Skip to content
Open
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
4 changes: 3 additions & 1 deletion cypress/e2e/common/ui/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Then(
export const selectOption = (option: string, selector: string) => {
cy.dataCy(selector + "-toggle").click();
cy.dataCy(selector + "-toggle").should("have.attr", "aria-expanded", "true");
cy.dataCy(selector + "-" + option).click();
cy.dataCy(selector + "-" + option)
.find("button")
.click({ force: true });
};

export const isOptionSelected = (option: string, selector: string) => {
Expand Down
48 changes: 48 additions & 0 deletions cypress/e2e/otp_tokens/otp_token_management.ts
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}"`,
});
}
);
194 changes: 194 additions & 0 deletions cypress/e2e/otp_tokens/otp_tokens.feature
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

Copy link
Copy Markdown
Contributor

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 table or something along the lines

Copy link
Copy Markdown
Contributor

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

When I search for "otpmanager" in the members table
Then I should see "otpmanager" entry in the data table


@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

Copy link
Copy Markdown
Contributor

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 table


@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this test is needed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be @cleanup and @seed again between these tests

@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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"
72 changes: 72 additions & 0 deletions cypress/e2e/otp_tokens/otp_tokens_managedby.feature
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"
Loading
Loading