diff options
Diffstat (limited to 'server/tests/api/users/users-verification.ts')
-rw-r--r-- | server/tests/api/users/users-verification.ts | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index 23f81d804..ade730323 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts | |||
@@ -2,23 +2,21 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '@shared/core-utils' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |
9 | getMyUserInformation, | 9 | getMyUserInformation, |
10 | getUserInformation, | 10 | getUserInformation, |
11 | login, | 11 | MockSmtpServer, |
12 | registerUser, | 12 | registerUser, |
13 | ServerInfo, | 13 | ServerInfo, |
14 | setAccessTokensToServers, | ||
14 | updateMyUser, | 15 | updateMyUser, |
15 | userLogin, | 16 | verifyEmail, |
16 | verifyEmail | 17 | waitJobs |
17 | } from '../../../../shared/extra-utils' | 18 | } from '@shared/extra-utils' |
18 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | 19 | import { User } from '@shared/models' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
20 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' | ||
21 | import { User } from '../../../../shared/models/users' | ||
22 | 20 | ||
23 | const expect = chai.expect | 21 | const expect = chai.expect |
24 | 22 | ||
@@ -91,15 +89,15 @@ describe('Test users account verification', function () { | |||
91 | }) | 89 | }) |
92 | 90 | ||
93 | it('Should not allow login for user with unverified email', async function () { | 91 | it('Should not allow login for user with unverified email', async function () { |
94 | const resLogin = await login(server.url, server.client, user1, HttpStatusCode.BAD_REQUEST_400) | 92 | const { detail } = await server.loginCommand.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
95 | expect(resLogin.body.detail).to.contain('User email is not verified.') | 93 | expect(detail).to.contain('User email is not verified.') |
96 | }) | 94 | }) |
97 | 95 | ||
98 | it('Should verify the user via email and allow login', async function () { | 96 | it('Should verify the user via email and allow login', async function () { |
99 | await verifyEmail(server.url, userId, verificationString) | 97 | await verifyEmail(server.url, userId, verificationString) |
100 | 98 | ||
101 | const res = await login(server.url, server.client, user1) | 99 | const body = await server.loginCommand.login({ user: user1 }) |
102 | userAccessToken = res.body.access_token | 100 | userAccessToken = body.access_token |
103 | 101 | ||
104 | const resUserVerified = await getUserInformation(server.url, server.accessToken, userId) | 102 | const resUserVerified = await getUserInformation(server.url, server.accessToken, userId) |
105 | expect(resUserVerified.body.emailVerified).to.be.true | 103 | expect(resUserVerified.body.emailVerified).to.be.true |
@@ -164,7 +162,7 @@ describe('Test users account verification', function () { | |||
164 | await waitJobs(server) | 162 | await waitJobs(server) |
165 | expect(emails).to.have.lengthOf(expectedEmailsLength) | 163 | expect(emails).to.have.lengthOf(expectedEmailsLength) |
166 | 164 | ||
167 | const accessToken = await userLogin(server, user2) | 165 | const accessToken = await server.loginCommand.getAccessToken(user2) |
168 | 166 | ||
169 | const resMyUserInfo = await getMyUserInformation(server.url, accessToken) | 167 | const resMyUserInfo = await getMyUserInformation(server.url, accessToken) |
170 | expect(resMyUserInfo.body.emailVerified).to.be.null | 168 | expect(resMyUserInfo.body.emailVerified).to.be.null |
@@ -181,7 +179,7 @@ describe('Test users account verification', function () { | |||
181 | } | 179 | } |
182 | }) | 180 | }) |
183 | 181 | ||
184 | await userLogin(server, user2) | 182 | await server.loginCommand.getAccessToken(user2) |
185 | }) | 183 | }) |
186 | 184 | ||
187 | after(async function () { | 185 | after(async function () { |