2021-07-14 10:14:03 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
2022-12-07 15:28:28 +00:00
|
|
|
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
|
|
|
|
import SessionsPage from "../support/pages/admin-ui/manage/sessions/SessionsPage";
|
2022-09-12 13:30:12 +00:00
|
|
|
import CommonPage from "../support/pages/CommonPage";
|
2022-12-07 15:28:28 +00:00
|
|
|
import ListingPage from "../support/pages/admin-ui/ListingPage";
|
2022-01-07 07:27:58 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2023-10-26 14:50:45 +00:00
|
|
|
import PageObject from "../support/pages/admin-ui/components/PageObject";
|
2023-12-15 11:55:11 +00:00
|
|
|
import adminClient from "../support/util/AdminClient";
|
|
|
|
import { v4 as uuid } from "uuid";
|
2021-07-14 10:14:03 +00:00
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const sessionsPage = new SessionsPage();
|
2022-09-12 13:30:12 +00:00
|
|
|
const commonPage = new CommonPage();
|
|
|
|
const listingPage = new ListingPage();
|
2023-10-26 14:50:45 +00:00
|
|
|
const page = new PageObject();
|
2021-07-14 10:14:03 +00:00
|
|
|
|
2021-10-04 06:03:19 +00:00
|
|
|
describe("Sessions test", () => {
|
2022-09-12 13:30:12 +00:00
|
|
|
const admin = "admin";
|
|
|
|
const client = "security-admin-console";
|
2023-02-10 10:10:35 +00:00
|
|
|
|
2022-02-22 13:30:18 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
loginPage.logIn();
|
2023-02-10 10:10:35 +00:00
|
|
|
keycloakBefore();
|
2022-02-22 13:30:18 +00:00
|
|
|
sidebarPage.goToSessions();
|
|
|
|
});
|
2021-08-16 19:25:36 +00:00
|
|
|
|
2022-09-12 13:30:12 +00:00
|
|
|
describe("Sessions list view", () => {
|
|
|
|
it("check item values", () => {
|
2022-10-25 08:57:22 +00:00
|
|
|
listingPage.searchItem(client, false);
|
2022-09-12 13:30:12 +00:00
|
|
|
commonPage
|
|
|
|
.tableUtils()
|
|
|
|
.checkRowItemExists(admin)
|
2023-12-15 11:55:11 +00:00
|
|
|
.checkRowItemExists(client)
|
|
|
|
.assertRowItemActionExist(admin, "Sign out");
|
2022-09-12 13:30:12 +00:00
|
|
|
});
|
2021-08-16 19:25:36 +00:00
|
|
|
|
2022-09-12 13:30:12 +00:00
|
|
|
it("go to item accessed clients link", () => {
|
2022-10-25 08:57:22 +00:00
|
|
|
listingPage.searchItem(client, false);
|
2022-09-12 13:30:12 +00:00
|
|
|
commonPage.tableUtils().clickRowItemLink(client);
|
|
|
|
});
|
2022-02-22 13:30:18 +00:00
|
|
|
});
|
2021-08-16 19:25:36 +00:00
|
|
|
|
2023-12-15 11:55:11 +00:00
|
|
|
describe("Offline sessions", () => {
|
|
|
|
const clientId = "offline-client-" + uuid();
|
|
|
|
const username = "user-" + uuid();
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
await Promise.all([
|
|
|
|
adminClient.createClient({
|
|
|
|
protocol: "openid-connect",
|
|
|
|
clientId,
|
|
|
|
publicClient: false,
|
|
|
|
directAccessGrantsEnabled: true,
|
|
|
|
clientAuthenticatorType: "client-secret",
|
|
|
|
secret: "secret",
|
|
|
|
standardFlowEnabled: true,
|
|
|
|
}),
|
|
|
|
adminClient.createUser({
|
|
|
|
// Create user in master realm
|
|
|
|
username: username,
|
|
|
|
enabled: true,
|
|
|
|
credentials: [{ type: "password", value: "password" }],
|
|
|
|
}),
|
|
|
|
]);
|
|
|
|
|
|
|
|
await adminClient.auth({
|
|
|
|
username,
|
|
|
|
password: "password",
|
|
|
|
grantType: "password",
|
|
|
|
clientId,
|
|
|
|
clientSecret: "secret",
|
|
|
|
scopes: ["openid", "offline_access"],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() =>
|
|
|
|
Promise.all([
|
|
|
|
adminClient.deleteClient(clientId),
|
|
|
|
adminClient.deleteUser(username),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
|
|
|
|
it("check offline token", () => {
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
|
|
|
|
listingPage.searchItem(clientId, false);
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
|
|
|
|
// Now check that offline session exists (online one has been logged off above)
|
2024-03-08 12:51:45 +00:00
|
|
|
// and that it is possible to revoke it
|
2023-12-15 11:55:11 +00:00
|
|
|
commonPage
|
|
|
|
.tableUtils()
|
|
|
|
.checkRowItemExists(username)
|
2024-03-08 12:51:45 +00:00
|
|
|
.selectRowItemAction(username, "Revoke");
|
2023-12-15 11:55:11 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-09-12 13:30:12 +00:00
|
|
|
describe("Search", () => {
|
|
|
|
it("search existing session", () => {
|
|
|
|
listingPage.searchItem(admin, false);
|
|
|
|
listingPage.itemExist(admin, true);
|
2023-10-26 14:50:45 +00:00
|
|
|
page.assertEmptyStateExist(false);
|
2022-09-12 13:30:12 +00:00
|
|
|
});
|
2021-08-16 19:25:36 +00:00
|
|
|
|
2022-09-12 13:30:12 +00:00
|
|
|
it("search non-existant session", () => {
|
|
|
|
listingPage.searchItem("non-existant-session", false);
|
2023-10-26 14:50:45 +00:00
|
|
|
page.assertEmptyStateExist(true);
|
2022-09-12 13:30:12 +00:00
|
|
|
});
|
2022-02-22 13:30:18 +00:00
|
|
|
});
|
2021-08-16 19:25:36 +00:00
|
|
|
|
2023-12-01 08:39:39 +00:00
|
|
|
//TODO seems these tests are not stable on CI
|
|
|
|
describe.skip("revocation", () => {
|
2022-09-12 13:30:12 +00:00
|
|
|
it("Clear revocation notBefore", () => {
|
|
|
|
sessionsPage.clearNotBefore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Check if notBefore cleared", () => {
|
|
|
|
sessionsPage.checkNotBeforeCleared();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Set revocation notBefore", () => {
|
|
|
|
sessionsPage.setToNow();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Check if notBefore saved", () => {
|
|
|
|
sessionsPage.checkNotBeforeValueExists();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Push when URI not configured", () => {
|
|
|
|
sessionsPage.pushRevocation();
|
2022-09-15 10:55:57 +00:00
|
|
|
commonPage
|
|
|
|
.masthead()
|
|
|
|
.checkNotificationMessage(
|
2023-07-11 14:03:21 +00:00
|
|
|
"No push sent. No admin URI configured or no registered cluster nodes available",
|
2022-09-15 10:55:57 +00:00
|
|
|
);
|
2022-09-12 13:30:12 +00:00
|
|
|
});
|
|
|
|
});
|
2023-03-30 08:44:36 +00:00
|
|
|
|
|
|
|
describe("Accessibility tests for sessions", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
loginPage.logIn();
|
|
|
|
keycloakBefore();
|
|
|
|
sidebarPage.goToSessions();
|
|
|
|
cy.injectAxe();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Check a11y violations on load/ sessions", () => {
|
|
|
|
cy.checkA11y();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Check a11y violations on revocation dialog", () => {
|
|
|
|
cy.findByTestId("action-dropdown").click();
|
|
|
|
cy.findByTestId("revocation").click();
|
|
|
|
cy.checkA11y();
|
|
|
|
cy.findByTestId("cancel").click();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Check a11y violations on sign out all active sessions dialog", () => {
|
|
|
|
cy.findByTestId("action-dropdown").click();
|
|
|
|
cy.findByTestId("logout-all").click();
|
|
|
|
cy.checkA11y();
|
|
|
|
cy.findByTestId("cancel").click();
|
|
|
|
});
|
|
|
|
});
|
2021-07-14 10:14:03 +00:00
|
|
|
});
|