-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix: removal of temporary saml toggle #37651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
599fb53
32bf41d
9c587b9
cf68e2d
ac02cb3
30a8d18
2000223
db80c07
098a471
66ef4ab
ecaf568
174e7fa
a3beed6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,17 +69,16 @@ def setUp(self): | |
| # not processed. | ||
| self.saml_config = SAMLConfigurationFactory.create( | ||
| enabled=False, | ||
| site__domain='testserver.fake', | ||
| site__name='testserver.fake' | ||
| site__domain='setup.testserver.fake', | ||
| site__name='setup.testserver.fake' | ||
| ) | ||
| self.provider_config = SAMLProviderConfigFactory.create( | ||
| site__domain='testserver.fake', | ||
| site__name='testserver.fake', | ||
| slug='test-shib', | ||
| name='TestShib College', | ||
| entity_id='https://idp.testshib.org/idp/shibboleth', | ||
| metadata_source='https://www.testshib.org/metadata/testshib-providers.xml', | ||
| saml_configuration=self.saml_config, | ||
| site__domain='setup.testserver.fake', | ||
| site__name='setup.testserver.fake', | ||
| slug='setup-test-shib', | ||
| name='Setup TestShib College', | ||
| entity_id='https://idp.testshib.org/idp/setup-shibboleth', | ||
| metadata_source='https://www.testshib.org/metadata/setup-testshib-providers.xml', | ||
| ) | ||
|
|
||
| def _setup_test_configs_for_run_checks(self): | ||
|
|
@@ -170,7 +169,7 @@ def test_fetch_saml_metadata(self): | |
| # Create enabled configurations | ||
| self.__create_saml_configurations__() | ||
|
||
|
|
||
| expected = "\nDone.\n1 provider(s) found in database.\n0 skipped and 1 attempted.\n1 updated and 0 failed.\n" | ||
| expected = "\nDone.\n2 provider(s) found in database.\n1 skipped and 1 attempted.\n1 updated and 0 failed.\n" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain why removal of the toggle results in an additional provider?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, with the toggle gone, the base setup always creates a provider and configuration (the "setup" provider). When the test method also creates its own providers, the total number of providers in the database increases by one compared to before. That’s why, for example, the expected count changes from 1 to 2 providers in the test output.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| call_command("saml", pull=True, stdout=self.stdout) | ||
| assert expected in self.stdout.getvalue() | ||
|
|
||
|
|
@@ -183,7 +182,7 @@ def test_fetch_saml_metadata_failure(self): | |
| # Create enabled configurations | ||
| self.__create_saml_configurations__() | ||
|
|
||
| expected = "\nDone.\n1 provider(s) found in database.\n0 skipped and 1 attempted.\n0 updated and 1 failed.\n" | ||
| expected = "\nDone.\n2 provider(s) found in database.\n1 skipped and 1 attempted.\n0 updated and 1 failed.\n" | ||
|
|
||
| with self.assertRaisesRegex(CommandError, r"HTTPError: 404 Client Error"): | ||
| call_command("saml", pull=True, stdout=self.stdout) | ||
|
|
@@ -229,7 +228,7 @@ def test_fetch_multiple_providers_data(self): | |
| } | ||
| ) | ||
|
|
||
| expected = '\n3 provider(s) found in database.\n0 skipped and 3 attempted.\n2 updated and 1 failed.\n' | ||
| expected = '\n4 provider(s) found in database.\n1 skipped and 3 attempted.\n2 updated and 1 failed.\n' | ||
| with self.assertRaisesRegex(CommandError, r"MetadataParseError: Can't find EntityDescriptor for entityID"): | ||
| call_command("saml", pull=True, stdout=self.stdout) | ||
| assert expected in self.stdout.getvalue() | ||
|
|
@@ -251,8 +250,8 @@ def test_fetch_multiple_providers_data(self): | |
| } | ||
| ) | ||
|
|
||
| # Four configurations -- one will be skipped and three attempted, with similar results. | ||
| expected = '\nDone.\n4 provider(s) found in database.\n1 skipped and 3 attempted.\n0 updated and 1 failed.\n' | ||
| # Five configurations -- two will be skipped and three attempted, with similar results. | ||
| expected = '\nDone.\n5 provider(s) found in database.\n2 skipped and 3 attempted.\n0 updated and 1 failed.\n' | ||
| with self.assertRaisesRegex(CommandError, r"MetadataParseError: Can't find EntityDescriptor for entityID"): | ||
| call_command("saml", pull=True, stdout=self.stdout) | ||
| assert expected in self.stdout.getvalue() | ||
|
|
@@ -267,7 +266,7 @@ def test_saml_request_exceptions(self, mocked_get): | |
|
|
||
| mocked_get.side_effect = exceptions.SSLError | ||
|
|
||
| expected = "\nDone.\n1 provider(s) found in database.\n0 skipped and 1 attempted.\n0 updated and 1 failed.\n" | ||
| expected = "\nDone.\n2 provider(s) found in database.\n1 skipped and 1 attempted.\n0 updated and 1 failed.\n" | ||
|
|
||
| with self.assertRaisesRegex(CommandError, "SSLError:"): | ||
| call_command("saml", pull=True, stdout=self.stdout) | ||
|
|
@@ -324,7 +323,7 @@ def test_xml_parse_exceptions(self, mocked_get): | |
| # create enabled configuration | ||
| self.__create_saml_configurations__() | ||
|
|
||
| expected = "\nDone.\n1 provider(s) found in database.\n0 skipped and 1 attempted.\n0 updated and 1 failed.\n" | ||
| expected = "\nDone.\n2 provider(s) found in database.\n1 skipped and 1 attempted.\n0 updated and 1 failed.\n" | ||
|
|
||
| with self.assertRaisesRegex(CommandError, "XMLSyntaxError:"): | ||
| call_command("saml", pull=True, stdout=self.stdout) | ||
|
|
@@ -344,18 +343,20 @@ def test_run_checks_setup_test_data(self): | |
|
|
||
| This test validates that the base setup data (from setUp) is correctly | ||
| identified as having configuration issues. The setup includes a provider | ||
| (self.provider_config) with a disabled SAML configuration (self.saml_config), | ||
| which is reported as a disabled config issue (not a missing config). | ||
| (self.provider_config) with no direct SAML configuration, falling back to | ||
| a disabled default configuration (self.saml_config), which is reported as | ||
| a disabled config issue (not a missing config). | ||
| """ | ||
| output = self._run_checks_command() | ||
|
|
||
| # The setup data includes a provider with a disabled SAML config | ||
| # The setup data includes a provider with no direct SAML config, using disabled default config | ||
| expected_warning = ( | ||
| f'[WARNING] Provider (id={self.provider_config.id}, ' | ||
| f'name={self.provider_config.name}, ' | ||
| f'slug={self.provider_config.slug}, ' | ||
| f'site_id={self.provider_config.site_id}) ' | ||
| f'has SAML config (id={self.saml_config.id}, enabled=False).' | ||
| f'has no direct SAML configuration and the default configuration ' | ||
| f'(id={self.saml_config.id}, enabled=False).' | ||
| ) | ||
| self.assertIn(expected_warning, output) | ||
| self.assertIn('Missing configs: 0', output) # No missing configs from setUp | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help explain why these changes are needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robrap Previously, the test setup used names like testserver.fake and test-shib for both the base test data (created in setUp) and for additional test data created in individual test methods. This caused problems because some tests would accidentally interact with or be affected by the base data, leading to confusing or flaky test results.
By changing the setup data to use unique names (like setup.testserver.fake and setup-test-shib), make sure that the base data created for all tests is clearly separated from any test-specific data.