aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/users/login.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-29 09:04:42 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commit9107d791e2eef9a1b24b0499dac8b9dbba8a792f (patch)
treef09b20f06008b094f3266b39063bc9785dfebf5f /shared/extra-utils/users/login.ts
parent4a8d113b9b57d97ff13ad1608798eabca99643e4 (diff)
downloadPeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.tar.gz
PeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.tar.zst
PeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.zip
Add external login tests
Diffstat (limited to 'shared/extra-utils/users/login.ts')
-rw-r--r--shared/extra-utils/users/login.ts23
1 files changed, 22 insertions, 1 deletions
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[]) {
95 return Promise.all(tasks) 95 return Promise.all(tasks)
96} 96}
97 97
98function loginUsingExternalToken (server: Server, username: string, externalAuthToken: string, expectedStatus = 200) {
99 const path = '/api/v1/users/token'
100
101 const body = {
102 client_id: server.client.id,
103 client_secret: server.client.secret,
104 username: username,
105 response_type: 'code',
106 grant_type: 'password',
107 scope: 'upload',
108 externalAuthToken
109 }
110
111 return request(server.url)
112 .post(path)
113 .type('form')
114 .send(body)
115 .expect(expectedStatus)
116}
117
98// --------------------------------------------------------------------------- 118// ---------------------------------------------------------------------------
99 119
100export { 120export {
@@ -107,5 +127,6 @@ export {
107 setAccessTokensToServers, 127 setAccessTokensToServers,
108 Server, 128 Server,
109 Client, 129 Client,
110 User 130 User,
131 loginUsingExternalToken
111} 132}