mirror of
https://github.com/documize/community.git
synced 2025-08-08 06:55:28 +02:00
WIP fix sso test
This commit is contained in:
parent
3dccfc6a24
commit
7955da433c
6 changed files with 654 additions and 611 deletions
|
@ -7,9 +7,10 @@ export default Ember.Route.extend({
|
|||
this.get("session").authenticate('authenticator:documize', token)
|
||||
.then(() => {
|
||||
this.transitionTo('folders.folder');
|
||||
}, () => {
|
||||
})
|
||||
.catch(() => {
|
||||
this.transitionTo('auth.login');
|
||||
console.log(">>>>> Documize SSO failure");
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
export default function() {
|
||||
import Mirage from 'ember-cli-mirage';
|
||||
|
||||
export default function () {
|
||||
|
||||
this.passthrough('https://widget.intercom.io/widget/%7Bapp_id%7D');
|
||||
this.urlPrefix = 'https://localhost:5001'; // make this `http://localhost:8080`, for example, if your API is on a different server
|
||||
this.namespace = 'api'; // make this `api`, for example, if your API is namespaced
|
||||
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
||||
|
||||
this.get('/public/meta', function(schema) {
|
||||
this.get('/public/meta', function (schema) {
|
||||
return schema.db.meta[0];
|
||||
});
|
||||
|
||||
this.get('/public/validate', function(schema, request) {
|
||||
this.get('/public/validate', function (schema, request) {
|
||||
let serverToken = request.queryParams.token;
|
||||
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0";
|
||||
|
||||
|
@ -42,7 +44,7 @@ export default function() {
|
|||
}
|
||||
});
|
||||
|
||||
this.get('/users/0/permissions', function() {
|
||||
this.get('/users/0/permissions', function () {
|
||||
return [{
|
||||
"folderId": "VzMygEw_3WrtFzto",
|
||||
"userId": "",
|
||||
|
@ -51,11 +53,11 @@ export default function() {
|
|||
}];
|
||||
});
|
||||
|
||||
this.get('/templates', function() {
|
||||
this.get('/templates', function () {
|
||||
return [];
|
||||
});
|
||||
|
||||
this.get('/documents', function(schema, request) {
|
||||
this.get('/documents', function (schema, request) {
|
||||
let folder_id = request.queryParams.folder;
|
||||
|
||||
if (folder_id = "VzMuyEw_3WqiafcG") {
|
||||
|
@ -96,32 +98,37 @@ export default function() {
|
|||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"folderType": 1
|
||||
};
|
||||
} else if (folder_id = 'V0Vy5Uw_3QeDAMW9'){
|
||||
} else if (folder_id = 'V0Vy5Uw_3QeDAMW9') {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
this.get('/folders', function(schema) {
|
||||
this.get('/folders', function (schema) {
|
||||
return schema.db.folders;
|
||||
});
|
||||
|
||||
this.post('/folders', function(schema, request) {
|
||||
this.post('/folders', function (schema, request) {
|
||||
var name = JSON.parse(request.requestBody).name;
|
||||
let newFolder = {
|
||||
"id":"V0Vy5Uw_3QeDAMW9",
|
||||
"created":"2016-05-25T09:39:49Z",
|
||||
"revised":"2016-05-25T09:39:49Z",
|
||||
"name":name,
|
||||
"orgId":"VzMuyEw_3WqiafcD",
|
||||
"userId":"VzMuyEw_3WqiafcE",
|
||||
"folderType":2
|
||||
"id": "V0Vy5Uw_3QeDAMW9",
|
||||
"created": "2016-05-25T09:39:49Z",
|
||||
"revised": "2016-05-25T09:39:49Z",
|
||||
"name": name,
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"folderType": 2
|
||||
};
|
||||
|
||||
let folder = schema.db.folders.insert(newFolder);
|
||||
return folder;
|
||||
});
|
||||
|
||||
this.post('/public/authenticate', () => {
|
||||
this.post('/public/authenticate', (schema, request) => {
|
||||
debugger;
|
||||
let authorization = request.requestHeaders.Authorization;
|
||||
let expectedAuthorization = "Basic OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==";
|
||||
|
||||
if (expectedAuthorization == authorization) {
|
||||
return {
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
|
||||
"user": {
|
||||
|
@ -150,6 +157,39 @@ export default function() {
|
|||
}]
|
||||
}
|
||||
};
|
||||
} else if (expectedAuthorization != authorization) {
|
||||
return new Mirage.Response(400);
|
||||
} else {
|
||||
return {
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
|
||||
"user": {
|
||||
"id": "VzMuyEw_3WqiafcE",
|
||||
"created": "2016-05-11T15:08:24Z",
|
||||
"revised": "2016-05-11T15:08:24Z",
|
||||
"firstname": "Lennex",
|
||||
"lastname": "Zinyando",
|
||||
"email": "brizdigital@gmail.com",
|
||||
"initials": "LZ",
|
||||
"active": true,
|
||||
"editor": true,
|
||||
"admin": true,
|
||||
"accounts": [{
|
||||
"id": "VzMuyEw_3WqiafcF",
|
||||
"created": "2016-05-11T15:08:24Z",
|
||||
"revised": "2016-05-11T15:08:24Z",
|
||||
"admin": true,
|
||||
"editor": true,
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"company": "EmberSherpa",
|
||||
"title": "EmberSherpa",
|
||||
"message": "This Documize instance contains all our team documentation",
|
||||
"domain": ""
|
||||
}]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.get('/users/VzMuyEw_3WqiafcE/permissions', (schema) => {
|
||||
|
@ -157,49 +197,43 @@ export default function() {
|
|||
});
|
||||
|
||||
this.get('/folders/VzMuyEw_3WqiafcG/permissions', () => {
|
||||
return [
|
||||
{
|
||||
"folderId":"VzMuyEw_3WqiafcG",
|
||||
"userId":"VzMuyEw_3WqiafcE",
|
||||
"canView":true,
|
||||
"canEdit":true
|
||||
}
|
||||
];
|
||||
return [{
|
||||
"folderId": "VzMuyEw_3WqiafcG",
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"canView": true,
|
||||
"canEdit": true
|
||||
}];
|
||||
});
|
||||
|
||||
this.put('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
||||
return [
|
||||
{
|
||||
"orgId":"VzMuyEw_3WqiafcD",
|
||||
"folderId":"VzMygEw_3WrtFzto",
|
||||
"userId":"",
|
||||
"canEdit":true,
|
||||
"canView":true
|
||||
},{
|
||||
"orgId":"VzMuyEw_3WqiafcD",
|
||||
"folderId":"VzMygEw_3WrtFzto",
|
||||
"userId":"VzMyp0w_3WrtFztq",
|
||||
"canEdit":false,
|
||||
"canView":false
|
||||
},{
|
||||
"orgId":"",
|
||||
"folderId":"VzMygEw_3WrtFzto",
|
||||
"userId":"VzMuyEw_3WqiafcE",
|
||||
"canEdit":true,
|
||||
"canView":true
|
||||
}
|
||||
];
|
||||
return [{
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"folderId": "VzMygEw_3WrtFzto",
|
||||
"userId": "",
|
||||
"canEdit": true,
|
||||
"canView": true
|
||||
}, {
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"folderId": "VzMygEw_3WrtFzto",
|
||||
"userId": "VzMyp0w_3WrtFztq",
|
||||
"canEdit": false,
|
||||
"canView": false
|
||||
}, {
|
||||
"orgId": "",
|
||||
"folderId": "VzMygEw_3WrtFzto",
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"canEdit": true,
|
||||
"canView": true
|
||||
}];
|
||||
});
|
||||
|
||||
this.get('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
||||
return [
|
||||
{
|
||||
"folderId":"VzMygEw_3WrtFzto",
|
||||
"userId":"VzMuyEw_3WqiafcE",
|
||||
"canView":true,
|
||||
"canEdit":true
|
||||
}
|
||||
];
|
||||
return [{
|
||||
"folderId": "VzMygEw_3WrtFzto",
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"canView": true,
|
||||
"canEdit": true
|
||||
}];
|
||||
});
|
||||
|
||||
this.put('/folders/:id', (schema, request) => {
|
||||
|
@ -211,13 +245,13 @@ export default function() {
|
|||
|
||||
this.put('/folders/V0Vy5Uw_3QeDAMW9', () => {
|
||||
return {
|
||||
"id":"V0Vy5Uw_3QeDAMW9",
|
||||
"created":"2016-05-25T09:39:49Z",
|
||||
"revised":"2016-05-25T09:39:49Z",
|
||||
"name":"Test Folder",
|
||||
"orgId":"VzMuyEw_3WqiafcD",
|
||||
"userId":"VzMuyEw_3WqiafcE",
|
||||
"folderType":2
|
||||
"id": "V0Vy5Uw_3QeDAMW9",
|
||||
"created": "2016-05-25T09:39:49Z",
|
||||
"revised": "2016-05-25T09:39:49Z",
|
||||
"name": "Test Folder",
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"folderType": 2
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -316,59 +350,59 @@ export default function() {
|
|||
let email = JSON.parse(request.requestBody).email;
|
||||
|
||||
return {
|
||||
"id":"V0RmtUw_3QeDAMW7",
|
||||
"created":"2016-05-24T14:35:33Z",
|
||||
"revised":"2016-05-24T14:35:33Z",
|
||||
"firstname":`${firstname}`,
|
||||
"lastname":`${lastname}`,
|
||||
"email":`${email}`,
|
||||
"initials":"TU",
|
||||
"active":true,
|
||||
"editor":true,
|
||||
"admin":false,
|
||||
"accounts":[{
|
||||
"id":"V0RmtUw_3QeDAMW8",
|
||||
"created":"2016-05-24T14:35:34Z",
|
||||
"revised":"2016-05-24T14:35:34Z",
|
||||
"admin":false,
|
||||
"editor":true,
|
||||
"userId":"V0RmtUw_3QeDAMW7",
|
||||
"orgId":"VzMuyEw_3WqiafcD",
|
||||
"company":"EmberSherpa",
|
||||
"title":"EmberSherpa",
|
||||
"message":"This Documize instance contains all our team documentation",
|
||||
"domain":""
|
||||
}
|
||||
]};
|
||||
"id": "V0RmtUw_3QeDAMW7",
|
||||
"created": "2016-05-24T14:35:33Z",
|
||||
"revised": "2016-05-24T14:35:33Z",
|
||||
"firstname": `${firstname}`,
|
||||
"lastname": `${lastname}`,
|
||||
"email": `${email}`,
|
||||
"initials": "TU",
|
||||
"active": true,
|
||||
"editor": true,
|
||||
"admin": false,
|
||||
"accounts": [{
|
||||
"id": "V0RmtUw_3QeDAMW8",
|
||||
"created": "2016-05-24T14:35:34Z",
|
||||
"revised": "2016-05-24T14:35:34Z",
|
||||
"admin": false,
|
||||
"editor": true,
|
||||
"userId": "V0RmtUw_3QeDAMW7",
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"company": "EmberSherpa",
|
||||
"title": "EmberSherpa",
|
||||
"message": "This Documize instance contains all our team documentation",
|
||||
"domain": ""
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
this.get('/users/VzMuyEw_3WqiafcE', () => {
|
||||
|
||||
return {
|
||||
"id":"VzMuyEw_3WqiafcE",
|
||||
"created":"2016-05-11T15:08:24Z",
|
||||
"revised":"2016-05-11T15:08:24Z",
|
||||
"firstname":"Lennex",
|
||||
"lastname":"Zinyando",
|
||||
"email":"brizdigital@gmail.com",
|
||||
"initials":"LZ",
|
||||
"active":true,
|
||||
"editor":true,
|
||||
"admin":true,
|
||||
"accounts":[{
|
||||
"id":"VzMuyEw_3WqiafcF",
|
||||
"created":"2016-05-11T15:08:24Z",
|
||||
"revised":"2016-05-11T15:08:24Z",
|
||||
"admin":true,
|
||||
"editor":true,
|
||||
"userId":"VzMuyEw_3WqiafcE",
|
||||
"orgId":"VzMuyEw_3WqiafcD",
|
||||
"company":"EmberSherpa",
|
||||
"title":"EmberSherpa",
|
||||
"message":"This Documize instance contains all our team documentation",
|
||||
"domain":""
|
||||
}
|
||||
]};
|
||||
"id": "VzMuyEw_3WqiafcE",
|
||||
"created": "2016-05-11T15:08:24Z",
|
||||
"revised": "2016-05-11T15:08:24Z",
|
||||
"firstname": "Lennex",
|
||||
"lastname": "Zinyando",
|
||||
"email": "brizdigital@gmail.com",
|
||||
"initials": "LZ",
|
||||
"active": true,
|
||||
"editor": true,
|
||||
"admin": true,
|
||||
"accounts": [{
|
||||
"id": "VzMuyEw_3WqiafcF",
|
||||
"created": "2016-05-11T15:08:24Z",
|
||||
"revised": "2016-05-11T15:08:24Z",
|
||||
"admin": true,
|
||||
"editor": true,
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"company": "EmberSherpa",
|
||||
"title": "EmberSherpa",
|
||||
"message": "This Documize instance contains all our team documentation",
|
||||
"domain": ""
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => {
|
||||
|
@ -377,30 +411,30 @@ export default function() {
|
|||
let email = JSON.parse(request.requestBody).email;
|
||||
|
||||
return {
|
||||
"id":"VzMuyEw_3WqiafcE",
|
||||
"created":"2016-05-11T15:08:24Z",
|
||||
"revised":"2016-05-11T15:08:24Z",
|
||||
"firstname":`${firstname}`,
|
||||
"lastname":`${lastname}`,
|
||||
"email":`${email}`,
|
||||
"initials":"LZ",
|
||||
"active":true,
|
||||
"editor":true,
|
||||
"admin":true,
|
||||
"accounts":[{
|
||||
"id":"VzMuyEw_3WqiafcF",
|
||||
"created":"2016-05-11T15:08:24Z",
|
||||
"revised":"2016-05-11T15:08:24Z",
|
||||
"admin":true,
|
||||
"editor":true,
|
||||
"userId":"VzMuyEw_3WqiafcE",
|
||||
"orgId":"VzMuyEw_3WqiafcD",
|
||||
"company":"EmberSherpa",
|
||||
"title":"EmberSherpa",
|
||||
"message":"This Documize instance contains all our team documentation",
|
||||
"domain":""
|
||||
}
|
||||
]};
|
||||
"id": "VzMuyEw_3WqiafcE",
|
||||
"created": "2016-05-11T15:08:24Z",
|
||||
"revised": "2016-05-11T15:08:24Z",
|
||||
"firstname": `${firstname}`,
|
||||
"lastname": `${lastname}`,
|
||||
"email": `${email}`,
|
||||
"initials": "LZ",
|
||||
"active": true,
|
||||
"editor": true,
|
||||
"admin": true,
|
||||
"accounts": [{
|
||||
"id": "VzMuyEw_3WqiafcF",
|
||||
"created": "2016-05-11T15:08:24Z",
|
||||
"revised": "2016-05-11T15:08:24Z",
|
||||
"admin": true,
|
||||
"editor": true,
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"company": "EmberSherpa",
|
||||
"title": "EmberSherpa",
|
||||
"message": "This Documize instance contains all our team documentation",
|
||||
"domain": ""
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
this.post('/folders/VzMuyEw_3WqiafcG/invitation', () => {
|
||||
|
@ -410,11 +444,11 @@ export default function() {
|
|||
/**
|
||||
very helpful for debugging
|
||||
*/
|
||||
this.handledRequest = function(verb, path) {
|
||||
this.handledRequest = function (verb, path) {
|
||||
console.log(`👊${verb} ${path}`);
|
||||
};
|
||||
|
||||
this.unhandledRequest = function(verb, path) {
|
||||
this.unhandledRequest = function (verb, path) {
|
||||
console.log(`🔥${verb} ${path}`);
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ test('visiting / when not authenticated and with { allowAnonymousAccess: true }
|
|||
server.create('meta', { allowAnonymousAccess: true });
|
||||
server.createList('folder', 2);
|
||||
visit('/');
|
||||
// return pauseTest();
|
||||
|
||||
andThen(function () {
|
||||
assert.equal(find('.login').length, 1, 'Login button is displayed');
|
||||
|
|
|
@ -13,7 +13,7 @@ test('visiting /auth/login and logging in', function (assert) {
|
|||
click('button');
|
||||
|
||||
andThen(function () {
|
||||
assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test', 'Login successfull');
|
||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -25,18 +25,29 @@ test('logging out a user', function (assert) {
|
|||
visit('/auth/logout');
|
||||
|
||||
andThen(function () {
|
||||
assert.equal(currentURL(), '/auth/login', 'Logging out successfull');
|
||||
assert.equal(currentURL(), '/auth/login', 'Logging out successful');
|
||||
});
|
||||
});
|
||||
|
||||
test('sso login', function (assert) {
|
||||
test('successful sso login authenticates redirects to dashboard', function (assert) {
|
||||
server.create('meta', { allowAnonymousAccess: false });
|
||||
server.createList('folder', 2);
|
||||
userLogin();
|
||||
|
||||
visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
|
||||
// return pauseTest();
|
||||
|
||||
andThen(function () {
|
||||
assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test', 'Login successfull');
|
||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful');
|
||||
});
|
||||
});
|
||||
|
||||
test('sso login with bad token should redirect to login', function (assert) {
|
||||
server.create('meta', { allowAnonymousAccess: false });
|
||||
server.createList('folder', 2);
|
||||
|
||||
visit('/auth/sso/randomToken1234567890');
|
||||
|
||||
andThen(function () {
|
||||
assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -48,7 +48,6 @@ skip('Adding a document to a space', function (assert) {
|
|||
let numberOfDocuments = find('.documents-list li').length;
|
||||
assert.equal(numberOfDocuments, 3, '3 documents listed');
|
||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
||||
// return pauseTest();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -130,7 +129,6 @@ test('changing space permissions', function (assert) {
|
|||
click('.button-blue');
|
||||
|
||||
visit('/s/VzMygEw_3WrtFzto/test');
|
||||
// return pauseTest();
|
||||
|
||||
andThen(function () {
|
||||
let numberOfPublicFolders = find('.folders-list div:contains(EVERYONE) .list a').length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue