1
0
mirror of https://git.cloudron.io/cloudron/minio-app synced 2025-09-25 22:47:23 +00:00

attempt to fix tests

This commit is contained in:
Girish Ramakrishnan
2025-06-02 17:58:24 +02:00
parent daad5e6942
commit 1a8f99b140
3 changed files with 35 additions and 88 deletions

13
test/package-lock.json generated
View File

@@ -9,6 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@eslint/js": "^9.28.0",
"chromedriver": "^136.0.3",
"expect.js": "^0.3.1",
"mocha": "^11.5.0",
@@ -22,6 +23,18 @@
"integrity": "sha512-1uLNT5NZsUVIGS4syuHwTzZ8HycMPyr6POA3FCE4GbMtc4rhoJk8aZKtNIRthJYfL+iioppi+rTfH3olMPr9nA==",
"license": "Apache-2.0"
},
"node_modules/@eslint/js": {
"version": "9.28.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.28.0.tgz",
"integrity": "sha512-fnqSjGWd/CoIp4EXIxWVK/sHA6DOHN4+8Ix2cX5ycOY7LG0UY8nHCU5pIp2eaE1Mc7Qd8kHspYNzYXT2ojPLzg==",
"license": "MIT",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"url": "https://eslint.org/donate"
}
},
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",

View File

@@ -9,6 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@eslint/js": "^9.28.0",
"chromedriver": "^136.0.3",
"expect.js": "^0.3.1",
"mocha": "^11.5.0",

View File

