diff --git a/test/test-files/auth/oauth2/provider.py b/test/config/oauth2/provider.py similarity index 53% rename from test/test-files/auth/oauth2/provider.py rename to test/config/oauth2/provider.py index 824c31f1..47ae3fed 100644 --- a/test/test-files/auth/oauth2/provider.py +++ b/test/config/oauth2/provider.py @@ -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") diff --git a/test/tests/serial/mail_with_oauth2.bats b/test/tests/serial/mail_with_oauth2.bats index 822baf7d..70b2e896 100644 --- a/test/tests/serial/mail_with_oauth2.bats +++ b/test/tests/serial/mail_with_oauth2.bats @@ -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 }