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,3 +1,5 @@
|
|||
import Mirage from 'ember-cli-mirage';
|
||||
|
||||
export default function () {
|
||||
|
||||
this.passthrough('https://widget.intercom.io/widget/%7Bapp_id%7D');
|
||||
|
@ -121,7 +123,12 @@ export default function() {
|
|||
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,19 +197,16 @@ export default function() {
|
|||
});
|
||||
|
||||
this.get('/folders/VzMuyEw_3WqiafcG/permissions', () => {
|
||||
return [
|
||||
{
|
||||
return [{
|
||||
"folderId": "VzMuyEw_3WqiafcG",
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"canView": true,
|
||||
"canEdit": true
|
||||
}
|
||||
];
|
||||
}];
|
||||
});
|
||||
|
||||
this.put('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
||||
return [
|
||||
{
|
||||
return [{
|
||||
"orgId": "VzMuyEw_3WqiafcD",
|
||||
"folderId": "VzMygEw_3WrtFzto",
|
||||
"userId": "",
|
||||
|
@ -187,19 +224,16 @@ export default function() {
|
|||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"canEdit": true,
|
||||
"canView": true
|
||||
}
|
||||
];
|
||||
}];
|
||||
});
|
||||
|
||||
this.get('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
||||
return [
|
||||
{
|
||||
return [{
|
||||
"folderId": "VzMygEw_3WrtFzto",
|
||||
"userId": "VzMuyEw_3WqiafcE",
|
||||
"canView": true,
|
||||
"canEdit": true
|
||||
}
|
||||
];
|
||||
}];
|
||||
});
|
||||
|
||||
this.put('/folders/:id', (schema, request) => {
|
||||
|
@ -338,8 +372,8 @@ export default function() {
|
|||
"title": "EmberSherpa",
|
||||
"message": "This Documize instance contains all our team documentation",
|
||||
"domain": ""
|
||||
}
|
||||
]};
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
this.get('/users/VzMuyEw_3WqiafcE', () => {
|
||||
|
@ -367,8 +401,8 @@ export default function() {
|
|||
"title": "EmberSherpa",
|
||||
"message": "This Documize instance contains all our team documentation",
|
||||
"domain": ""
|
||||
}
|
||||
]};
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => {
|
||||
|
@ -399,8 +433,8 @@ export default function() {
|
|||
"title": "EmberSherpa",
|
||||
"message": "This Documize instance contains all our team documentation",
|
||||
"domain": ""
|
||||
}
|
||||
]};
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
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.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