
* Just cleaning up. * web: removing sonarjs from yet another branch. * web: everything except the tests are up-to-date. There was a lot, it turns out, we simply weren't using. * web: update package.json to support WebdriverIO 9 This commit: - Upgrades to WebdriverIO 9.1.2 - Resets our `devDependencies` collection to remove all imports that we either were not using or were duplicates of existing dependencies: - *Babel*, of all things - Storybook addon css user preferences, now native to Storybook 8 - SonarJS, *again*, sigh. - React - Fixes a bug where ESLint would report missing features in our build scripts - Fixes a bug where Wdio might not reach a headless browser before timeout - Replaces Rollup's CSSLit with Vite's CSSLit, which actually works without hacks, for testing. - Moves the package-lock scanner to its own script, with better reporting and tool verification, which also cleans up the package.lock file a little. * web: unify unit and end-to-end tests This commit builds on the Upgrade to WebdriverIO 9.1 and provides *two* variants of the wdio.conf file: One in `browser` mode, so that standalone component tests are uploaded to the browser and run independently, and one in `local` mode that allows the Webdriver-DOM framework to run end-to-end tests. This means that both Component and End-to-End tests use the same drivers, same framework, and same versions, and all tests for the WebUI are contained in this folder. * Prettier just opinionatin' all over the place. * Eslint bein' disagreeable. * Tests embedded like ticks. * Someday I'll get prettier to agree with my IDE. * Re-ran the installation with resolutions enforced. * web: fix type errors in tests Typechecking the tests is pretty messy, first because WebdriverIO passes around a lot of `ChainablePromise` objects, which TSC does not know how to resolve to their final form after a full `await`, and second because I used a lot of metaprogramming to provide getters for the different kinds of subtypes (here: providers) that we are targeting. So there are a lot of compromises here, none of which make me spectacularly happy, but they're all well-commented, so there's that. * But I am done with you, orc. * Fixed broken comment.
175 lines
7.7 KiB
TypeScript
175 lines
7.7 KiB
TypeScript
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-nocheck
|
|
// ^^^^^^^^^^^ Because TSC cannot handle metaprogramming, and metaprogramming
|
|
// via `defineProperties` is how we installed the OUID finders for the various
|
|
// wizard types.
|
|
import { expect } from "@wdio/globals";
|
|
|
|
import ApplicationWizardView from "../pageobjects/application-wizard.page.js";
|
|
import ApplicationsListPage from "../pageobjects/applications-list.page.js";
|
|
import { randomId } from "../utils/index.js";
|
|
import { login } from "../utils/login.js";
|
|
|
|
async function reachTheProvider(title: string) {
|
|
const newPrefix = randomId();
|
|
|
|
await ApplicationsListPage.logout();
|
|
await login();
|
|
await ApplicationsListPage.open();
|
|
await ApplicationsListPage.pause("ak-page-header");
|
|
await expect(await ApplicationsListPage.pageHeader()).toBeDisplayed();
|
|
await expect(await ApplicationsListPage.pageHeader()).toHaveText("Applications");
|
|
|
|
await (await ApplicationsListPage.startWizardButton()).click();
|
|
await (await ApplicationWizardView.wizardTitle()).waitForDisplayed();
|
|
await expect(await ApplicationWizardView.wizardTitle()).toHaveText("New application");
|
|
|
|
await (await ApplicationWizardView.app.name()).setValue(`${title} - ${newPrefix}`);
|
|
await (await ApplicationWizardView.app.uiSettings()).scrollIntoView();
|
|
await (await ApplicationWizardView.app.uiSettings()).click();
|
|
await (await ApplicationWizardView.app.launchUrl()).scrollIntoView();
|
|
await (await ApplicationWizardView.app.launchUrl()).setValue("http://example.goauthentik.io");
|
|
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
return await ApplicationWizardView.pause();
|
|
}
|
|
|
|
async function getCommitMessage() {
|
|
await (await ApplicationWizardView.successMessage()).waitForDisplayed();
|
|
return await ApplicationWizardView.successMessage();
|
|
}
|
|
|
|
const SUCCESS_MESSAGE = "Your application has been saved";
|
|
const EXPLICIT_CONSENT = "default-provider-authorization-explicit-consent";
|
|
|
|
describe("Configure Applications with the Application Wizard", () => {
|
|
it("Should configure a simple LDAP Application", async () => {
|
|
await reachTheProvider("New LDAP Application");
|
|
|
|
await (await ApplicationWizardView.providerList()).waitForDisplayed();
|
|
await (await ApplicationWizardView.ldapProvider).scrollIntoView();
|
|
await (await ApplicationWizardView.ldapProvider).click();
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await ApplicationWizardView.ldap.setBindFlow("default-authentication-flow");
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await expect(await getCommitMessage()).toHaveText(SUCCESS_MESSAGE);
|
|
});
|
|
|
|
it("Should configure a simple Oauth2 Application", async () => {
|
|
await reachTheProvider("New Oauth2 Application");
|
|
|
|
await (await ApplicationWizardView.providerList()).waitForDisplayed();
|
|
await (await ApplicationWizardView.oauth2Provider).scrollIntoView();
|
|
await (await ApplicationWizardView.oauth2Provider).click();
|
|
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await ApplicationWizardView.oauth.setAuthorizationFlow(EXPLICIT_CONSENT);
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await expect(await getCommitMessage()).toHaveText(SUCCESS_MESSAGE);
|
|
});
|
|
|
|
it("Should configure a simple SAML Application", async () => {
|
|
await reachTheProvider("New SAML Application");
|
|
|
|
await (await ApplicationWizardView.providerList()).waitForDisplayed();
|
|
await (await ApplicationWizardView.samlProvider).scrollIntoView();
|
|
await (await ApplicationWizardView.samlProvider).click();
|
|
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await ApplicationWizardView.saml.setAuthorizationFlow(EXPLICIT_CONSENT);
|
|
await ApplicationWizardView.saml.acsUrl.setValue("http://example.com:8000/");
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await expect(await getCommitMessage()).toHaveText(SUCCESS_MESSAGE);
|
|
});
|
|
|
|
it("Should configure a simple SCIM Application", async () => {
|
|
await reachTheProvider("New SCIM Application");
|
|
|
|
await (await ApplicationWizardView.providerList()).waitForDisplayed();
|
|
await (await ApplicationWizardView.scimProvider).scrollIntoView();
|
|
await (await ApplicationWizardView.scimProvider).click();
|
|
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await ApplicationWizardView.scim.url.setValue("http://example.com:8000/");
|
|
await ApplicationWizardView.scim.token.setValue("a-very-basic-token");
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await expect(await getCommitMessage()).toHaveText(SUCCESS_MESSAGE);
|
|
});
|
|
|
|
it("Should configure a simple Radius Application", async () => {
|
|
await reachTheProvider("New Radius Application");
|
|
|
|
await (await ApplicationWizardView.providerList()).waitForDisplayed();
|
|
await (await ApplicationWizardView.radiusProvider).scrollIntoView();
|
|
await (await ApplicationWizardView.radiusProvider).click();
|
|
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await ApplicationWizardView.radius.setAuthenticationFlow("default-authentication-flow");
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await expect(await getCommitMessage()).toHaveText(SUCCESS_MESSAGE);
|
|
});
|
|
|
|
it("Should configure a simple Transparent Proxy Application", async () => {
|
|
await reachTheProvider("New Transparent Proxy Application");
|
|
|
|
await (await ApplicationWizardView.providerList()).waitForDisplayed();
|
|
await (await ApplicationWizardView.proxyProviderProxy).scrollIntoView();
|
|
await (await ApplicationWizardView.proxyProviderProxy).click();
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await ApplicationWizardView.transparentProxy.setAuthorizationFlow(EXPLICIT_CONSENT);
|
|
await ApplicationWizardView.transparentProxy.externalHost.setValue(
|
|
"http://external.example.com",
|
|
);
|
|
await ApplicationWizardView.transparentProxy.internalHost.setValue(
|
|
"http://internal.example.com",
|
|
);
|
|
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await expect(await getCommitMessage()).toHaveText(SUCCESS_MESSAGE);
|
|
});
|
|
|
|
it("Should configure a simple Forward Proxy Application", async () => {
|
|
await reachTheProvider("New Forward Proxy Application");
|
|
|
|
await (await ApplicationWizardView.providerList()).waitForDisplayed();
|
|
await (await ApplicationWizardView.proxyProviderForwardsingle).scrollIntoView();
|
|
await (await ApplicationWizardView.proxyProviderForwardsingle).click();
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await ApplicationWizardView.forwardProxy.setAuthorizationFlow(EXPLICIT_CONSENT);
|
|
await ApplicationWizardView.forwardProxy.externalHost.setValue(
|
|
"http://external.example.com",
|
|
);
|
|
|
|
await (await ApplicationWizardView.nextButton()).click();
|
|
await ApplicationWizardView.pause();
|
|
|
|
await expect(await getCommitMessage()).toHaveText(SUCCESS_MESSAGE);
|
|
});
|
|
});
|