2022-03-09 16:42:51 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2022-02-24 10:31:46 +00:00
|
|
|
import adminClient from "../support/util/AdminClient";
|
2022-01-12 16:01:54 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import AuthorizationTab from "../support/pages/admin_console/manage/clients/AuthorizationTab";
|
2022-01-21 14:10:36 +00:00
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2022-01-12 16:01:54 +00:00
|
|
|
|
2022-04-08 08:56:20 +00:00
|
|
|
describe("Client authentication subtab", () => {
|
2022-01-12 16:01:54 +00:00
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const listingPage = new ListingPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const authenticationTab = new AuthorizationTab();
|
|
|
|
const clientId =
|
|
|
|
"client-authentication-" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
adminClient.createClient({
|
|
|
|
protocol: "openid-connect",
|
|
|
|
clientId,
|
|
|
|
publicClient: false,
|
|
|
|
authorizationServicesEnabled: true,
|
|
|
|
serviceAccountsEnabled: true,
|
|
|
|
standardFlowEnabled: true,
|
|
|
|
});
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
2022-01-21 14:10:36 +00:00
|
|
|
sidebarPage.goToClients();
|
|
|
|
listingPage.searchItem(clientId).goToItemDetails(clientId);
|
|
|
|
authenticationTab.goToAuthenticationTab();
|
2022-01-12 16:01:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
adminClient.deleteClient(clientId);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should update the resource server settings", () => {
|
|
|
|
authenticationTab.setPolicy("DISABLED").saveSettings();
|
2022-03-15 09:45:02 +00:00
|
|
|
masthead.checkNotificationMessage("Resource successfully updated", true);
|
2022-01-12 16:01:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Should create a resource", () => {
|
|
|
|
authenticationTab.goToResourceSubTab();
|
|
|
|
authenticationTab.assertDefaultResource();
|
|
|
|
|
|
|
|
authenticationTab
|
|
|
|
.goToCreateResource()
|
|
|
|
.fillResourceForm({
|
|
|
|
name: "Resource",
|
|
|
|
displayName: "The display name",
|
|
|
|
type: "type",
|
|
|
|
uris: ["one", "two"],
|
|
|
|
})
|
|
|
|
.save();
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
masthead.checkNotificationMessage("Resource created successfully", true);
|
2022-04-08 08:56:20 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2022-01-21 14:10:36 +00:00
|
|
|
authenticationTab.cancel();
|
2022-01-12 16:01:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Should create a scope", () => {
|
|
|
|
authenticationTab.goToScopeSubTab();
|
|
|
|
authenticationTab
|
|
|
|
.goToCreateScope()
|
|
|
|
.fillScopeForm({
|
|
|
|
name: "The scope",
|
|
|
|
displayName: "Display something",
|
|
|
|
iconUri: "res://something",
|
|
|
|
})
|
|
|
|
.save();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
2022-03-15 09:45:02 +00:00
|
|
|
"Authorization scope created successfully",
|
|
|
|
true
|
2022-01-12 16:01:54 +00:00
|
|
|
);
|
|
|
|
authenticationTab.goToScopeSubTab();
|
|
|
|
listingPage.itemExist("The scope");
|
|
|
|
});
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
it("Should create a policy", () => {
|
2022-01-21 14:10:36 +00:00
|
|
|
authenticationTab.goToPolicySubTab();
|
|
|
|
cy.intercept(
|
|
|
|
"GET",
|
2022-03-06 15:25:37 +00:00
|
|
|
"/admin/realms/master/clients/*/authz/resource-server/policy/regex/*"
|
2022-01-21 14:10:36 +00:00
|
|
|
).as("get");
|
|
|
|
authenticationTab
|
|
|
|
.goToCreatePolicy("regex")
|
|
|
|
.fillBasePolicyForm({
|
|
|
|
name: "Regex policy",
|
|
|
|
description: "Policy for regex",
|
|
|
|
targetClaim: "I don't know",
|
|
|
|
regexPattern: ".*?",
|
|
|
|
})
|
|
|
|
.save();
|
|
|
|
|
|
|
|
cy.wait(["@get"]);
|
2022-03-15 09:45:02 +00:00
|
|
|
masthead.checkNotificationMessage("Successfully created the policy", true);
|
2022-04-08 08:56:20 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2022-01-21 14:10:36 +00:00
|
|
|
authenticationTab.cancel();
|
|
|
|
});
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
it("Should delete a policy", () => {
|
2022-01-21 14:10:36 +00:00
|
|
|
authenticationTab.goToPolicySubTab();
|
|
|
|
listingPage.deleteItem("Regex policy");
|
|
|
|
new ModalUtils().confirmModal();
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
masthead.checkNotificationMessage("The Policy successfully deleted", true);
|
2022-01-21 14:10:36 +00:00
|
|
|
});
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
it("Should create a client policy", () => {
|
2022-01-21 14:10:36 +00:00
|
|
|
authenticationTab.goToPolicySubTab();
|
|
|
|
cy.intercept(
|
|
|
|
"GET",
|
2022-03-06 15:25:37 +00:00
|
|
|
"/admin/realms/master/clients/*/authz/resource-server/policy/client/*"
|
2022-01-21 14:10:36 +00:00
|
|
|
).as("get");
|
|
|
|
authenticationTab
|
|
|
|
.goToCreatePolicy("client")
|
|
|
|
.fillBasePolicyForm({
|
|
|
|
name: "Client policy",
|
|
|
|
description: "Extra client field",
|
|
|
|
})
|
|
|
|
.inputClient("master-realm")
|
|
|
|
.save();
|
|
|
|
|
|
|
|
cy.wait(["@get"]);
|
2022-03-15 09:45:02 +00:00
|
|
|
masthead.checkNotificationMessage("Successfully created the policy", true);
|
2022-04-08 08:56:20 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2022-01-21 14:10:36 +00:00
|
|
|
authenticationTab.cancel();
|
|
|
|
});
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
it("Should create a permission", () => {
|
2022-01-12 16:01:54 +00:00
|
|
|
authenticationTab.goToPermissionsSubTab();
|
|
|
|
authenticationTab
|
|
|
|
.goToCreatePermission("resource")
|
|
|
|
.fillPermissionForm({
|
|
|
|
name: "Permission name",
|
|
|
|
description: "Something describing this permission",
|
|
|
|
})
|
2022-03-15 09:45:02 +00:00
|
|
|
.selectResource("Default Resource")
|
2022-01-12 16:01:54 +00:00
|
|
|
.save();
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
cy.intercept(
|
|
|
|
"/admin/realms/master/clients/*/authz/resource-server/resource?first=0&max=10"
|
|
|
|
).as("load");
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Successfully created the permission",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
cy.wait(["@load"]);
|
2022-04-08 08:56:20 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2022-02-09 22:37:31 +00:00
|
|
|
authenticationTab.cancel();
|
|
|
|
});
|
|
|
|
|
2022-04-08 08:56:20 +00:00
|
|
|
it.skip("Should copy auth details", () => {
|
2022-02-09 22:37:31 +00:00
|
|
|
authenticationTab.goToExportSubTab();
|
2022-04-08 08:56:20 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2022-02-09 22:37:31 +00:00
|
|
|
authenticationTab.copy();
|
2022-03-15 09:45:02 +00:00
|
|
|
masthead.checkNotificationMessage("Authorization details copied.", true);
|
2022-02-09 22:37:31 +00:00
|
|
|
});
|
|
|
|
|
2022-03-15 09:45:02 +00:00
|
|
|
it("Should export auth details", () => {
|
2022-02-09 22:37:31 +00:00
|
|
|
authenticationTab.goToExportSubTab();
|
2022-04-08 08:56:20 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2022-02-09 22:37:31 +00:00
|
|
|
authenticationTab.export();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
2022-03-15 09:45:02 +00:00
|
|
|
"Successfully exported authorization details.",
|
|
|
|
true
|
2022-02-09 22:37:31 +00:00
|
|
|
);
|
2022-01-12 16:01:54 +00:00
|
|
|
});
|
|
|
|
});
|