now only logs in per test suite for client tests (#1828)

This commit is contained in:
Erik Jan de Wit 2022-01-07 08:27:58 +01:00 committed by GitHub
parent f1c7e5ecb3
commit ced1008ad5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 62 additions and 42 deletions

View file

@ -1,4 +1,4 @@
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import LoginPage from "../support/pages/LoginPage";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import Masthead from "../support/pages/admin_console/Masthead";

View file

@ -3,7 +3,7 @@ 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 CreateClientScopePage from "../support/pages/admin_console/manage/client_scopes/CreateClientScopePage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import RoleMappingTab from "../support/pages/admin_console/manage/RoleMappingTab";
import ModalUtils from "../support/util/ModalUtils";
import AdminClient from "../support/util/AdminClient";

View file

@ -4,7 +4,7 @@ import ListingPage from "../support/pages/admin_console/ListingPage";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import ModalUtils from "../support/util/ModalUtils";
import AdminClient from "../support/util/AdminClient";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import AuthenticationTab from "../support/pages/admin_console/manage/clients/Authentication";
const loginPage = new LoginPage();

View file

@ -7,7 +7,10 @@ import ModalUtils from "../support/util/ModalUtils";
import AdvancedTab from "../support/pages/admin_console/manage/clients/AdvancedTab";
import AdminClient from "../support/util/AdminClient";
import InitialAccessTokenTab from "../support/pages/admin_console/manage/clients/InitialAccessTokenTab";
import { keycloakBefore } from "../support/util/keycloak_before";
import {
keycloakBefore,
keycloakBeforeEach,
} from "../support/util/keycloak_hooks";
import RoleMappingTab from "../support/pages/admin_console/manage/RoleMappingTab";
import KeysTab from "../support/pages/admin_console/manage/clients/KeysTab";
import ClientScopesTab from "../support/pages/admin_console/manage/clients/ClientScopesTab";
@ -78,9 +81,13 @@ describe("Clients test", () => {
});
describe("Client creation", () => {
beforeEach(() => {
before(() => {
keycloakBefore();
loginPage.logIn();
});
beforeEach(() => {
keycloakBeforeEach();
sidebarPage.goToClients();
});
@ -155,9 +162,13 @@ describe("Clients test", () => {
const advancedTab = new AdvancedTab();
let client: string;
beforeEach(() => {
before(() => {
keycloakBefore();
loginPage.logIn();
});
beforeEach(() => {
keycloakBeforeEach();
sidebarPage.goToClients();
client = "client_" + (Math.random() + 1).toString(36).substring(7);
@ -205,13 +216,14 @@ describe("Clients test", () => {
const serviceAccountName = "service-account-client";
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
keycloakBeforeEach();
sidebarPage.goToClients();
});
before(async () => {
await new AdminClient().createClient({
before(() => {
keycloakBefore();
loginPage.logIn();
new AdminClient().createClient({
protocol: "openid-connect",
clientId: serviceAccountName,
publicClient: false,
@ -234,7 +246,6 @@ describe("Clients test", () => {
.checkRoles(["manage-account", "offline_access", "uma_authorization"]);
});
/* this test causes the test(s) that follow it to fail - it should be rewritten
it("assign", () => {
listingPage.goToItemDetails(serviceAccountName);
serviceAccountTab
@ -244,7 +255,6 @@ describe("Clients test", () => {
.clickAssign();
masthead.checkNotificationMessage("Role mapping updated");
});
*/
});
describe("Mapping tab", () => {
@ -280,13 +290,14 @@ describe("Clients test", () => {
describe("Keys tab test", () => {
const keysName = "keys-client";
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
keycloakBeforeEach();
sidebarPage.goToClients();
listingPage.searchItem(keysName).goToItemDetails(keysName);
});
before(() => {
keycloakBefore();
loginPage.logIn();
new AdminClient().createClient({
protocol: "openid-connect",
clientId: keysName,
@ -319,13 +330,17 @@ describe("Clients test", () => {
describe("Realm client", () => {
const clientName = "master-realm";
beforeEach(() => {
before(() => {
keycloakBefore();
loginPage.logIn();
sidebarPage.goToClients();
listingPage.searchItem(clientName).goToItemDetails(clientName);
});
beforeEach(() => {
keycloakBeforeEach();
});
it("displays the correct tabs", () => {
cy.findByTestId("client-tabs")
.find("#pf-tab-settings-settings")
@ -352,12 +367,18 @@ describe("Clients test", () => {
const clientId = "bearer-only";
before(() => {
keycloakBefore();
loginPage.logIn();
new AdminClient().createClient({
clientId,
protocol: "openid-connect",
publicClient: false,
bearerOnly: true,
});
sidebarPage.goToClients();
cy.intercept("/auth/admin/realms/master/clients/*").as("fetchClient");
listingPage.searchItem(clientId).goToItemDetails(clientId);
cy.wait("@fetchClient");
});
after(() => {
@ -365,12 +386,7 @@ describe("Clients test", () => {
});
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
sidebarPage.goToClients();
cy.intercept("/auth/admin/realms/master/clients/*").as("fetchClient");
listingPage.searchItem(clientId).goToItemDetails(clientId);
cy.wait("@fetchClient");
keycloakBeforeEach();
});
it("shows an explainer text for bearer only clients", () => {

View file

@ -4,7 +4,7 @@ import UserEventsTab from "../support/pages/admin_console/manage/events/UserEven
import AdminEventsTab from "../support/pages/admin_console/manage/events/AdminEventsTab";
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
import Masthead from "../support/pages/admin_console/Masthead";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();

View file

@ -9,7 +9,7 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import ViewHeaderPage from "../support/pages/ViewHeaderPage";
import AdminClient from "../support/util/AdminClient";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import ModalUtils from "../support/util/ModalUtils";
describe("Group test", () => {

View file

@ -1,7 +1,7 @@
import Masthead from "../support/pages/admin_console/Masthead";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import ListingPage from "../support/pages/admin_console/ListingPage";
import CreateProviderPage from "../support/pages/admin_console/manage/identity_providers/CreateProviderPage";
import ModalUtils from "../support/util/ModalUtils";

View file

@ -1,7 +1,7 @@
import Masthead from "../support/pages/admin_console/Masthead";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import ListingPage from "../support/pages/admin_console/ListingPage";
import CreateProviderPage from "../support/pages/admin_console/manage/identity_providers/CreateProviderPage";
import ModalUtils from "../support/util/ModalUtils";

View file

@ -1,7 +1,7 @@
import Masthead from "../support/pages/admin_console/Masthead";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import ListingPage from "../support/pages/admin_console/ListingPage";
import CreateProviderPage from "../support/pages/admin_console/manage/identity_providers/CreateProviderPage";

View file

@ -1,6 +1,6 @@
import LoginPage from "../support/pages/LoginPage";
import Masthead from "../support/pages/admin_console/Masthead";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const username = "admin";
const password = "admin";

View file

@ -2,7 +2,7 @@ import ListingPage from "../support/pages/admin_console/ListingPage";
import LoginPage from "../support/pages/LoginPage";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import Masthead from "../support/pages/admin_console/Masthead";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const loginPage = new LoginPage();
const masthead = new Masthead();

View file

@ -3,7 +3,7 @@ import RealmSettings from "../support/pages/admin_console/configure/realm_settin
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import AdminClient from "../support/util/AdminClient";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
describe("Partial realm export", () => {
const REALM_NAME = "partial-export-test-realm";

View file

@ -3,7 +3,7 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import PartialImportModal from "../support/pages/admin_console/configure/realm_settings/PartialImportModal";
import RealmSettings from "../support/pages/admin_console/configure/realm_settings/RealmSettings";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import AdminClient from "../support/util/AdminClient";
describe("Partial import test", () => {

View file

@ -5,7 +5,7 @@ import ListingPage from "../support/pages/admin_console/ListingPage";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import CreateRealmRolePage from "../support/pages/admin_console/manage/realm_roles/CreateRealmRolePage";
import AssociatedRolesPage from "../support/pages/admin_console/manage/realm_roles/AssociatedRolesPage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
let itemId = "realm_role_crud";
const loginPage = new LoginPage();

View file

@ -1,7 +1,7 @@
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import AdminClient from "../support/util/AdminClient";
const loginPage = new LoginPage();

View file

@ -1,7 +1,7 @@
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import AdminClient from "../support/util/AdminClient";
const loginPage = new LoginPage();

View file

@ -3,7 +3,7 @@ import LoginPage from "../support/pages/LoginPage";
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
import Masthead from "../support/pages/admin_console/Masthead";
import ModalUtils from "../support/util/ModalUtils";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import ListingPage from "../support/pages/admin_console/ListingPage";
import AdminClient from "../support/util/AdminClient";

View file

@ -2,7 +2,7 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
import Masthead from "../support/pages/admin_console/Masthead";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import AdminClient from "../support/util/AdminClient";
const loginPage = new LoginPage();

View file

@ -3,7 +3,7 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import CreateRealmPage from "../support/pages/admin_console/CreateRealmPage";
import Masthead from "../support/pages/admin_console/Masthead";
import AdminClient from "../support/util/AdminClient";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const masthead = new Masthead();
const loginPage = new LoginPage();

View file

@ -1,7 +1,7 @@
import LoginPage from "../support/pages/LoginPage";
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import SessionsPage from "../support/pages/admin_console/manage/sessions/SessionsPage";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();

View file

@ -3,7 +3,7 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
import Masthead from "../support/pages/admin_console/Masthead";
import ModalUtils from "../support/util/ModalUtils";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const loginPage = new LoginPage();
const masthead = new Masthead();

View file

@ -6,7 +6,7 @@ import ProviderPage from "../support/pages/admin_console/manage/providers/Provid
import CreateClientPage from "../support/pages/admin_console/manage/clients/CreateClientPage";
import Masthead from "../support/pages/admin_console/Masthead";
import ModalUtils from "../support/util/ModalUtils";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const loginPage = new LoginPage();
const masthead = new Masthead();

View file

@ -4,7 +4,7 @@ import ListingPage from "../support/pages/admin_console/ListingPage";
import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
import Masthead from "../support/pages/admin_console/Masthead";
import ModalUtils from "../support/util/ModalUtils";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const loginPage = new LoginPage();
const masthead = new Masthead();

View file

@ -3,7 +3,7 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
import Masthead from "../support/pages/admin_console/Masthead";
import ModalUtils from "../support/util/ModalUtils";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
const loginPage = new LoginPage();
const masthead = new Masthead();

View file

@ -6,7 +6,7 @@ import ListingPage from "../support/pages/admin_console/ListingPage";
import UserDetailsPage from "../support/pages/admin_console/manage/users/UserDetailsPage";
import AttributesTab from "../support/pages/admin_console/manage/AttributesTab";
import ModalUtils from "../support/util/ModalUtils";
import { keycloakBefore } from "../support/util/keycloak_before";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import GroupModal from "../support/pages/admin_console/manage/groups/GroupModal";
import UserGroupsPage from "../support/pages/admin_console/manage/users/UserGroupsPage";
import AdminClient from "../support/util/AdminClient";

View file

@ -13,3 +13,7 @@ export const keycloakBefore = () => {
});
cy.visit("");
};
export const keycloakBeforeEach = () => {
Cypress.Cookies.preserveOnce("KEYCLOAK_SESSION", "KEYCLOAK_IDENTITY");
};