Finalise test

This commit is contained in:
Keval Kapdee 2023-11-15 18:26:39 +00:00
parent facacb7b88
commit 55917748c4
2 changed files with 28 additions and 30 deletions

View File

@ -9,38 +9,37 @@ print("XOAUTH2 string: " + str(xoauth2))
class HTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
auth = self.headers.get("Authorization")
if auth is None:
self.send_response(401)
self.end_headers()
return
if len(auth.split()) != 2:
self.send_response(401)
self.end_headers()
return
auth = auth.split()[1]
if auth == token:
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps({
"email": "user1@localhost.localdomain",
"email_verified": True,
"sub": "82c1c334dcc6e311ae4aaebfe946c5e858f055aff1ce5a37aa7cc91aab17e35c"
}).encode("utf-8"))
else:
self.send_response(401)
self.end_headers()
def do_GET(self):
auth = self.headers.get("Authorization")
if auth is None:
self.send_response(401)
self.end_headers()
return
if len(auth.split()) != 2:
self.send_response(401)
self.end_headers()
return
auth = auth.split()[1]
if auth == token:
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps({
"email": "user1@localhost.localdomain",
"email_verified": True,
"sub": "82c1c334dcc6e311ae4aaebfe946c5e858f055aff1ce5a37aa7cc91aab17e35c"
}).encode("utf-8"))
else:
self.send_response(401)
self.end_headers()
server = HTTPServer(('', 80), HTTPRequestHandler)
print("Starting server", flush=True)
try:
server.serve_forever()
server.serve_forever()
except KeyboardInterrupt:
print()
print("Received keyboard interrupt")
print()
print("Received keyboard interrupt")
finally:
print("Exiting")
print("Exiting")

View File

@ -20,7 +20,7 @@ function setup_file() {
--hostname "${FQDN_OAUTH2}" \
--network "${DMS_TEST_NETWORK}" \
--user "$(id -u):$(id -g)" \
--volume "${REPOSITORY_ROOT}/test/test-files/auth/oauth2/provider.py:/app/provider.py" \
--volume "${REPOSITORY_ROOT}/test/config/oauth2/:/app/" \
--expose 80 \
docker.io/library/python:latest \
python /app/provider.py
@ -77,6 +77,5 @@ function teardown() {
@test "oauth2: imap connect and authentication works" {
_run_in_container_bash 'nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-oauth2-auth.txt'
sleep 120
assert_success
}