aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/id-and-pass-auth.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:04:35 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit89d241a79c262b9775c233b73cff080043ebb5e6 (patch)
treecb3b6cb431d25d891ef4e02f66c61d252d17048f /server/tests/plugins/id-and-pass-auth.ts
parentd23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff)
downloadPeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip
Shorter server command names
Diffstat (limited to 'server/tests/plugins/id-and-pass-auth.ts')
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts64
1 files changed, 32 insertions, 32 deletions
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts
index 787080e7c..203996af8 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -22,12 +22,12 @@ describe('Test id and pass auth plugins', function () {
22 await setAccessTokensToServers([ server ]) 22 await setAccessTokensToServers([ server ])
23 23
24 for (const suffix of [ 'one', 'two', 'three' ]) { 24 for (const suffix of [ 'one', 'two', 'three' ]) {
25 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) }) 25 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) })
26 } 26 }
27 }) 27 })
28 28
29 it('Should display the correct configuration', async function () { 29 it('Should display the correct configuration', async function () {
30 const config = await server.configCommand.getConfig() 30 const config = await server.config.getConfig()
31 31
32 const auths = config.plugin.registeredIdAndPassAuths 32 const auths = config.plugin.registeredIdAndPassAuths
33 expect(auths).to.have.lengthOf(8) 33 expect(auths).to.have.lengthOf(8)
@@ -39,13 +39,13 @@ describe('Test id and pass auth plugins', function () {
39 }) 39 })
40 40
41 it('Should not login', async function () { 41 it('Should not login', async function () {
42 await server.loginCommand.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 42 await server.login.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
43 }) 43 })
44 44
45 it('Should login Spyro, create the user and use the token', async function () { 45 it('Should login Spyro, create the user and use the token', async function () {
46 const accessToken = await server.loginCommand.getAccessToken({ username: 'spyro', password: 'spyro password' }) 46 const accessToken = await server.login.getAccessToken({ username: 'spyro', password: 'spyro password' })
47 47
48 const body = await server.usersCommand.getMyInfo({ token: accessToken }) 48 const body = await server.users.getMyInfo({ token: accessToken })
49 49
50 expect(body.username).to.equal('spyro') 50 expect(body.username).to.equal('spyro')
51 expect(body.account.displayName).to.equal('Spyro the Dragon') 51 expect(body.account.displayName).to.equal('Spyro the Dragon')
@@ -54,13 +54,13 @@ describe('Test id and pass auth plugins', function () {
54 54
55 it('Should login Crash, create the user and use the token', async function () { 55 it('Should login Crash, create the user and use the token', async function () {
56 { 56 {
57 const body = await server.loginCommand.login({ user: { username: 'crash', password: 'crash password' } }) 57 const body = await server.login.login({ user: { username: 'crash', password: 'crash password' } })
58 crashAccessToken = body.access_token 58 crashAccessToken = body.access_token
59 crashRefreshToken = body.refresh_token 59 crashRefreshToken = body.refresh_token
60 } 60 }
61 61
62 { 62 {
63 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 63 const body = await server.users.getMyInfo({ token: crashAccessToken })
64 64
65 expect(body.username).to.equal('crash') 65 expect(body.username).to.equal('crash')
66 expect(body.account.displayName).to.equal('Crash Bandicoot') 66 expect(body.account.displayName).to.equal('Crash Bandicoot')
@@ -70,13 +70,13 @@ describe('Test id and pass auth plugins', function () {
70 70
71 it('Should login the first Laguna, create the user and use the token', async function () { 71 it('Should login the first Laguna, create the user and use the token', async function () {
72 { 72 {
73 const body = await server.loginCommand.login({ user: { username: 'laguna', password: 'laguna password' } }) 73 const body = await server.login.login({ user: { username: 'laguna', password: 'laguna password' } })
74 lagunaAccessToken = body.access_token 74 lagunaAccessToken = body.access_token
75 lagunaRefreshToken = body.refresh_token 75 lagunaRefreshToken = body.refresh_token
76 } 76 }
77 77
78 { 78 {
79 const body = await server.usersCommand.getMyInfo({ token: lagunaAccessToken }) 79 const body = await server.users.getMyInfo({ token: lagunaAccessToken })
80 80
81 expect(body.username).to.equal('laguna') 81 expect(body.username).to.equal('laguna')
82 expect(body.account.displayName).to.equal('laguna') 82 expect(body.account.displayName).to.equal('laguna')
@@ -86,46 +86,46 @@ describe('Test id and pass auth plugins', function () {
86 86
87 it('Should refresh crash token, but not laguna token', async function () { 87 it('Should refresh crash token, but not laguna token', async function () {
88 { 88 {
89 const resRefresh = await server.loginCommand.refreshToken({ refreshToken: crashRefreshToken }) 89 const resRefresh = await server.login.refreshToken({ refreshToken: crashRefreshToken })
90 crashAccessToken = resRefresh.body.access_token 90 crashAccessToken = resRefresh.body.access_token
91 crashRefreshToken = resRefresh.body.refresh_token 91 crashRefreshToken = resRefresh.body.refresh_token
92 92
93 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 93 const body = await server.users.getMyInfo({ token: crashAccessToken })
94 expect(body.username).to.equal('crash') 94 expect(body.username).to.equal('crash')
95 } 95 }
96 96
97 { 97 {
98 await server.loginCommand.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 98 await server.login.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
99 } 99 }
100 }) 100 })
101 101
102 it('Should update Crash profile', async function () { 102 it('Should update Crash profile', async function () {
103 await server.usersCommand.updateMe({ 103 await server.users.updateMe({
104 token: crashAccessToken, 104 token: crashAccessToken,
105 displayName: 'Beautiful Crash', 105 displayName: 'Beautiful Crash',
106 description: 'Mutant eastern barred bandicoot' 106 description: 'Mutant eastern barred bandicoot'
107 }) 107 })
108 108
109 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 109 const body = await server.users.getMyInfo({ token: crashAccessToken })
110 110
111 expect(body.account.displayName).to.equal('Beautiful Crash') 111 expect(body.account.displayName).to.equal('Beautiful Crash')
112 expect(body.account.description).to.equal('Mutant eastern barred bandicoot') 112 expect(body.account.description).to.equal('Mutant eastern barred bandicoot')
113 }) 113 })
114 114
115 it('Should logout Crash', async function () { 115 it('Should logout Crash', async function () {
116 await server.loginCommand.logout({ token: crashAccessToken }) 116 await server.login.logout({ token: crashAccessToken })
117 }) 117 })
118 118
119 it('Should have logged out Crash', async function () { 119 it('Should have logged out Crash', async function () {
120 await server.serversCommand.waitUntilLog('On logout for auth 1 - 2') 120 await server.servers.waitUntilLog('On logout for auth 1 - 2')
121 121
122 await server.usersCommand.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 122 await server.users.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
123 }) 123 })
124 124
125 it('Should login Crash and keep the old existing profile', async function () { 125 it('Should login Crash and keep the old existing profile', async function () {
126 crashAccessToken = await server.loginCommand.getAccessToken({ username: 'crash', password: 'crash password' }) 126 crashAccessToken = await server.login.getAccessToken({ username: 'crash', password: 'crash password' })
127 127
128 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 128 const body = await server.users.getMyInfo({ token: crashAccessToken })
129 129
130 expect(body.username).to.equal('crash') 130 expect(body.username).to.equal('crash')
131 expect(body.account.displayName).to.equal('Beautiful Crash') 131 expect(body.account.displayName).to.equal('Beautiful Crash')
@@ -138,38 +138,38 @@ describe('Test id and pass auth plugins', function () {
138 138
139 await wait(5000) 139 await wait(5000)
140 140
141 await server.usersCommand.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 141 await server.users.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
142 }) 142 })
143 143
144 it('Should reject an invalid username, email, role or display name', async function () { 144 it('Should reject an invalid username, email, role or display name', async function () {
145 const command = server.loginCommand 145 const command = server.login
146 146
147 await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 147 await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
148 await server.serversCommand.waitUntilLog('valid username') 148 await server.servers.waitUntilLog('valid username')
149 149
150 await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 150 await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
151 await server.serversCommand.waitUntilLog('valid display name') 151 await server.servers.waitUntilLog('valid display name')
152 152
153 await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 153 await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
154 await server.serversCommand.waitUntilLog('valid role') 154 await server.servers.waitUntilLog('valid role')
155 155
156 await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 156 await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
157 await server.serversCommand.waitUntilLog('valid email') 157 await server.servers.waitUntilLog('valid email')
158 }) 158 })
159 159
160 it('Should unregister spyro-auth and do not login existing Spyro', async function () { 160 it('Should unregister spyro-auth and do not login existing Spyro', async function () {
161 await server.pluginsCommand.updateSettings({ 161 await server.plugins.updateSettings({
162 npmName: 'peertube-plugin-test-id-pass-auth-one', 162 npmName: 'peertube-plugin-test-id-pass-auth-one',
163 settings: { disableSpyro: true } 163 settings: { disableSpyro: true }
164 }) 164 })
165 165
166 const command = server.loginCommand 166 const command = server.login
167 await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 167 await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
168 await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 168 await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
169 }) 169 })
170 170
171 it('Should have disabled this auth', async function () { 171 it('Should have disabled this auth', async function () {
172 const config = await server.configCommand.getConfig() 172 const config = await server.config.getConfig()
173 173
174 const auths = config.plugin.registeredIdAndPassAuths 174 const auths = config.plugin.registeredIdAndPassAuths
175 expect(auths).to.have.lengthOf(7) 175 expect(auths).to.have.lengthOf(7)
@@ -179,16 +179,16 @@ describe('Test id and pass auth plugins', function () {
179 }) 179 })
180 180
181 it('Should uninstall the plugin one and do not login existing Crash', async function () { 181 it('Should uninstall the plugin one and do not login existing Crash', async function () {
182 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' }) 182 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
183 183
184 await server.loginCommand.login({ 184 await server.login.login({
185 user: { username: 'crash', password: 'crash password' }, 185 user: { username: 'crash', password: 'crash password' },
186 expectedStatus: HttpStatusCode.BAD_REQUEST_400 186 expectedStatus: HttpStatusCode.BAD_REQUEST_400
187 }) 187 })
188 }) 188 })
189 189
190 it('Should display the correct configuration', async function () { 190 it('Should display the correct configuration', async function () {
191 const config = await server.configCommand.getConfig() 191 const config = await server.config.getConfig()
192 192
193 const auths = config.plugin.registeredIdAndPassAuths 193 const auths = config.plugin.registeredIdAndPassAuths
194 expect(auths).to.have.lengthOf(6) 194 expect(auths).to.have.lengthOf(6)
@@ -198,7 +198,7 @@ describe('Test id and pass auth plugins', function () {
198 }) 198 })
199 199
200 it('Should display plugin auth information in users list', async function () { 200 it('Should display plugin auth information in users list', async function () {
201 const { data } = await server.usersCommand.list() 201 const { data } = await server.users.list()
202 202
203 const root = data.find(u => u.username === 'root') 203 const root = data.find(u => u.username === 'root')
204 const crash = data.find(u => u.username === 'crash') 204 const crash = data.find(u => u.username === 'crash')