mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05: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)
|
this.get("session").authenticate('authenticator:documize', token)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.transitionTo('folders.folder');
|
this.transitionTo('folders.folder');
|
||||||
}, () => {
|
})
|
||||||
|
.catch(() => {
|
||||||
this.transitionTo('auth.login');
|
this.transitionTo('auth.login');
|
||||||
console.log(">>>>> Documize SSO failure");
|
console.log(">>>>> Documize SSO failure");
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import Mirage from 'ember-cli-mirage';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
|
||||||
this.passthrough('https://widget.intercom.io/widget/%7Bapp_id%7D');
|
this.passthrough('https://widget.intercom.io/widget/%7Bapp_id%7D');
|
||||||
|
@ -121,7 +123,12 @@ export default function() {
|
||||||
return folder;
|
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 {
|
return {
|
||||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
|
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
|
||||||
"user": {
|
"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) => {
|
this.get('/users/VzMuyEw_3WqiafcE/permissions', (schema) => {
|
||||||
|
@ -157,19 +197,16 @@ export default function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders/VzMuyEw_3WqiafcG/permissions', () => {
|
this.get('/folders/VzMuyEw_3WqiafcG/permissions', () => {
|
||||||
return [
|
return [{
|
||||||
{
|
|
||||||
"folderId": "VzMuyEw_3WqiafcG",
|
"folderId": "VzMuyEw_3WqiafcG",
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
"canView": true,
|
"canView": true,
|
||||||
"canEdit": true
|
"canEdit": true
|
||||||
}
|
}];
|
||||||
];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
this.put('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
||||||
return [
|
return [{
|
||||||
{
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
"folderId": "VzMygEw_3WrtFzto",
|
"folderId": "VzMygEw_3WrtFzto",
|
||||||
"userId": "",
|
"userId": "",
|
||||||
|
@ -187,19 +224,16 @@ export default function() {
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
"canEdit": true,
|
"canEdit": true,
|
||||||
"canView": true
|
"canView": true
|
||||||
}
|
}];
|
||||||
];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
this.get('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
||||||
return [
|
return [{
|
||||||
{
|
|
||||||
"folderId": "VzMygEw_3WrtFzto",
|
"folderId": "VzMygEw_3WrtFzto",
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
"canView": true,
|
"canView": true,
|
||||||
"canEdit": true
|
"canEdit": true
|
||||||
}
|
}];
|
||||||
];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/folders/:id', (schema, request) => {
|
this.put('/folders/:id', (schema, request) => {
|
||||||
|
@ -338,8 +372,8 @@ export default function() {
|
||||||
"title": "EmberSherpa",
|
"title": "EmberSherpa",
|
||||||
"message": "This Documize instance contains all our team documentation",
|
"message": "This Documize instance contains all our team documentation",
|
||||||
"domain": ""
|
"domain": ""
|
||||||
}
|
}]
|
||||||
]};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/users/VzMuyEw_3WqiafcE', () => {
|
this.get('/users/VzMuyEw_3WqiafcE', () => {
|
||||||
|
@ -367,8 +401,8 @@ export default function() {
|
||||||
"title": "EmberSherpa",
|
"title": "EmberSherpa",
|
||||||
"message": "This Documize instance contains all our team documentation",
|
"message": "This Documize instance contains all our team documentation",
|
||||||
"domain": ""
|
"domain": ""
|
||||||
}
|
}]
|
||||||
]};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => {
|
this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => {
|
||||||
|
@ -399,8 +433,8 @@ export default function() {
|
||||||
"title": "EmberSherpa",
|
"title": "EmberSherpa",
|
||||||
"message": "This Documize instance contains all our team documentation",
|
"message": "This Documize instance contains all our team documentation",
|
||||||
"domain": ""
|
"domain": ""
|
||||||
}
|
}]
|
||||||
]};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.post('/folders/VzMuyEw_3WqiafcG/invitation', () => {
|
this.post('/folders/VzMuyEw_3WqiafcG/invitation', () => {
|
||||||
|
|
|
@ -7,7 +7,6 @@ test('visiting / when not authenticated and with { allowAnonymousAccess: true }
|
||||||
server.create('meta', { allowAnonymousAccess: true });
|
server.create('meta', { allowAnonymousAccess: true });
|
||||||
server.createList('folder', 2);
|
server.createList('folder', 2);
|
||||||
visit('/');
|
visit('/');
|
||||||
// return pauseTest();
|
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
assert.equal(find('.login').length, 1, 'Login button is displayed');
|
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');
|
click('button');
|
||||||
|
|
||||||
andThen(function () {
|
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');
|
visit('/auth/logout');
|
||||||
|
|
||||||
andThen(function () {
|
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.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
server.createList('folder', 2);
|
||||||
userLogin();
|
|
||||||
|
|
||||||
visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
|
visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
|
||||||
|
// return pauseTest();
|
||||||
|
|
||||||
andThen(function () {
|
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;
|
let numberOfDocuments = find('.documents-list li').length;
|
||||||
assert.equal(numberOfDocuments, 3, '3 documents listed');
|
assert.equal(numberOfDocuments, 3, '3 documents listed');
|
||||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
// return pauseTest();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -130,7 +129,6 @@ test('changing space permissions', function (assert) {
|
||||||
click('.button-blue');
|
click('.button-blue');
|
||||||
|
|
||||||
visit('/s/VzMygEw_3WrtFzto/test');
|
visit('/s/VzMygEw_3WrtFzto/test');
|
||||||
// return pauseTest();
|
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
let numberOfPublicFolders = find('.folders-list div:contains(EVERYONE) .list a').length;
|
let numberOfPublicFolders = find('.folders-list div:contains(EVERYONE) .list a').length;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue