CLOUDRON_OIDC_PROVIDER_NAME implemented, tests updated and fixed
This commit is contained in:
2
start.sh
2
start.sh
@@ -70,7 +70,7 @@ if [[ -n "${CLOUDRON_OIDC_ISSUER:-}" ]]; then
|
|||||||
yq eval -i "del(.password_providers)" /app/data/configs/homeserver.yaml # remove old ldap config
|
yq eval -i "del(.password_providers)" /app/data/configs/homeserver.yaml # remove old ldap config
|
||||||
echo " ==> Configuring OIDC auth"
|
echo " ==> Configuring OIDC auth"
|
||||||
yq eval -i ".oidc_providers[0].idp_id=\"cloudron\"" /app/data/configs/homeserver.yaml
|
yq eval -i ".oidc_providers[0].idp_id=\"cloudron\"" /app/data/configs/homeserver.yaml
|
||||||
yq eval -i ".oidc_providers[0].idp_name=\"Cloudron\"" /app/data/configs/homeserver.yaml
|
yq eval -i ".oidc_providers[0].idp_name=\"${CLOUDRON_OIDC_PROVIDER_NAME:-Cloudron}\"" /app/data/configs/homeserver.yaml
|
||||||
yq eval -i ".oidc_providers[0].issuer=\"${CLOUDRON_OIDC_ISSUER}\"" /app/data/configs/homeserver.yaml
|
yq eval -i ".oidc_providers[0].issuer=\"${CLOUDRON_OIDC_ISSUER}\"" /app/data/configs/homeserver.yaml
|
||||||
yq eval -i ".oidc_providers[0].client_id=\"${CLOUDRON_OIDC_CLIENT_ID}\"" /app/data/configs/homeserver.yaml
|
yq eval -i ".oidc_providers[0].client_id=\"${CLOUDRON_OIDC_CLIENT_ID}\"" /app/data/configs/homeserver.yaml
|
||||||
yq eval -i ".oidc_providers[0].client_secret=\"${CLOUDRON_OIDC_CLIENT_SECRET}\"" /app/data/configs/homeserver.yaml
|
yq eval -i ".oidc_providers[0].client_secret=\"${CLOUDRON_OIDC_CLIENT_SECRET}\"" /app/data/configs/homeserver.yaml
|
||||||
|
|||||||
2047
test/package-lock.json
generated
2047
test/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
96
test/test.js
96
test/test.js
@@ -91,6 +91,7 @@ describe('Application life cycle test', function () {
|
|||||||
|
|
||||||
async function updateSynapseConfig() {
|
async function updateSynapseConfig() {
|
||||||
console.log(`Setting Synapse Matrix server location to "https://${app.fqdn}"`);
|
console.log(`Setting Synapse Matrix server location to "https://${app.fqdn}"`);
|
||||||
|
|
||||||
execSync(`cloudron exec --app ${ELEMENT_LOCATION} -- bash -c "jq '.default_server_config[\\"m.homeserver\\"].base_url = \\"https://${app.fqdn}\\"' /app/data/config.json | sponge /app/data/config.json"`);
|
execSync(`cloudron exec --app ${ELEMENT_LOCATION} -- bash -c "jq '.default_server_config[\\"m.homeserver\\"].base_url = \\"https://${app.fqdn}\\"' /app/data/config.json | sponge /app/data/config.json"`);
|
||||||
execSync(`cloudron restart --app ${ELEMENT_LOCATION}`);
|
execSync(`cloudron restart --app ${ELEMENT_LOCATION}`);
|
||||||
// wait when all services are up and running
|
// wait when all services are up and running
|
||||||
@@ -106,43 +107,48 @@ describe('Application life cycle test', function () {
|
|||||||
await browser.get(`https://${elementApp.fqdn}/#/register`);
|
await browser.get(`https://${elementApp.fqdn}/#/register`);
|
||||||
await waitForElement(By.xpath('//input[@label="Username"]'));
|
await waitForElement(By.xpath('//input[@label="Username"]'));
|
||||||
await browser.findElement(By.xpath('//input[@label="Username"]')).sendKeys(USERNAME);
|
await browser.findElement(By.xpath('//input[@label="Username"]')).sendKeys(USERNAME);
|
||||||
await browser.sleep(2000);
|
|
||||||
await browser.findElement(By.xpath('//input[@label="Password"]')).sendKeys(PASSWORD);
|
await browser.findElement(By.xpath('//input[@label="Password"]')).sendKeys(PASSWORD);
|
||||||
await browser.sleep(2000);
|
|
||||||
await browser.findElement(By.xpath('//input[@label="Confirm password"]')).sendKeys(PASSWORD);
|
await browser.findElement(By.xpath('//input[@label="Confirm password"]')).sendKeys(PASSWORD);
|
||||||
await browser.sleep(2000);
|
|
||||||
await browser.findElement(By.xpath('//input[@value="Register"]')).click();
|
await browser.findElement(By.xpath('//input[@value="Register"]')).click();
|
||||||
await browser.sleep(2000);
|
|
||||||
await waitForElement(By.xpath('//h1[text()="You\'re in"]'));
|
await waitForElement(By.xpath('//h1[text()="You\'re in"]'));
|
||||||
await browser.sleep(2000);
|
|
||||||
await browser.findElement(By.xpath('//div[@role="button" and text()="Skip"]')).click();
|
await browser.findElement(By.xpath('//div[@role="button" and text()="Skip"]')).click();
|
||||||
await browser.sleep(2000);
|
|
||||||
await waitForElement(By.xpath(`//h1[contains(., "Welcome")]`));
|
await waitForElement(By.xpath(`//h1[contains(., "Welcome")]`));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loginOIDC(username, password, hasSession, proceedWithReset) {
|
async function loginOIDC(username, password, alreadyAuthenticated, proceedWithReset) {
|
||||||
browser.manage().deleteAllCookies();
|
browser.manage().deleteAllCookies();
|
||||||
await browser.get(`https://${elementApp.fqdn}/#/login`);
|
await browser.get(`https://${elementApp.fqdn}/#/login`);
|
||||||
await browser.sleep(6000);
|
|
||||||
|
|
||||||
await waitForElement(By.xpath('//div[@role="button" and contains(., "Continue with Cloudron")]'));
|
|
||||||
await browser.findElement(By.xpath('//div[@role="button" and contains(., "Continue with Cloudron")]')).click();
|
|
||||||
await browser.sleep(2000);
|
await browser.sleep(2000);
|
||||||
|
|
||||||
if (!hasSession) {
|
await waitForElement(By.css('.mx_Dropdown_arrow'));
|
||||||
|
await browser.findElement(By.css('.mx_Dropdown_arrow')).click();
|
||||||
|
await waitForElement(By.id('mx_LanguageDropdown__en'));
|
||||||
|
await browser.findElement(By.id('mx_LanguageDropdown__en')).click();
|
||||||
|
await browser.sleep(3000);
|
||||||
|
|
||||||
|
await waitForElement(By.xpath('//div[@role="button" and contains(., "Continue with")]'));
|
||||||
|
await browser.findElement(By.xpath('//div[@role="button" and contains(., "Continue with")]')).click();
|
||||||
|
if (!alreadyAuthenticated) {
|
||||||
await waitForElement(By.xpath('//input[@name="username"]'));
|
await waitForElement(By.xpath('//input[@name="username"]'));
|
||||||
await browser.findElement(By.xpath('//input[@name="username"]')).sendKeys(username);
|
await browser.findElement(By.xpath('//input[@name="username"]')).sendKeys(username);
|
||||||
await browser.findElement(By.xpath('//input[@name="password"]')).sendKeys(password);
|
await browser.findElement(By.xpath('//input[@name="password"]')).sendKeys(password);
|
||||||
await browser.sleep(2000);
|
|
||||||
await browser.findElement(By.id('loginSubmitButton')).click();
|
await browser.findElement(By.id('loginSubmitButton')).click();
|
||||||
await browser.sleep(2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await waitForElement(By.xpath('//p[@class="confirm-trust" and contains(., "Continuing will grant ")]'));
|
await waitForElement(By.xpath('//p[@class="confirm-trust" and contains(., "Continuing will grant ")]'));
|
||||||
await browser.findElement(By.xpath('//a[contains(., "Continue")]')).click();
|
await browser.findElement(By.xpath('//a[contains(., "Continue")]')).click();
|
||||||
await browser.sleep(2000);
|
|
||||||
|
|
||||||
if (proceedWithReset) {
|
if (proceedWithReset) {
|
||||||
|
await waitForElement(By.xpath('//div[text()="Proceed with reset" or text()="Reset all"]'));
|
||||||
|
|
||||||
|
if (await browser.findElements(By.xpath('//div[text()="Reset all"]')).then(found => !!found.length)) {
|
||||||
|
|
||||||
|
await browser.findElement(By.xpath('//div[text()="Reset all"]')).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
await waitForElement(By.xpath('//div[text()="Proceed with reset"]'));
|
||||||
await browser.findElement(By.xpath('//div[text()="Proceed with reset"]')).click();
|
await browser.findElement(By.xpath('//div[text()="Proceed with reset"]')).click();
|
||||||
|
|
||||||
await waitForElement(By.xpath('//button[text()="Continue"]'));
|
await waitForElement(By.xpath('//button[text()="Continue"]'));
|
||||||
@@ -151,16 +157,41 @@ describe('Application life cycle test', function () {
|
|||||||
await waitForElement(By.xpath('//div[text()="Copy"]'));
|
await waitForElement(By.xpath('//div[text()="Copy"]'));
|
||||||
await browser.findElement(By.xpath('//div[text()="Copy"]')).click();
|
await browser.findElement(By.xpath('//div[text()="Copy"]')).click();
|
||||||
|
|
||||||
await browser.sleep(1000);
|
|
||||||
|
|
||||||
await waitForElement(By.xpath('//button[text()="Continue"]'));
|
await waitForElement(By.xpath('//button[text()="Continue"]'));
|
||||||
await browser.findElement(By.xpath('//button[text()="Continue"]')).click();
|
await browser.findElement(By.xpath('//button[text()="Continue"]')).click();
|
||||||
|
|
||||||
|
await waitForElement(By.xpath('//button[text()="Done"] | //div[text()="Single Sign On"]'));
|
||||||
|
|
||||||
|
if (await browser.findElements(By.xpath('//div[text()="Single Sign On"]')).then(found => !!found.length)) {
|
||||||
|
|
||||||
|
await browser.findElement(By.xpath('//div[text()="Single Sign On"]')).click();
|
||||||
|
|
||||||
|
const originalWindowHandle = await browser.getWindowHandle();
|
||||||
|
await browser.wait(async () => (await browser.getAllWindowHandles()).length === 2, 10000);
|
||||||
|
//Loop through until we find a new window handle
|
||||||
|
const windows = await browser.getAllWindowHandles();
|
||||||
|
windows.forEach(async handle => {
|
||||||
|
if (handle !== originalWindowHandle) {
|
||||||
|
await browser.switchTo().window(handle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await waitForElement(By.xpath('//a[contains(., "Continue with")]'));
|
||||||
|
await browser.findElement(By.xpath('//a[contains(., "Continue with")]')).click();
|
||||||
|
|
||||||
|
// switch back to the main window
|
||||||
|
await browser.switchTo().window(originalWindowHandle);
|
||||||
|
|
||||||
|
await waitForElement(By.xpath('//div[text()="Confirm"]'));
|
||||||
|
await browser.findElement(By.xpath('//div[text()="Confirm"]')).click();
|
||||||
|
}
|
||||||
|
|
||||||
await waitForElement(By.xpath('//button[text()="Done"]'));
|
await waitForElement(By.xpath('//button[text()="Done"]'));
|
||||||
await browser.findElement(By.xpath('//button[text()="Done"]')).click();
|
await browser.findElement(By.xpath('//button[text()="Done"]')).click();
|
||||||
|
|
||||||
await waitForElement(By.xpath('//div[text()="Cancel"]'));
|
await waitForElement(By.xpath('//div[text()="Cancel"] | //h1[contains(., "Welcome")]'));
|
||||||
await browser.findElement(By.xpath('//div[text()="Cancel"]')).click();
|
if (await browser.findElements(By.xpath('//div[text()="Cancel"]')).then(found => !!found.length)) {
|
||||||
|
await browser.findElement(By.xpath('//div[text()="Cancel"]')).click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await browser.sleep(3000);
|
await browser.sleep(3000);
|
||||||
@@ -214,18 +245,23 @@ describe('Application life cycle test', function () {
|
|||||||
|
|
||||||
async function createRoom() {
|
async function createRoom() {
|
||||||
await browser.get(`https://${elementApp.fqdn}/#/home`);
|
await browser.get(`https://${elementApp.fqdn}/#/home`);
|
||||||
await browser.sleep(4000);
|
await browser.sleep(2000);
|
||||||
await waitForElement(By.xpath('//div[@role="button" and @aria-label="Add room"]'));
|
await waitForElement(By.xpath('//div[@role="button" and @aria-label="Add room"]'));
|
||||||
await browser.findElement(By.xpath('//div[@role="button" and @aria-label="Add room"]')).click();
|
await browser.findElement(By.xpath('//div[@role="button" and @aria-label="Add room"]')).click();
|
||||||
await browser.sleep(2000);
|
await browser.sleep(1000);
|
||||||
|
await waitForElement(By.xpath('//li[@role="menuitem" and @aria-label="New room"]'));
|
||||||
await browser.findElement(By.xpath('//li[@role="menuitem" and @aria-label="New room"]')).click();
|
await browser.findElement(By.xpath('//li[@role="menuitem" and @aria-label="New room"]')).click();
|
||||||
await browser.sleep(2000);
|
await browser.sleep(1000);
|
||||||
|
|
||||||
|
await waitForElement(By.xpath('//input[@label="Name"]'));
|
||||||
await browser.findElement(By.xpath('//input[@label="Name"]')).sendKeys(ROOM_NAME);
|
await browser.findElement(By.xpath('//input[@label="Name"]')).sendKeys(ROOM_NAME);
|
||||||
await browser.sleep(2000);
|
|
||||||
|
|
||||||
|
await browser.sleep(1000);
|
||||||
|
|
||||||
|
await waitForElement(By.xpath('//button[text()="Create room"]'));
|
||||||
await browser.findElement(By.xpath('//button[text()="Create room"]')).click();
|
await browser.findElement(By.xpath('//button[text()="Create room"]')).click();
|
||||||
await browser.sleep(2000);
|
|
||||||
|
await browser.sleep(1000);
|
||||||
|
|
||||||
await waitForElement(By.xpath('//div[@role="button" and @aria-label="Add room"]'));
|
await waitForElement(By.xpath('//div[@role="button" and @aria-label="Add room"]'));
|
||||||
|
|
||||||
@@ -263,6 +299,7 @@ describe('Application life cycle test', function () {
|
|||||||
|
|
||||||
it('can get Element app info', getElementAppInfo);
|
it('can get Element app info', getElementAppInfo);
|
||||||
it('can register new user', registerUser);
|
it('can register new user', registerUser);
|
||||||
|
|
||||||
it('create room', createRoom);
|
it('create room', createRoom);
|
||||||
it('can send message', sendMessage);
|
it('can send message', sendMessage);
|
||||||
it('can logout', logout); // from auto-login
|
it('can logout', logout); // from auto-login
|
||||||
@@ -285,7 +322,7 @@ describe('Application life cycle test', function () {
|
|||||||
it('can get Element app info', getElementAppInfo);
|
it('can get Element app info', getElementAppInfo);
|
||||||
it('update element-app config', updateSynapseConfig);
|
it('update element-app config', updateSynapseConfig);
|
||||||
|
|
||||||
it('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, false, false /* proceedWithReset */));
|
it('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, false, false));
|
||||||
it('create room', createRoom);
|
it('create room', createRoom);
|
||||||
it('can send message', sendMessage);
|
it('can send message', sendMessage);
|
||||||
it('can get app info', getAppInfo);
|
it('can get app info', getAppInfo);
|
||||||
@@ -326,7 +363,7 @@ describe('Application life cycle test', function () {
|
|||||||
});
|
});
|
||||||
xit('update element-app config', updateSynapseConfig);
|
xit('update element-app config', updateSynapseConfig);
|
||||||
xit('can get Element app info', getElementAppInfo);
|
xit('can get Element app info', getElementAppInfo);
|
||||||
xit('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, true, true /* proceedWithReset */));
|
xit('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, true, true));
|
||||||
xit('check room', checkRoom);
|
xit('check room', checkRoom);
|
||||||
xit('can send message', sendMessage);
|
xit('can send message', sendMessage);
|
||||||
|
|
||||||
@@ -346,10 +383,9 @@ describe('Application life cycle test', function () {
|
|||||||
|
|
||||||
it('can install element-web app (update)', function () { execSync('cloudron install --appstore-id im.riot.cloudronapp --location ' + ELEMENT_LOCATION, EXEC_ARGS); });
|
it('can install element-web app (update)', function () { execSync('cloudron install --appstore-id im.riot.cloudronapp --location ' + ELEMENT_LOCATION, EXEC_ARGS); });
|
||||||
it('can get Element app info', getElementAppInfo);
|
it('can get Element app info', getElementAppInfo);
|
||||||
|
|
||||||
it('update element-app config', updateSynapseConfig);
|
it('update element-app config', updateSynapseConfig);
|
||||||
|
|
||||||
it('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, false, false /* proceedWithReset */));
|
it('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, false, false));
|
||||||
it('is logged in', isLoggedIn);
|
it('is logged in', isLoggedIn);
|
||||||
it('create room', createRoom);
|
it('create room', createRoom);
|
||||||
it('can send message', sendMessage);
|
it('can send message', sendMessage);
|
||||||
@@ -363,9 +399,11 @@ describe('Application life cycle test', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can get Element app info', getElementAppInfo);
|
it('can get Element app info', getElementAppInfo);
|
||||||
it('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, false, true /* proceedWithReset */));
|
it('can login via OIDC', loginOIDC.bind(null, USERNAME, PASSWORD, false, true));
|
||||||
|
|
||||||
it('is logged in', isLoggedIn);
|
it('is logged in', isLoggedIn);
|
||||||
it('check room', checkRoom);
|
it('check room', checkRoom);
|
||||||
|
|
||||||
it('can send message', sendMessage);
|
it('can send message', sendMessage);
|
||||||
it('can get app info', getAppInfo);
|
it('can get app info', getAppInfo);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user