From 9107d791e2eef9a1b24b0499dac8b9dbba8a792f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Apr 2020 09:04:42 +0200 Subject: Add external login tests --- shared/extra-utils/users/login.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'shared/extra-utils/users') diff --git a/shared/extra-utils/users/login.ts b/shared/extra-utils/users/login.ts index b12b51b8c..275bb0826 100644 --- a/shared/extra-utils/users/login.ts +++ b/shared/extra-utils/users/login.ts @@ -95,6 +95,26 @@ function setAccessTokensToServers (servers: ServerInfo[]) { return Promise.all(tasks) } +function loginUsingExternalToken (server: Server, username: string, externalAuthToken: string, expectedStatus = 200) { + const path = '/api/v1/users/token' + + const body = { + client_id: server.client.id, + client_secret: server.client.secret, + username: username, + response_type: 'code', + grant_type: 'password', + scope: 'upload', + externalAuthToken + } + + return request(server.url) + .post(path) + .type('form') + .send(body) + .expect(expectedStatus) +} + // --------------------------------------------------------------------------- export { @@ -107,5 +127,6 @@ export { setAccessTokensToServers, Server, Client, - User + User, + loginUsingExternalToken } -- cgit v1.2.3