Finalise test
This commit is contained in:
parent
facacb7b88
commit
55917748c4
|
@ -9,38 +9,37 @@ print("XOAUTH2 string: " + str(xoauth2))
|
||||||
|
|
||||||
|
|
||||||
class HTTPRequestHandler(BaseHTTPRequestHandler):
|
class HTTPRequestHandler(BaseHTTPRequestHandler):
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
auth = self.headers.get("Authorization")
|
auth = self.headers.get("Authorization")
|
||||||
if auth is None:
|
if auth is None:
|
||||||
self.send_response(401)
|
self.send_response(401)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
return
|
return
|
||||||
if len(auth.split()) != 2:
|
if len(auth.split()) != 2:
|
||||||
self.send_response(401)
|
self.send_response(401)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
return
|
return
|
||||||
auth = auth.split()[1]
|
auth = auth.split()[1]
|
||||||
if auth == token:
|
if auth == token:
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-Type', 'application/json')
|
self.send_header('Content-Type', 'application/json')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(json.dumps({
|
self.wfile.write(json.dumps({
|
||||||
"email": "user1@localhost.localdomain",
|
"email": "user1@localhost.localdomain",
|
||||||
"email_verified": True,
|
"email_verified": True,
|
||||||
"sub": "82c1c334dcc6e311ae4aaebfe946c5e858f055aff1ce5a37aa7cc91aab17e35c"
|
"sub": "82c1c334dcc6e311ae4aaebfe946c5e858f055aff1ce5a37aa7cc91aab17e35c"
|
||||||
}).encode("utf-8"))
|
}).encode("utf-8"))
|
||||||
else:
|
else:
|
||||||
self.send_response(401)
|
self.send_response(401)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
|
|
||||||
server = HTTPServer(('', 80), HTTPRequestHandler)
|
server = HTTPServer(('', 80), HTTPRequestHandler)
|
||||||
print("Starting server", flush=True)
|
print("Starting server", flush=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print()
|
print()
|
||||||
print("Received keyboard interrupt")
|
print("Received keyboard interrupt")
|
||||||
finally:
|
finally:
|
||||||
print("Exiting")
|
print("Exiting")
|
|
@ -20,7 +20,7 @@ function setup_file() {
|
||||||
--hostname "${FQDN_OAUTH2}" \
|
--hostname "${FQDN_OAUTH2}" \
|
||||||
--network "${DMS_TEST_NETWORK}" \
|
--network "${DMS_TEST_NETWORK}" \
|
||||||
--user "$(id -u):$(id -g)" \
|
--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 \
|
--expose 80 \
|
||||||
docker.io/library/python:latest \
|
docker.io/library/python:latest \
|
||||||
python /app/provider.py
|
python /app/provider.py
|
||||||
|
@ -77,6 +77,5 @@ function teardown() {
|
||||||
|
|
||||||
@test "oauth2: imap connect and authentication works" {
|
@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'
|
_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
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue