From f010ef70e9feb59f0cbf4111644df4bf9cb918c0 Mon Sep 17 00:00:00 2001 From: Vladimir D Date: Tue, 24 Dec 2024 13:48:03 +0400 Subject: [PATCH] checklist added to CloudronManifest, CLOUDRON_OIDC_PROVIDER_NAME implemented, tests updated --- CloudronManifest.json | 7 +++++- POSTINSTALL.md | 2 -- start.sh | 3 ++- test/test.js | 57 +++++++++++++++++++++++-------------------- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/CloudronManifest.json b/CloudronManifest.json index 9d894d1..6fc083b 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -30,6 +30,11 @@ "loginRedirectUri": "/plugins/auth-openid-connect/router/code-cb" } }, + "checklist": { + "change-default-password": { + "message": "Change the default admin password" + } + }, "memoryLimit": 1073741824, "forumUrl": "https://forum.cloudron.io/category/91/peertube", "optionalSso": true, @@ -50,6 +55,6 @@ "changelog": "file://CHANGELOG.md", "postInstallMessage": "file://POSTINSTALL.md", "documentationUrl": "https://docs.cloudron.io/apps/peertube/", - "minBoxVersion": "7.4.0", + "minBoxVersion": "8.1.0", "manifestVersion": 2 } diff --git a/POSTINSTALL.md b/POSTINSTALL.md index d5f720d..5f32c41 100644 --- a/POSTINSTALL.md +++ b/POSTINSTALL.md @@ -3,8 +3,6 @@ This app is pre-setup with an admin account. The initial credentials are: **Username**: root
**Password**: changeme
-Please change the admin password immediately. - IMPORTANT: PeerTube does not support changing the location of the app after installation. Doing so, will break the installation. diff --git a/start.sh b/start.sh index 6614ca5..490cadf 100755 --- a/start.sh +++ b/start.sh @@ -19,8 +19,9 @@ install_oidc() { update_oidc() { echo "==> Updating OIDC config" + provider_name="${CLOUDRON_OIDC_PROVIDER_NAME:-Cloudron}" PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} \ - -c "UPDATE plugin SET settings='{\"scope\": \"openid email profile\", \"client-id\": \"${CLOUDRON_OIDC_CLIENT_ID}\", \"discover-url\": \"${CLOUDRON_OIDC_DISCOVERY_URL}\", \"client-secret\": \"${CLOUDRON_OIDC_CLIENT_SECRET}\", \"mail-property\": \"email\", \"auth-display-name\": \"Cloudron\", \"username-property\": \"preferred_username\", \"signature-algorithm\": \"RS256\", \"display-name-property\": \"name\"}' WHERE name='auth-openid-connect'" + -c "UPDATE plugin SET settings='{\"scope\": \"openid email profile\", \"client-id\": \"${CLOUDRON_OIDC_CLIENT_ID}\", \"discover-url\": \"${CLOUDRON_OIDC_DISCOVERY_URL}\", \"client-secret\": \"${CLOUDRON_OIDC_CLIENT_SECRET}\", \"mail-property\": \"email\", \"auth-display-name\": \"${provider_name//\'/\'\'}\", \"username-property\": \"preferred_username\", \"signature-algorithm\": \"RS256\", \"display-name-property\": \"name\"}' WHERE name='auth-openid-connect'" } first_time_setup() { diff --git a/test/test.js b/test/test.js index fdd4973..b7356b9 100644 --- a/test/test.js +++ b/test/test.js @@ -31,8 +31,7 @@ describe('Application life cycle test', function () { const TEST_TIMEOUT = parseInt(process.env.TEST_TIMEOUT, 10) || 30000; const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; - let browser; - let app; + let browser, app, cloudronName; let host_os; let username = process.env.USERNAME; let password = process.env.PASSWORD; @@ -60,6 +59,14 @@ describe('Application life cycle test', function () { fs.writeFileSync(`./screenshots/${new Date().getTime()}-${this.currentTest.title.replaceAll(' ', '_')}.png`, screenshotData, 'base64'); }); + function getAppInfo() { + let inspect = JSON.parse(execSync('cloudron inspect')); + app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0]; + expect(app).to.be.an('object'); + const tmp = execSync(`cloudron exec --app ${app.id} env`).toString().split('\n').find((l) => l.indexOf('CLOUDRON_OIDC_PROVIDER_NAME=') === 0); + if (tmp) cloudronName = tmp.slice('CLOUDRON_OIDC_PROVIDER_NAME='.length); + } + async function clearCache() { await browser.manage().deleteAllCookies(); await browser.quit(); @@ -70,12 +77,6 @@ describe('Application life cycle test', function () { browser = new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build(); } - function getAppInfo() { - let inspect = JSON.parse(execSync('cloudron inspect')); - app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0]; - expect(app).to.be.an('object'); - } - async function getOS() { if (typeof(host_os) == 'undefined' || host_os == null) host_os = String(await execSync('uname -s')).trim(); @@ -106,8 +107,8 @@ describe('Application life cycle test', function () { await browser.get(`https://${app.fqdn}/login`); await browser.sleep(2000); - await browser.wait(until.elementLocated(By.xpath('//a[contains(., "Cloudron")]')), TEST_TIMEOUT); - await browser.findElement(By.xpath('//a[contains(., "Cloudron")]')).click(); + await browser.wait(until.elementLocated(By.xpath(`//a[contains(., "${cloudronName}") or contains(., "Cloudron")]`)), TEST_TIMEOUT); + await browser.findElement(By.xpath('//a[contains(., "${cloudronName}") or contains(., "Cloudron")]')).click(); await browser.sleep(2000); if (!alreadyAuthenticated) { @@ -172,6 +173,24 @@ describe('Application life cycle test', function () { } xit('build app', function () { execSync('cloudron build', EXEC_ARGS); }); + + // No SSO + it('install app (no sso)', async function () { + execSync('cloudron install --no-sso --location ' + LOCATION, EXEC_ARGS); + await sleep(10000); // takes a bit to create root user in background + }); + + it('can get app information', getAppInfo); + + it('can login (no sso)', login.bind(null, 'root', 'changeme')); + it('can complete setup', completeSetup); + it('can logout', clearCache); + + it('uninstall app (no sso)', async function () { + execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS); + }); + + // SSO it('install app', async function () { execSync('cloudron install --location ' + LOCATION, EXEC_ARGS); await sleep(40000); // takes a bit to create root user in background @@ -184,6 +203,8 @@ describe('Application life cycle test', function () { it('video exists', videoExists); it('logout', clearCache); + it('can get app information', getAppInfo); + it('can OIDC login', loginOIDC.bind(null, username, password)); it('can close account setup dialog', closeAccountSetupDialog); it('logout', clearCache); @@ -230,22 +251,6 @@ describe('Application life cycle test', function () { execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS); }); - // No SSO - it('install app (no sso)', async function () { - execSync('cloudron install --no-sso --location ' + LOCATION, EXEC_ARGS); - await sleep(10000); // takes a bit to create root user in background - }); - - it('can get app information', getAppInfo); - - it('can login (no sso)', login.bind(null, 'root', 'changeme')); - it('can complete setup', completeSetup); - it('can logout', clearCache); - - it('uninstall app (no sso)', async function () { - execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS); - }); - // test update it('can install app', async function () { execSync('cloudron install --appstore-id org.joinpeertube.cloudronapp --location ' + LOCATION, EXEC_ARGS);