Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/auth/unified/mongodb-oidc-no-retry.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
{
"minServerVersion": "7.0",
"auth": true,
"authMechanism": "MONGODB-OIDC"
"authMechanism": "MONGODB-OIDC",
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
25 changes: 8 additions & 17 deletions test/auth_oidc/test_auth_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,30 +824,21 @@ def fetch(self, a):
# Close the client.
client.close()

def test_2_4_oidc_callback_returns_invalid_data(self):
# Create a MongoClient configured with an OIDC callback that returns data not conforming to the OIDCCredential with extra fields.
class CustomCallback(OIDCCallback):
count = 0

def fetch(self, a):
self.count += 1
return OIDCCallbackResult(access_token="bad value")

client = self.create_client(request_cb=CustomCallback())
# Perform a ``find`` operation that fails.
with self.assertRaises(OperationFailure):
client.test.test.find_one()
# Close the client.
client.close()

def test_2_5_invalid_client_configuration_with_callback(self):
def test_2_4_invalid_client_configuration_with_callback(self):
# Create a MongoClient configured with an OIDC callback and auth mechanism property ENVIRONMENT:test.
request_cb = self.create_request_cb()
props: Dict = {"OIDC_CALLBACK": request_cb, "ENVIRONMENT": "test"}
# Assert it returns a client configuration error.
with self.assertRaises(ConfigurationError):
self.create_client(authmechanismproperties=props)

def test_2_5_invalid_use_of_ALLOWED_HOSTS(self):
# Create an OIDC configured client with auth mechanism properties `{"ENVIRONMENT": "azure", "ALLOWED_HOSTS": []}`.
props: Dict = {"ENVIRONMENT": "azure", "ALLOWED_HOSTS": []}
# Assert it returns a client configuration error.
with self.assertRaises(ConfigurationError):
self.create_client(authmechanismproperties=props)

def test_3_1_authentication_failure_with_cached_tokens_fetch_a_new_token_and_retry(self):
# Create a MongoClient and an OIDC callback that implements the provider logic.
client = self.create_client()
Expand Down