-
Notifications
You must be signed in to change notification settings - Fork 26
Add tests for OTP tokens pages #1149
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: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { Given } from "@badeball/cypress-cucumber-preprocessor"; | ||
| import { IPA_PREFIX } from "../../support/utils"; | ||
|
|
||
| Given( | ||
| "OTP token {string} exists for user {string} with type {string} and description {string}", | ||
| (tokenId: string, owner: string, type: string, description: string) => { | ||
| cy.ipa({ | ||
| command: "otptoken-add", | ||
| name: tokenId, | ||
| specificOptions: `--owner="${owner}" --desc="${description}" --type=${type}`, | ||
| }); | ||
| } | ||
| ); | ||
|
|
||
| Given( | ||
| "an OTP token exists for user {string} with type {string} and description {string}", | ||
| (owner: string, type: string, description: string) => { | ||
| cy.exec( | ||
| `${IPA_PREFIX} otptoken-add --owner="${owner}" --desc="${description}" --type=${type}` | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| Given("I delete OTP token {string}", (tokenId: string) => { | ||
| cy.ipa({ | ||
| command: "otptoken-del", | ||
| name: tokenId, | ||
| }); | ||
| }); | ||
|
|
||
| Given("OTP token {string} is disabled", (tokenId: string) => { | ||
| cy.ipa({ | ||
| command: "otptoken-mod", | ||
| name: tokenId, | ||
| specificOptions: "--disabled=TRUE", | ||
| }); | ||
| }); | ||
|
|
||
| Given( | ||
| "user {string} is manager of OTP token {string}", | ||
| (userName: string, tokenId: string) => { | ||
| cy.ipa({ | ||
| command: "otptoken-add-managedby", | ||
| name: tokenId, | ||
| specificOptions: `--users="${userName}"`, | ||
| }); | ||
| } | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| Feature: OTP tokens manipulation | ||
| Create, search, enable, disable and delete OTP tokens | ||
|
|
||
| @seed | ||
| Scenario: Prep: Create user for TOTP test | ||
| Given User "otpuser" "OTP" "User" exists and is using password "Secret123" | ||
|
|
||
| @test | ||
| Scenario: Add a new TOTP token with owner | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I click on the "otp-tokens-button-add" button | ||
| Then I should see "add-otp-token-modal" modal | ||
| And I should see the "modal-radio-totp" radio button is selected | ||
|
|
||
| When I type in the "modal-textbox-description" textbox text "totp_token" | ||
| Then I should see "totp_token" in the "modal-textbox-description" textbox | ||
|
|
||
| When I select "otpuser" option in the "modal-select-owner" selector | ||
| Then I should see "otpuser" option in the "modal-select-owner" selector | ||
|
|
||
| When I click on the "modal-button-add" button | ||
| Then I should not see "add-otp-token-modal" modal | ||
|
|
||
| @cleanup | ||
| Scenario: Cleanup: Delete test data after TOTP test | ||
| Given I delete user "otpuser" | ||
|
|
||
| @seed | ||
| Scenario: Prep: Create user for HOTP test | ||
| Given User "otpuser" "OTP" "User" exists and is using password "Secret123" | ||
|
|
||
| @test | ||
| Scenario: Add a new HOTP token with owner | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I click on the "otp-tokens-button-add" button | ||
| Then I should see "add-otp-token-modal" modal | ||
|
|
||
| When I click on the "modal-radio-hotp" radio button | ||
| Then I should see the "modal-radio-hotp" radio button is selected | ||
| And I should see the "modal-radio-totp" radio button is not selected | ||
|
|
||
| When I type in the "modal-textbox-description" textbox text "hotp_token" | ||
| Then I should see "hotp_token" in the "modal-textbox-description" textbox | ||
|
|
||
| When I select "otpuser" option in the "modal-select-owner" selector | ||
| Then I should see "otpuser" option in the "modal-select-owner" selector | ||
|
|
||
| When I click on the "modal-button-add" button | ||
| Then I should not see "add-otp-token-modal" modal | ||
|
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.
|
||
|
|
||
| @cleanup | ||
| Scenario: Cleanup: Delete test data after HOTP test | ||
| Given I delete user "otpuser" | ||
|
|
||
| @seed | ||
| Scenario: Prep: Create user and token for search test | ||
| Given User "otpuser" "OTP" "User" exists and is using password "Secret123" | ||
| And an OTP token exists for user "otpuser" with type "totp" and description "search_token" | ||
|
|
||
| @test | ||
| Scenario: Search for an OTP token by owner | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I search for "otpuser" in the data table | ||
| Then I should see "otpuser" entry in the data table with ID "otp-tokens-table" | ||
|
|
||
| @test | ||
| Scenario: Cancel creation of an OTP token | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I click on the "otp-tokens-button-add" button | ||
| Then I should see "add-otp-token-modal" modal | ||
|
|
||
| When I type in the "modal-textbox-description" textbox text "cancel_token" | ||
| Then I should see "cancel_token" in the "modal-textbox-description" textbox | ||
|
|
||
| When I click on the "modal-button-cancel" button | ||
| Then I should not see "add-otp-token-modal" modal | ||
|
|
||
| @test | ||
| Scenario: TOTP is the default token type | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I click on the "otp-tokens-button-add" button | ||
| Then I should see "add-otp-token-modal" modal | ||
| And I should see the "modal-radio-totp" radio button is selected | ||
| And I should see the "modal-radio-hotp" radio button is not selected | ||
|
|
||
| When I click on the "modal-button-cancel" button | ||
| Then I should not see "add-otp-token-modal" modal | ||
|
|
||
| @test | ||
| Scenario: Delete button is disabled when no token is selected | ||
|
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. I dont think this test is needed
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. and the following two as well |
||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| Then I should see the "otp-tokens-button-delete" button is disabled | ||
|
|
||
| @test | ||
| Scenario: Enable button is disabled when no token is selected | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| Then I should see the "otp-tokens-button-enable" button is disabled | ||
|
|
||
| @test | ||
| Scenario: Disable button is disabled when no token is selected | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| Then I should see the "otp-tokens-button-disable" button is disabled | ||
|
|
||
| @cleanup | ||
| Scenario: Cleanup: Delete search test data | ||
| Given I delete user "otpuser" | ||
|
|
||
| @seed | ||
| Scenario: Prep: Create user and token for disable test | ||
| Given User "otpuser" "OTP" "User" exists and is using password "Secret123" | ||
| And an OTP token exists for user "otpuser" with type "totp" and description "disable_token" | ||
|
|
||
| @test | ||
| Scenario: Disable an OTP token | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I search for "otpuser" in the data table | ||
| Then I should see "otpuser" entry in the data table with ID "otp-tokens-table" | ||
|
|
||
| When I select "otpuser" entry in the data table with ID "otp-tokens-table" | ||
| Then I should see "otpuser" entry selected in the data table with ID "otp-tokens-table" | ||
|
|
||
| When I click on the "otp-tokens-button-disable" button | ||
| Then I should see "enable-disable-otp-tokens-modal" modal | ||
|
|
||
| When I click on the "modal-button-ok" button | ||
| Then I should not see "enable-disable-otp-tokens-modal" modal | ||
| And I should see "success" alert | ||
|
|
||
|
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. there should be |
||
| @test | ||
| Scenario: Enable a disabled OTP token | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I search for "otpuser" in the data table | ||
| Then I should see "otpuser" entry in the data table with ID "otp-tokens-table" | ||
|
|
||
| When I select "otpuser" entry in the data table with ID "otp-tokens-table" | ||
| Then I should see "otpuser" entry selected in the data table with ID "otp-tokens-table" | ||
|
|
||
| When I click on the "otp-tokens-button-enable" button | ||
| Then I should see "enable-disable-otp-tokens-modal" modal | ||
|
|
||
| When I click on the "modal-button-ok" button | ||
| Then I should not see "enable-disable-otp-tokens-modal" modal | ||
| And I should see "success" alert | ||
|
|
||
| @cleanup | ||
| Scenario: Cleanup: Delete disable/enable test data | ||
| Given I delete user "otpuser" | ||
|
|
||
| @seed | ||
| Scenario: Seed: Create user and OTP token for delete test | ||
| Given User "otpuser" "OTP" "User" exists and is using password "Secret123" | ||
| And an OTP token exists for user "otpuser" with type "totp" and description "delete_token" | ||
|
|
||
| @test | ||
| Scenario: Delete an OTP token | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens" page | ||
|
|
||
| When I search for "otpuser" in the data table | ||
| Then I should see "otpuser" entry in the data table with ID "otp-tokens-table" | ||
|
|
||
| When I select "otpuser" entry in the data table with ID "otp-tokens-table" | ||
| Then I should see "otpuser" entry selected in the data table with ID "otp-tokens-table" | ||
|
|
||
| When I click on the "otp-tokens-button-delete" button | ||
| Then I should see "delete-otp-tokens-modal" modal | ||
|
|
||
| When I click on the "modal-button-ok" button | ||
| Then I should see "remove-otp-tokens-success" alert | ||
| And I should not see "delete-otp-tokens-modal" modal | ||
|
|
||
| @cleanup | ||
| Scenario: Cleanup: Delete test data and remaining tokens | ||
|
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. nitpick: the name of the cleanup is a bit confusing |
||
| Given I delete user "otpuser" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| Feature: OTP tokens - Is managed by page | ||
| Manage OTP token managers (users) | ||
|
|
||
| @seed | ||
| Scenario: Prep: Create users and OTP token for add manager test | ||
| Given User "otpmgdbyuser" "OTPManaged" "User" exists and is using password "Secret123" | ||
| And User "otpmanager" "OTP" "Manager" exists and is using password "Secret123" | ||
| And OTP token "managedby_token" exists for user "otpmgdbyuser" with type "totp" and description "managedby_token" | ||
|
|
||
| @test | ||
| Scenario: Add a user manager to OTP token | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens/managedby_token" page | ||
|
|
||
| When I click on the "otp-tokens-tab-managedby" tab | ||
| Then I should see "otp-tokens-tab-managedby" tab selected | ||
|
|
||
| When I click on the "member-of-button-add" button | ||
| Then I should see "member-of-add-modal" modal | ||
| And I should see "item-otpmanager" dual list item on the left | ||
|
|
||
| When I click on "item-otpmanager" dual list item | ||
| Then I should see "item-otpmanager" dual list item selected | ||
| When I click on the "dual-list-add-selected" button | ||
| Then I should see "item-otpmanager" dual list item on the right | ||
|
|
||
| When I click on the "modal-button-add" button | ||
| Then I should not see "member-of-add-modal" modal | ||
| And I should see "add-managedby-success" alert | ||
|
|
||
| When I search for "otpmanager" in the members table | ||
| Then I should see "otpmanager" entry in the data table | ||
|
|
||
| @cleanup | ||
| Scenario: Cleanup: Delete add manager test data | ||
| Given I delete OTP token "managedby_token" | ||
| And I delete user "otpmgdbyuser" | ||
| And I delete user "otpmanager" | ||
|
|
||
| @seed | ||
| Scenario: Prep: Create users, OTP token, and manager for remove test | ||
| Given User "otpmgdbyuser" "OTPManaged" "User" exists and is using password "Secret123" | ||
| And User "otpmanager" "OTP" "Manager" exists and is using password "Secret123" | ||
| And OTP token "managedby_token" exists for user "otpmgdbyuser" with type "totp" and description "managedby_token" | ||
| And user "otpmanager" is manager of OTP token "managedby_token" | ||
|
|
||
| @test | ||
| Scenario: Remove a user manager from OTP token | ||
| Given I am logged in as admin | ||
| And I am on "otp-tokens/managedby_token" page | ||
|
|
||
| When I click on the "otp-tokens-tab-managedby" tab | ||
| Then I should see "otp-tokens-tab-managedby" tab selected | ||
|
|
||
| When I select entry "otpmanager" in the members table | ||
| Then I should see "otpmanager" entry selected in the data table | ||
|
|
||
| When I click on the "member-of-button-delete" button | ||
| Then I should see "member-of-delete-modal" modal | ||
|
|
||
| When I click on the "modal-button-delete" button | ||
| Then I should not see "member-of-delete-modal" modal | ||
| And I should see "remove-managedby-success" alert | ||
|
|
||
| When I search for "otpmanager" in the members table | ||
| Then I should not see "otpmanager" entry in the data table | ||
|
|
||
| @cleanup | ||
| Scenario: Cleanup: Delete remove manager test data | ||
| Given I delete OTP token "managedby_token" | ||
| And I delete user "otpmgdbyuser" | ||
| And I delete user "otpmanager" |
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.
And I should see the token in the tableor something along the linesThere 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.
similar to this
```
And I should see "add-managedby-success" alert