-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#293] add test for verifying idempotent behavior
- Loading branch information
Showing
2 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/openklant/setup_configuration/tests/files/token_idempotent.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
tokens_config_enable: true | ||
|
||
tokens_config: | ||
group: | ||
- identifier: token-1 | ||
contact_person: Person 1 | ||
email: [email protected] | ||
organization: Organization XYZ | ||
application: Application XYZ | ||
administration: Administration XYZ | ||
|
||
- identifier: token-2 | ||
contact_person: Person 2 | ||
email: [email protected] | ||
organization: Organization ZYX | ||
application: Application ZYX | ||
administration: Administration ZYX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,5 +173,55 @@ def test_validation_errors(self): | |
self.assertEqual(second_token.application, "Application ZYX") | ||
self.assertEqual(second_token.administration, "Administration ZYX") | ||
|
||
def test_impodent_configuration_step(self): | ||
raise NotImplementedError | ||
def test_idempotent_step(self): | ||
test_file_path = str(TEST_FILES / "token_idempotent.yaml") | ||
|
||
execute_single_step( | ||
TokenAuthConfigurationStep, yaml_source=test_file_path | ||
) | ||
|
||
tokens = TokenAuth.objects.order_by("created") | ||
|
||
self.assertEqual(tokens.count(), 2) | ||
|
||
first_token: TokenAuth = tokens[0] | ||
|
||
self.assertEqual(first_token.identifier, "token-1") | ||
self.assertEqual(first_token.contact_person, "Person 1") | ||
self.assertEqual(first_token.email, "[email protected]") | ||
self.assertEqual(first_token.organization, "Organization XYZ") | ||
self.assertEqual(first_token.application, "Application XYZ") | ||
self.assertEqual(first_token.administration, "Administration XYZ") | ||
|
||
second_token: TokenAuth = tokens[1] | ||
|
||
self.assertEqual(second_token.identifier, "token-2") | ||
self.assertEqual(second_token.contact_person, "Person 2") | ||
self.assertEqual(second_token.email, "[email protected]") | ||
self.assertEqual(second_token.organization, "Organization ZYX") | ||
self.assertEqual(second_token.application, "Application ZYX") | ||
self.assertEqual(second_token.administration, "Administration ZYX") | ||
|
||
execute_single_step( | ||
TokenAuthConfigurationStep, yaml_source=test_file_path | ||
) | ||
|
||
self.assertEqual(TokenAuth.objects.count(), 2) | ||
|
||
first_token.refresh_from_db() | ||
|
||
self.assertEqual(first_token.identifier, "token-1") | ||
self.assertEqual(first_token.contact_person, "Person 1") | ||
self.assertEqual(first_token.email, "[email protected]") | ||
self.assertEqual(first_token.organization, "Organization XYZ") | ||
self.assertEqual(first_token.application, "Application XYZ") | ||
self.assertEqual(first_token.administration, "Administration XYZ") | ||
|
||
second_token.refresh_from_db() | ||
|
||
self.assertEqual(second_token.identifier, "token-2") | ||
self.assertEqual(second_token.contact_person, "Person 2") | ||
self.assertEqual(second_token.email, "[email protected]") | ||
self.assertEqual(second_token.organization, "Organization ZYX") | ||
self.assertEqual(second_token.application, "Application ZYX") | ||
self.assertEqual(second_token.administration, "Administration ZYX") |