From 070d306838b4ac607ff30bd4ec6f4665094e09cb Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 9 Jun 2020 22:20:42 -0700 Subject: [PATCH] Add non-sso tests --- test/test.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/test.js b/test/test.js index 45423d1..6d8042b 100644 --- a/test/test.js +++ b/test/test.js @@ -58,6 +58,37 @@ describe('Application life cycle test', function () { }); } + // https://matrix.org/docs/spec/client_server/latest#user-interactive-api-in-the-rest-api + function registerUser(done) { + superagent.post('https://' + app.fqdn + '/_matrix/client/r0/register?kind=user').send({ + username: username, + password: password, + inhibit_login: false + }).end(function (error, result) { + // we will first get a 401 + let session = result.body.session; + console.log('session is', session); + if (result.statusCode !== 401) return done(new Error('Expecting a 401 ' + result.statusCode)); + + superagent.post('https://' + app.fqdn + '/_matrix/client/r0/register?kind=user').send({ + auth: { + type: 'm.login.dummy', + session: session + }, + username: username, + password: password, + inhibit_login: false + }).end(function (error, result) { + if (error) return done(error); + if (result.statusCode !== 200) return done(new Error('Login failed with status ' + result.statusCode)); + + console.log('registered user with id', result.user_id); + + done(); + }); + }); + } + // https://matrix.org/docs/spec/client_server/latest function checkLogin(done) { superagent.post('https://' + app.fqdn + '/_matrix/client/r0/login').send({ @@ -114,6 +145,31 @@ describe('Application life cycle test', function () { execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); }); + // No SSO + it('install app (no sso)', function () { + execSync('cloudron install --no-sso --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + it('can get app information', function () { + var inspect = JSON.parse(execSync('cloudron inspect')); + + app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0]; + + expect(app).to.be.an('object'); + }); + + it('check landing page', checkLandingPage); + it('can register new user', registerUser); + it('can login', checkLogin); + it('check autojoin', checkAutoJoinRoom); + it('create room', createRoom); + it('check room', checkRoom); + + it('uninstall app', function () { + execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + // SSO it('install app', function () { execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); });