Skip to content
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

Following up #757 - Fixed remaining non-idempotent tests #758

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

kaiyaok2
Copy link
Contributor

Following up #757 : this PRs fixed the remaining non-idempotent unit tests in the repository.

Test that depend on access permission:

  • TestAppResource#testAppResource
    Reason: The test first asserts that guest login is disabled in default state, and then enables guest login. In the second execution, the assertion will fail since guest login is globally enabled after the first test run.

Fix: Disable guest login before finishing test execution.

Test that depend on default theme resource:

  • TestThemeResource#testThemeResource
    Reason: The test first asserts that the main color is (by default) #ffffff, but later changed it to #ff0000. It does not reset it back to #ffffff in the end, so the assertion will fail in the second test execution.

Fix: Reset main color to #ffffff at the end of the test.

Tests that creates users with fixed usernames:

  • TestAuditLogResource#testAuditLogResource
  • TestGroupResource#testGroupResource
  • TestRouteModelResource#testRouteModelResource
  • TestSecurity#testSecurity
  • TestSecurity#testHeaderBasedAuthentication
  • TestShareResource#testShareResource
  • TestTagResource#testTagResource
  • TestUserResource#testUserResource
  • TestUserResource#testResetPassword
  • TestWebhookResource#testWebhookResource
    Reason: Similarly to previous discussion of TestUserResource#testTotp in Fixed non-idempotent unit tests #757 , the test creates a users with specific names without deleting them in the end. Therefore, HTTP 400 Bad Request errors will occur on creating the users with the same names in the second executions, since the users already exist in the database.

Fix: Delete the created users at the end of the tests.

Tests that depend on the inherently non-idempotent POST method:

  • TestAppResource#testSmtpConfiguration
  • TestAppResource#testLdapAuthentication

Reason: Similarly to previous discussion of TestAppResource#TestInbox in #757 , these tests initially get specific configurations and asserts they're in default state. However, the non-revertible POST method changes these configurations, and there's no trivial way to restore this configurations to default. Hence, assertions of default configurations shall only be made in the first run of the test.

Fix: Add static flags to ensure that assertions with respect to default configurations are only executed in the first test execution.

@jendib jendib merged commit 8f1ff56 into sismics:master Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants