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
The following commit(s) were added to refs/heads/master by this push:
new a080104 Allow for multiple users
a080104 is described below
commit a0801042fa7d04244a83d65c7547ba535010f828
Author: Sebb <[email protected]>
AuthorDate: Wed Jan 26 23:21:49 2022 +0000
Allow for multiple users
---
server/test/testauth.py | 31 +++++++++++--------------------
server/test/testauth.yaml | 24 ++++++++++--------------
2 files changed, 21 insertions(+), 34 deletions(-)
diff --git a/server/test/testauth.py b/server/test/testauth.py
index ed693a7..3443647 100644
--- a/server/test/testauth.py
+++ b/server/test/testauth.py
@@ -44,18 +44,6 @@ import typing
import uuid
import yaml
-# default data if file is not readable
-DATA = {
- 'uid': 'test',
- 'email': '[email protected]',
- 'fullname': "Test Name",
- 'isMember': True,
- 'isChair': True,
- 'projects': ['a', 'b', 'b'],
- 'pmcs': ['a', 'b', 'b'],
- 'state': None
-}
-
async def process(server: plugins.server.BaseServer, session: dict, indata:
dict) -> typing.Union[aiohttp.web.Response, dict]:
print('INDATA', indata)
redirect_uri = indata.get('redirect_uri')
@@ -71,15 +59,18 @@ async def process(server: plugins.server.BaseServer,
session: dict, indata: dict
try:
data = yaml.safe_load(open(datafile))['oauth_data']
print(f'using data from {datafile}')
+ user = indata.get('user', 'user')
+ if user in data:
+ data = data[user]
+ data['state'] = indata.get('state')
+ print(f"testauth: {data}")
+ return data
+ else:
+ print(f"Could not find record for {user}")
except:
- print('Using built-in data')
- data = DATA
- if 'state' in data:
- data['state'] = indata.get('state') # fix up
- print(data)
- return data
- else:
- return {"okay": False, "message": "Invalid invocation!"}
+ print(f'Could not find data file {datafile}')
+
+ return {"okay": False, "message": "Invalid invocation!"}
def register(server: plugins.server.BaseServer):
return plugins.server.Endpoint(process)
diff --git a/server/test/testauth.yaml b/server/test/testauth.yaml
index 03db5d7..c7176e4 100644
--- a/server/test/testauth.yaml
+++ b/server/test/testauth.yaml
@@ -2,17 +2,13 @@
# This is read by the corresponding endpoint script
oauth_data:
- uid: test
- email: [email protected]
- fullname: Test Name
- isMember: True
- isChair: True
- projects:
- - a
- - b
- - c
- pmcs:
- - d
- - e
- - f
- state: TBA # will be replaced at runtime
\ No newline at end of file
+ admin:
+ uid: admin
+ email: [email protected]
+ name: Admin
+ fullname: Admin Name
+ user:
+ uid: user
+ email: [email protected]
+ name: User
+ fullname: User Name