@@ -68,49 +68,35 @@ describe('Application life cycle test', function () {
expect(app).to.be.an('object');
}
async function login(username, password, expandLoginForm=true) {
async function confirmLicense() {
await timers.setTimeout(5000);
console.log('confirming license');
await waitForElement(By.id('acknowledge-confirm'));
const button = await browser.findElement(By.id('acknowledge-confirm'));
await browser.executeScript('arguments[0].scrollIntoView(false)', button);
await browser.sleep(4000);
await button.click();
await browser.sleep(4000);
}
async function login(username, password, acceptLicense=false) {
await browser.manage().deleteAllCookies();
await browser.get('about:blank');
await browser.sleep(2000);
await browser.get(`https://${app.fqdn}/login`);
await browser.sleep(2000);
if (expandLoginForm) {
await waitForElement(By.xpath('//div[@id="alternativeMethods-select"]/div[contains(., "Other Authentication Methods")]'));
await browser.findElement(By.xpath('//div[@id="alternativeMethods-select"]/div[contains(., "Other Authentication Methods")]')).click();
await browser.sleep(2000);
await browser.findElement(By.xpath('//li[contains(., "Use Credentials")] | //div[@label="Use Credentials"]')).click();
await browser.sleep(2000);
}
await waitForElement(By.id('accessKey'));
await browser.findElement(By.id('accessKey')).sendKeys(username);
await browser.findElement(By.id('secretKey')).sendKeys(password);
await browser.findElement(By.xpath('//button[@id="do-login"]')).click();
await waitForElement(By.xpath('//span[contains(text(), "Buckets")]'));
if (acceptLicense) await confirmLicense();
await waitForElement(By.xpath('//button[contains(., "Create Bucket")]'));
await timers.setTimeout(5000);
}
async function loginOIDC(username, password, alreadyAuthenticated = true) {
browser.manage().deleteAllCookies();
await browser.get(`https://${app.fqdn}/login`);
await browser.sleep(10000);
await waitForElement(By.xpath('//button[contains(., "iam")]'));
await browser.findElement(By.xpath('//button[contains(., "iam")]')).click();
await browser.sleep(10000);
if (!alreadyAuthenticated) {
await waitForElement(By.id('inputUsername'));
await browser.findElement(By.id('inputUsername')).sendKeys(username);
await browser.findElement(By.id('inputPassword')).sendKeys(password);
await browser.findElement(By.id('loginSubmitButton')).click();
await browser.sleep(2000);
}
await waitForElement(By.xpath('//span[contains(text(), "Buckets")]'));
}
async function logout() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath('//span[contains(text(), "Buckets")]'));
@@ -118,13 +104,13 @@ describe('Application life cycle test', function () {
await browser.executeScript('arguments[0].scrollIntoView(false)', button);
await button.click();
await browser.sleep(10000); // needed!
await waitForElement(By.xpath('//*[@id="accessKey"] | //button[contains(., "Cloudron")]'));
await waitForElement(By.xpath('//*[@id="accessKey"]'));
}
async function addBucket() {
await browser.get(`https://${app.fqdn}/buckets`);
await waitForElement(By.xpath('//button[@id="create-bucket"]'));
await browser.findElement(By.xpath('//button[@id="create-bucket"]')).click();
await waitForElement(By.xpath('//button[contains(., "Create Bucket")]'));
await browser.findElement(By.xpath('//button[contains(., "Create Bucket")]')).click();
await browser.sleep(1000);
await waitForElement(By.xpath('//input[@id="bucket-name"]'));
await browser.findElement(By.xpath('//input[@id="bucket-name"]')).sendKeys(BUCKET);
@@ -170,51 +156,18 @@ 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} --secondary-domains API_SERVER_DOMAIN=${LOCATION}-api`, EXEC_ARGS);
await timers.setTimeout(10000);
});
it('can get app information', getAppInfo);
it('can admin login', login.bind(null, 'minioadmin', 'minioadmin', false));
it('can add bucket', addBucket);
it('can logout', logout);
it('does redirect', checkRedirect);
it('check api', checkApi);
it('can change admin credentials', changeAdminCredentials);
it('can restart app', async function () {
execSync(`cloudron restart --app ${app.id}`, EXEC_ARGS);
await timers.setTimeout(10000);
});
it('can admin login', login.bind(null, 'minioakey', 'minioskey', false));
it('has bucket', checkBucket);
it('can logout', logout);
it('does redirect', checkRedirect);
it('check api', checkApi);
it('uninstall app', function () { execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS); });
// SSO
it('install app (SSO)', async function () {
xit('install app', async function () {
execSync(`cloudron install --location ${LOCATION} --secondary-domains API_SERVER_DOMAIN=${LOCATION}-api`, EXEC_ARGS);
await timers.setTimeout(10000);
});
it('can get app information', getAppInfo);
it('can get admin credentials', getAdminCredentials);
it('can admin login', async function () { await login('minioadmin', rootPassword); });
it('can admin login', login.bind(null, 'minioadmin', 'minioadmin', true));
it('can add bucket', addBucket);
it('can logout', logout);
it('does redirect', checkRedirect);
it('check api', checkApi);
it('can OIDC login', loginOIDC.bind(null, username, password, false));
it('has bucket', checkBucket);
it('can logout', logout);
it('can change admin credentials', changeAdminCredentials);
it('can restart app', async function () {
@@ -228,10 +181,6 @@ describe('Application life cycle test', function () {
it('does redirect', checkRedirect);
it('check api', checkApi);
it('can OIDC login', loginOIDC.bind(null, username, password, true));
it('has bucket', checkBucket);
it('can logout', logout);
it('backup app', function () { execSync('cloudron backup create --app ' + app.id, EXEC_ARGS); });
it('restore app', async function () {
const backups = JSON.parse(execSync(`cloudron backup list --raw --app ${app.id}`));
@@ -247,10 +196,6 @@ describe('Application life cycle test', function () {
it('has bucket', checkBucket);
it('can logout', logout);
it('can OIDC login', loginOIDC.bind(null, username, password, true));
it('has bucket', checkBucket);
it('can logout', logout);
it('does redirect', checkRedirect);
it('check api', checkApi);
@@ -265,10 +210,6 @@ describe('Application life cycle test', function () {
it('has bucket', checkBucket);
it('can logout', logout);
it('can OIDC login', loginOIDC.bind(null, username, password, true));
it('has bucket', checkBucket);
it('can logout', logout);
it('does redirect', checkRedirect);
it('check api', checkApi);
@@ -283,10 +224,6 @@ describe('Application life cycle test', function () {
it('can add buckets', addBucket);
it('can logout', logout);
it('can OIDC login', loginOIDC.bind(null, username, password, true));
it('has bucket', checkBucket);
it('can logout', logout);
it('can update', function () { execSync(`cloudron update --app ${LOCATION}`, EXEC_ARGS); });
it('can configure', function () { execSync(`cloudron configure --app ${LOCATION} --location ${LOCATION} --secondary-domains API_SERVER_DOMAIN=${LOCATION}-api`, EXEC_ARGS); });
it('can get app information', getAppInfo);
@@ -295,10 +232,6 @@ describe('Application life cycle test', function () {
it('has bucket', checkBucket);
it('can logout', logout);
it('can OIDC login', loginOIDC.bind(null, username, password, true));
it('has bucket', checkBucket);
it('can logout', logout);
it('does redirect', checkRedirect);
it('check api', checkApi);