Add non-sso tests
This commit is contained in:
56
test/test.js
56
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
|
// https://matrix.org/docs/spec/client_server/latest
|
||||||
function checkLogin(done) {
|
function checkLogin(done) {
|
||||||
superagent.post('https://' + app.fqdn + '/_matrix/client/r0/login').send({
|
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' });
|
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 () {
|
it('install app', function () {
|
||||||
execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user