2021-01-27 12:56:28 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import CreateClientPage from "../support/pages/admin_console/manage/clients/CreateClientPage";
|
2021-02-24 07:59:12 +00:00
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2021-02-28 20:02:31 +00:00
|
|
|
import AdvancedTab from "../support/pages/admin_console/manage/clients/AdvancedTab";
|
|
|
|
import AdminClient from "../support/util/AdminClient";
|
2021-03-05 13:47:59 +00:00
|
|
|
import InitialAccessTokenTab from "../support/pages/admin_console/manage/clients/InitialAccessTokenTab";
|
2022-01-07 07:27:58 +00:00
|
|
|
import {
|
|
|
|
keycloakBefore,
|
|
|
|
keycloakBeforeEach,
|
|
|
|
} from "../support/util/keycloak_hooks";
|
2021-04-20 12:10:00 +00:00
|
|
|
import RoleMappingTab from "../support/pages/admin_console/manage/RoleMappingTab";
|
2021-05-04 08:11:58 +00:00
|
|
|
import KeysTab from "../support/pages/admin_console/manage/clients/KeysTab";
|
2021-12-10 12:24:26 +00:00
|
|
|
import ClientScopesTab from "../support/pages/admin_console/manage/clients/ClientScopesTab";
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-01-27 12:47:57 +00:00
|
|
|
let itemId = "client_crud";
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const listingPage = new ListingPage();
|
|
|
|
const createClientPage = new CreateClientPage();
|
2021-02-24 07:59:12 +00:00
|
|
|
const modalUtils = new ModalUtils();
|
2021-01-27 12:47:57 +00:00
|
|
|
|
2021-10-04 06:03:19 +00:00
|
|
|
describe("Clients test", () => {
|
2021-12-10 12:24:26 +00:00
|
|
|
describe("Client details - Client scopes subtab", () => {
|
|
|
|
const clientScopesTab = new ClientScopesTab();
|
|
|
|
const client = new AdminClient();
|
|
|
|
const clientId = "client-scopes-subtab-test";
|
|
|
|
const clientScopeName = "client-scope-test";
|
|
|
|
const clientScope = {
|
|
|
|
name: clientScopeName,
|
|
|
|
description: "",
|
|
|
|
protocol: "openid-connect",
|
|
|
|
attributes: {
|
|
|
|
"include.in.token.scope": "true",
|
|
|
|
"display.on.consent.screen": "true",
|
|
|
|
"gui.order": "1",
|
|
|
|
"consent.screen.text": "",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
client.createClient({
|
|
|
|
clientId,
|
|
|
|
protocol: "openid-connect",
|
|
|
|
publicClient: false,
|
|
|
|
});
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
|
clientScope.name = clientScopeName + i;
|
|
|
|
await client.createClientScope(clientScope);
|
|
|
|
await client.addDefaultClientScopeInClient(
|
|
|
|
clientScopeName + i,
|
|
|
|
clientId
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToClients();
|
|
|
|
cy.intercept("/auth/admin/realms/master/clients/*").as("fetchClient");
|
|
|
|
listingPage.searchItem(clientId).goToItemDetails(clientId);
|
|
|
|
cy.wait("@fetchClient");
|
2022-01-08 09:27:57 +00:00
|
|
|
clientScopesTab.goToClientScopesTab();
|
2021-12-10 12:24:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
after(async () => {
|
|
|
|
client.deleteClient(clientId);
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
|
await client.deleteClientScope(clientScopeName + i);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should show items on next page are more than 11", () => {
|
|
|
|
listingPage.showNextPageTableItems();
|
|
|
|
cy.get(listingPage.tableRowItem).its("length").should("be.gt", 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-10-04 06:03:19 +00:00
|
|
|
describe("Client creation", () => {
|
2022-01-07 07:27:58 +00:00
|
|
|
before(() => {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
2021-01-21 12:09:50 +00:00
|
|
|
loginPage.logIn();
|
2022-01-07 07:27:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBeforeEach();
|
2021-01-21 12:09:50 +00:00
|
|
|
sidebarPage.goToClients();
|
2021-01-25 17:17:59 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-10-04 06:03:19 +00:00
|
|
|
it("should fail creating client", () => {
|
2021-01-21 12:09:50 +00:00
|
|
|
listingPage.goToCreateItem();
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
createClientPage.continue().checkClientIdRequiredMessage();
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
createClientPage
|
|
|
|
.fillClientData("")
|
|
|
|
.selectClientType("openid-connect")
|
|
|
|
.continue()
|
|
|
|
.checkClientIdRequiredMessage();
|
|
|
|
|
|
|
|
createClientPage.fillClientData("account").continue().continue();
|
|
|
|
|
|
|
|
// The error should inform about duplicated name/id
|
|
|
|
masthead.checkNotificationMessage(
|
2021-07-28 12:01:42 +00:00
|
|
|
"Could not create client: 'Client account already exists'"
|
2021-01-21 12:09:50 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-10-04 06:03:19 +00:00
|
|
|
it("Client CRUD test", () => {
|
2021-01-25 17:17:59 +00:00
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
2021-01-27 12:56:28 +00:00
|
|
|
|
2021-01-25 17:17:59 +00:00
|
|
|
// Create
|
2021-01-21 12:09:50 +00:00
|
|
|
listingPage.itemExist(itemId, false).goToCreateItem();
|
|
|
|
|
|
|
|
createClientPage
|
|
|
|
.selectClientType("openid-connect")
|
|
|
|
.fillClientData(itemId)
|
|
|
|
.continue()
|
|
|
|
.continue();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Client created successfully");
|
|
|
|
|
|
|
|
sidebarPage.goToClients();
|
|
|
|
|
2021-01-27 12:56:28 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-01-25 17:17:59 +00:00
|
|
|
// Delete
|
2021-02-24 07:59:12 +00:00
|
|
|
listingPage.deleteItem(itemId);
|
|
|
|
modalUtils.checkModalTitle(`Delete ${itemId} ?`).confirmModal();
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The client has been deleted");
|
|
|
|
|
|
|
|
listingPage.itemExist(itemId, false);
|
|
|
|
});
|
2021-03-05 13:47:59 +00:00
|
|
|
|
|
|
|
it("Initial access token", () => {
|
|
|
|
const initialAccessTokenTab = new InitialAccessTokenTab();
|
2021-03-24 14:07:49 +00:00
|
|
|
initialAccessTokenTab.goToInitialAccessTokenTab().shouldBeEmpty();
|
2021-03-05 13:47:59 +00:00
|
|
|
initialAccessTokenTab.createNewToken(1, 1).save();
|
|
|
|
|
|
|
|
modalUtils.checkModalTitle("Initial access token details").closeModal();
|
|
|
|
|
|
|
|
initialAccessTokenTab.shouldNotBeEmpty();
|
|
|
|
|
|
|
|
initialAccessTokenTab.getFistId((id) => {
|
|
|
|
listingPage.deleteItem(id);
|
|
|
|
modalUtils
|
|
|
|
.checkModalTitle("Delete initial access token?")
|
|
|
|
.confirmModal();
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"initial access token created successfully"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
});
|
2021-02-28 20:02:31 +00:00
|
|
|
|
|
|
|
describe("Advanced tab test", () => {
|
|
|
|
const advancedTab = new AdvancedTab();
|
|
|
|
let client: string;
|
|
|
|
|
2022-01-07 07:27:58 +00:00
|
|
|
before(() => {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
2021-02-28 20:02:31 +00:00
|
|
|
loginPage.logIn();
|
2022-01-07 07:27:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBeforeEach();
|
2021-02-28 20:02:31 +00:00
|
|
|
sidebarPage.goToClients();
|
|
|
|
|
|
|
|
client = "client_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
listingPage.goToCreateItem();
|
|
|
|
|
|
|
|
createClientPage
|
|
|
|
.selectClientType("openid-connect")
|
|
|
|
.fillClientData(client)
|
|
|
|
.continue()
|
|
|
|
.continue();
|
|
|
|
|
2022-01-08 09:27:57 +00:00
|
|
|
advancedTab.goToAdvancedTab();
|
2021-02-28 20:02:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
new AdminClient().deleteClient(client);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Clustering", () => {
|
2021-06-16 11:35:03 +00:00
|
|
|
advancedTab.expandClusterNode();
|
2021-02-28 20:02:31 +00:00
|
|
|
|
2022-01-08 09:27:57 +00:00
|
|
|
advancedTab.registerNodeManually().fillHost("localhost").saveHost();
|
2021-02-28 20:02:31 +00:00
|
|
|
advancedTab.checkTestClusterAvailability(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Fine grain OpenID connect configuration", () => {
|
|
|
|
const algorithm = "ES384";
|
|
|
|
advancedTab
|
|
|
|
.selectAccessTokenSignatureAlgorithm(algorithm)
|
2022-01-08 09:27:57 +00:00
|
|
|
.saveFineGrain();
|
2021-02-28 20:02:31 +00:00
|
|
|
|
|
|
|
advancedTab
|
|
|
|
.selectAccessTokenSignatureAlgorithm("HS384")
|
2022-01-08 09:27:57 +00:00
|
|
|
.revertFineGrain();
|
2021-02-28 20:02:31 +00:00
|
|
|
advancedTab.checkAccessTokenSignatureAlgorithm(algorithm);
|
|
|
|
});
|
|
|
|
});
|
2021-04-01 14:14:19 +00:00
|
|
|
|
|
|
|
describe("Service account tab test", () => {
|
2021-04-20 12:10:00 +00:00
|
|
|
const serviceAccountTab = new RoleMappingTab();
|
2021-04-01 14:14:19 +00:00
|
|
|
const serviceAccountName = "service-account-client";
|
|
|
|
|
2022-01-07 07:27:58 +00:00
|
|
|
before(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
new AdminClient().createClient({
|
2021-04-01 14:14:19 +00:00
|
|
|
protocol: "openid-connect",
|
|
|
|
clientId: serviceAccountName,
|
|
|
|
publicClient: false,
|
|
|
|
authorizationServicesEnabled: true,
|
|
|
|
serviceAccountsEnabled: true,
|
|
|
|
standardFlowEnabled: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-08 09:27:57 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBeforeEach();
|
|
|
|
sidebarPage.goToClients();
|
|
|
|
});
|
|
|
|
|
2021-04-01 14:14:19 +00:00
|
|
|
after(() => {
|
|
|
|
new AdminClient().deleteClient(serviceAccountName);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("list", () => {
|
|
|
|
listingPage
|
|
|
|
.searchItem(serviceAccountName)
|
|
|
|
.goToItemDetails(serviceAccountName);
|
|
|
|
serviceAccountTab
|
2021-04-20 12:10:00 +00:00
|
|
|
.goToServiceAccountTab()
|
2021-04-01 14:14:19 +00:00
|
|
|
.checkRoles(["manage-account", "offline_access", "uma_authorization"]);
|
|
|
|
});
|
2021-08-10 12:41:56 +00:00
|
|
|
|
|
|
|
it("assign", () => {
|
|
|
|
listingPage.goToItemDetails(serviceAccountName);
|
|
|
|
serviceAccountTab
|
|
|
|
.goToServiceAccountTab()
|
2022-01-08 09:27:57 +00:00
|
|
|
.assignRole(false)
|
2021-08-10 12:41:56 +00:00
|
|
|
.selectRow("create-realm")
|
2022-01-08 09:27:57 +00:00
|
|
|
.assign();
|
2021-08-10 12:41:56 +00:00
|
|
|
masthead.checkNotificationMessage("Role mapping updated");
|
2022-01-08 09:27:57 +00:00
|
|
|
serviceAccountTab.selectRow("create-realm").unAssign();
|
|
|
|
modalUtils.checkModalTitle("Remove mapping?").confirmModal();
|
|
|
|
masthead.checkNotificationMessage("Scope mapping successfully removed");
|
2021-08-10 12:41:56 +00:00
|
|
|
});
|
2021-04-01 14:14:19 +00:00
|
|
|
});
|
2021-05-04 08:11:58 +00:00
|
|
|
|
2021-10-20 14:26:05 +00:00
|
|
|
describe("Mapping tab", () => {
|
|
|
|
const mappingClient = "mapping-client";
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToClients();
|
|
|
|
listingPage.searchItem(mappingClient).goToItemDetails(mappingClient);
|
|
|
|
});
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
new AdminClient().createClient({
|
|
|
|
protocol: "openid-connect",
|
|
|
|
clientId: mappingClient,
|
|
|
|
publicClient: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
new AdminClient().deleteClient(mappingClient);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("add mapping to openid client", () => {
|
|
|
|
cy.get("#pf-tab-mappers-mappers").click();
|
|
|
|
cy.findByText("Add predefined mapper").click();
|
|
|
|
cy.get("table input").first().click();
|
|
|
|
cy.findByTestId("modalConfirm").click();
|
|
|
|
masthead.checkNotificationMessage("Mapping successfully created");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-05-04 08:11:58 +00:00
|
|
|
describe("Keys tab test", () => {
|
|
|
|
const keysName = "keys-client";
|
|
|
|
beforeEach(() => {
|
2022-01-07 07:27:58 +00:00
|
|
|
keycloakBeforeEach();
|
2021-05-04 08:11:58 +00:00
|
|
|
sidebarPage.goToClients();
|
|
|
|
listingPage.searchItem(keysName).goToItemDetails(keysName);
|
|
|
|
});
|
|
|
|
|
|
|
|
before(() => {
|
2022-01-07 07:27:58 +00:00
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
2021-05-04 08:11:58 +00:00
|
|
|
new AdminClient().createClient({
|
|
|
|
protocol: "openid-connect",
|
|
|
|
clientId: keysName,
|
|
|
|
publicClient: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
new AdminClient().deleteClient(keysName);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("change use JWKS Url", () => {
|
|
|
|
const keysTab = new KeysTab();
|
|
|
|
keysTab.goToTab().checkSaveDisabled();
|
|
|
|
keysTab.toggleUseJwksUrl().checkSaveDisabled(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("generate new keys", () => {
|
|
|
|
const keysTab = new KeysTab();
|
|
|
|
keysTab.goToTab().clickGenerate();
|
|
|
|
|
|
|
|
keysTab.fillGenerateModal("keyname", "123", "1234").clickConfirm();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"New key pair and certificate generated successfully"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-09-28 15:14:49 +00:00
|
|
|
|
|
|
|
describe("Realm client", () => {
|
|
|
|
const clientName = "master-realm";
|
|
|
|
|
2022-01-07 07:27:58 +00:00
|
|
|
before(() => {
|
2021-09-28 15:14:49 +00:00
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToClients();
|
|
|
|
listingPage.searchItem(clientName).goToItemDetails(clientName);
|
|
|
|
});
|
|
|
|
|
2022-01-07 07:27:58 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBeforeEach();
|
|
|
|
});
|
|
|
|
|
2021-09-28 15:14:49 +00:00
|
|
|
it("displays the correct tabs", () => {
|
|
|
|
cy.findByTestId("client-tabs")
|
|
|
|
.find("#pf-tab-settings-settings")
|
|
|
|
.should("exist");
|
|
|
|
|
|
|
|
cy.findByTestId("client-tabs")
|
|
|
|
.find("#pf-tab-roles-roles")
|
|
|
|
.should("exist");
|
|
|
|
|
|
|
|
cy.findByTestId("client-tabs")
|
|
|
|
.find("#pf-tab-advanced-advanced")
|
|
|
|
.should("exist");
|
|
|
|
|
|
|
|
cy.findByTestId("client-tabs").find("li").should("have.length", 3);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("hides the delete action", () => {
|
|
|
|
cy.findByTestId("action-dropdown").click();
|
|
|
|
cy.findByTestId("delete-client").should("not.exist");
|
|
|
|
});
|
|
|
|
});
|
2021-09-30 10:04:50 +00:00
|
|
|
|
|
|
|
describe("Bearer only", () => {
|
|
|
|
const clientId = "bearer-only";
|
|
|
|
|
|
|
|
before(() => {
|
2022-01-07 07:27:58 +00:00
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
2021-09-30 10:04:50 +00:00
|
|
|
new AdminClient().createClient({
|
|
|
|
clientId,
|
|
|
|
protocol: "openid-connect",
|
|
|
|
publicClient: false,
|
|
|
|
bearerOnly: true,
|
|
|
|
});
|
2022-01-07 07:27:58 +00:00
|
|
|
sidebarPage.goToClients();
|
|
|
|
cy.intercept("/auth/admin/realms/master/clients/*").as("fetchClient");
|
|
|
|
listingPage.searchItem(clientId).goToItemDetails(clientId);
|
|
|
|
cy.wait("@fetchClient");
|
2021-09-30 10:04:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
new AdminClient().deleteClient(clientId);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-01-07 07:27:58 +00:00
|
|
|
keycloakBeforeEach();
|
2021-09-30 10:04:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("shows an explainer text for bearer only clients", () => {
|
|
|
|
cy.findByTestId("bearer-only-explainer-label").trigger("mouseenter");
|
|
|
|
cy.findByTestId("bearer-only-explainer-tooltip").should("exist");
|
|
|
|
});
|
2021-10-06 11:05:27 +00:00
|
|
|
|
|
|
|
it("hides the capability config section", () => {
|
|
|
|
cy.findByTestId("capability-config-form").should("not.exist");
|
|
|
|
cy.findByTestId("jump-link-capability-config").should("not.exist");
|
|
|
|
});
|
2021-09-30 10:04:50 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
});
|