You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2022/01/27 16:29:46 UTC

[incubator-ponymail-foal] branch master updated (9762142 -> 1dd03e4)

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.


    from 9762142  Bump server version
     new 91ef399  Enable test endpoints
     new 1dd03e4  Bump version

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 server/main.py                               | 35 +++++++++++++++++++---------
 server/server_version.py                     |  2 +-
 server/{test => testendpoints}/testauth.py   |  3 ++-
 server/{test => testendpoints}/testauth.yaml |  0
 4 files changed, 27 insertions(+), 13 deletions(-)
 rename server/{test => testendpoints}/testauth.py (94%)
 rename server/{test => testendpoints}/testauth.yaml (100%)

[incubator-ponymail-foal] 02/02: Bump version

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 1dd03e4874f399d01aa150b9253adb8b321e5fb0
Author: Sebb <se...@apache.org>
AuthorDate: Thu Jan 27 16:00:51 2022 +0000

    Bump version
---
 server/server_version.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/server_version.py b/server/server_version.py
index eb0eb62..1b96c55 100644
--- a/server/server_version.py
+++ b/server/server_version.py
@@ -1,2 +1,2 @@
 # This file is generated by server/update_version.sh
-PONYMAIL_SERVER_VERSION = 'ea53571'
+PONYMAIL_SERVER_VERSION = '91ef399'

[incubator-ponymail-foal] 01/02: Enable test endpoints

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 91ef3996ac4fa5a7b88a18cdc052a6560cb87bcb
Author: Sebb <se...@apache.org>
AuthorDate: Thu Jan 27 16:00:36 2022 +0000

    Enable test endpoints
---
 server/main.py                               | 35 +++++++++++++++++++---------
 server/{test => testendpoints}/testauth.py   |  3 ++-
 server/{test => testendpoints}/testauth.yaml |  0
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/server/main.py b/server/main.py
index 522756a..f21a684 100644
--- a/server/main.py
+++ b/server/main.py
@@ -53,6 +53,19 @@ if not sys.stdout.buffer.isatty():
 class Server(plugins.server.BaseServer):
     """Main server class, responsible for handling requests and scheduling offloader threads """
 
+    def _load_endpoint(self, subdir):
+        for endpoint_file in sorted(os.listdir(subdir)):
+            if endpoint_file.endswith(".py"):
+                endpoint = endpoint_file[:-3]
+                m = importlib.import_module(f"{subdir}.{endpoint}")
+                if hasattr(m, "register"):
+                    self.handlers[endpoint] = m.__getattribute__("register")(self)
+                    print(f"Registered endpoint /api/{endpoint}")
+                else:
+                    print(
+                        f"Could not find entry point 'register()' in {endpoint_file}, skipping!"
+                    )
+
     def __init__(self, args: argparse.Namespace):
         print(
             "==== Apache Pony Mail (Foal v/%s ~%s) starting... ====" % (PONYMAIL_FOAL_VERSION, PONYMAIL_SERVER_VERSION)
@@ -80,17 +93,12 @@ class Server(plugins.server.BaseServer):
             self.dbpool.put_nowait(plugins.database.Database(self.config.database))
 
         # Load each URL endpoint
-        for endpoint_file in os.listdir("endpoints"):
-            if endpoint_file.endswith(".py"):
-                endpoint = endpoint_file[:-3]
-                m = importlib.import_module(f"endpoints.{endpoint}")
-                if hasattr(m, "register"):
-                    self.handlers[endpoint] = m.__getattribute__("register")(self)
-                    print(f"Registered endpoint /api/{endpoint}")
-                else:
-                    print(
-                        f"Could not find entry point 'register()' in {endpoint_file}, skipping!"
-                    )
+        if args.testendpoints:
+            print("** Loading additional testing endpoints **")
+            self._load_endpoint("testendpoints")
+            print()
+        self._load_endpoint("endpoints")
+
         if args.logger:
             import logging
             es_logger = logging.getLogger('elasticsearch')
@@ -262,5 +270,10 @@ if __name__ == "__main__":
         action='store_true',
         help="Allow remote refresh for testing",
     )
+    parser.add_argument(
+        "--testendpoints",
+        action='store_true',
+        help="Enable test endpoints",
+    )
     cliargs = parser.parse_args()
     Server(cliargs).run()
diff --git a/server/test/testauth.py b/server/testendpoints/testauth.py
similarity index 94%
rename from server/test/testauth.py
rename to server/testendpoints/testauth.py
index 3443647..d03138e 100644
--- a/server/test/testauth.py
+++ b/server/testendpoints/testauth.py
@@ -19,7 +19,8 @@
     Simple endpoint that does a local login
 
 To enable:
-- copy the files server/test/testauth.[py|.yaml] to the server/endpoints directory
+- Add the --testendpoints qualifier to the server startup command
+  Alternatively copy the files server/test/testauth.[py|.yaml] to the server/endpoints directory
   They can be renamed if necessary, so long as they have the same basename;
   adjust the URLs below to reflect the new name
 
diff --git a/server/test/testauth.yaml b/server/testendpoints/testauth.yaml
similarity index 100%
rename from server/test/testauth.yaml
rename to server/testendpoints/testauth.yaml