Skip to content

Commit 7b12dd4

Browse files
authored
PYTHON-4256 OIDC Test Cleanup (mongodb#1632)
1 parent 46da55b commit 7b12dd4

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

test/auth/unified/mongodb-oidc-no-retry.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
{
66
"minServerVersion": "7.0",
77
"auth": true,
8-
"authMechanism": "MONGODB-OIDC"
8+
"authMechanism": "MONGODB-OIDC",
9+
"serverless": "forbid"
910
}
1011
],
1112
"createEntities": [

test/auth_oidc/test_auth_oidc.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -824,30 +824,21 @@ def fetch(self, a):
824824
# Close the client.
825825
client.close()
826826

827-
def test_2_4_oidc_callback_returns_invalid_data(self):
828-
# Create a MongoClient configured with an OIDC callback that returns data not conforming to the OIDCCredential with extra fields.
829-
class CustomCallback(OIDCCallback):
830-
count = 0
831-
832-
def fetch(self, a):
833-
self.count += 1
834-
return OIDCCallbackResult(access_token="bad value")
835-
836-
client = self.create_client(request_cb=CustomCallback())
837-
# Perform a ``find`` operation that fails.
838-
with self.assertRaises(OperationFailure):
839-
client.test.test.find_one()
840-
# Close the client.
841-
client.close()
842-
843-
def test_2_5_invalid_client_configuration_with_callback(self):
827+
def test_2_4_invalid_client_configuration_with_callback(self):
844828
# Create a MongoClient configured with an OIDC callback and auth mechanism property ENVIRONMENT:test.
845829
request_cb = self.create_request_cb()
846830
props: Dict = {"OIDC_CALLBACK": request_cb, "ENVIRONMENT": "test"}
847831
# Assert it returns a client configuration error.
848832
with self.assertRaises(ConfigurationError):
849833
self.create_client(authmechanismproperties=props)
850834

835+
def test_2_5_invalid_use_of_ALLOWED_HOSTS(self):
836+
# Create an OIDC configured client with auth mechanism properties `{"ENVIRONMENT": "azure", "ALLOWED_HOSTS": []}`.
837+
props: Dict = {"ENVIRONMENT": "azure", "ALLOWED_HOSTS": []}
838+
# Assert it returns a client configuration error.
839+
with self.assertRaises(ConfigurationError):
840+
self.create_client(authmechanismproperties=props)
841+
851842
def test_3_1_authentication_failure_with_cached_tokens_fetch_a_new_token_and_retry(self):
852843
# Create a MongoClient and an OIDC callback that implements the provider logic.
853844
client = self.create_client()

0 commit comments

Comments
 (0)