Introduce login command
This commit is contained in:
parent
6c5065a011
commit
41d1d07501
|
@ -11,7 +11,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { Video } from '../../../../shared/models/videos'
|
import { Video } from '../../../../shared/models/videos'
|
||||||
|
@ -36,7 +35,7 @@ describe('Test ActivityPub fetcher', function () {
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
}
|
}
|
||||||
|
|
||||||
const userAccessToken = await userLogin(servers[0], user)
|
const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' })
|
await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' })
|
||||||
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' })
|
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' })
|
||||||
|
|
|
@ -18,7 +18,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { AbuseCreate, AbuseState } from '@shared/models'
|
import { AbuseCreate, AbuseState } from '@shared/models'
|
||||||
|
@ -47,7 +46,7 @@ describe('Test abuses API validators', function () {
|
||||||
const username = 'user1'
|
const username = 'user1'
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
||||||
userToken = await userLogin(server, { username, password })
|
userToken = await server.loginCommand.getAccessToken({ username, password })
|
||||||
|
|
||||||
userToken2 = await generateUserAccessToken(server, 'user_2')
|
userToken2 = await generateUserAccessToken(server, 'user_2')
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ import {
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
checkBadCountPagination,
|
checkBadCountPagination,
|
||||||
|
@ -37,7 +36,7 @@ describe('Test blocklist API validators', function () {
|
||||||
const user = { username: 'user1', password: 'password' }
|
const user = { username: 'user1', password: 'password' }
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[0], servers[1])
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,8 +6,7 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
|
import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
|
@ -27,7 +26,7 @@ describe('Test bulk API validators', function () {
|
||||||
const user = { username: 'user1', password: 'password' }
|
const user = { username: 'user1', password: 'password' }
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When removing comments of', function () {
|
describe('When removing comments of', function () {
|
||||||
|
|
|
@ -11,8 +11,7 @@ import {
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { CustomConfig } from '@shared/models'
|
import { CustomConfig } from '@shared/models'
|
||||||
|
|
||||||
|
@ -208,7 +207,7 @@ describe('Test config API validators', function () {
|
||||||
password: 'password'
|
password: 'password'
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When getting the configuration', function () {
|
describe('When getting the configuration', function () {
|
||||||
|
|
|
@ -7,8 +7,7 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests'
|
import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests'
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ describe('Test custom pages validators', function () {
|
||||||
const user = { username: 'user1', password: 'password' }
|
const user = { username: 'user1', password: 'password' }
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When updating instance homepage', function () {
|
describe('When updating instance homepage', function () {
|
||||||
|
|
|
@ -7,8 +7,7 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
|
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
|
@ -32,7 +31,7 @@ describe('Test debug API validators', function () {
|
||||||
password: 'my super password'
|
password: 'my super password'
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When getting debug endpoint', function () {
|
describe('When getting debug endpoint', function () {
|
||||||
|
|
|
@ -9,8 +9,7 @@ import {
|
||||||
makeDeleteRequest, makeGetRequest,
|
makeDeleteRequest, makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
checkBadCountPagination,
|
checkBadCountPagination,
|
||||||
|
@ -42,7 +41,7 @@ describe('Test server follows API validators', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When adding follows', function () {
|
describe('When adding follows', function () {
|
||||||
|
|
|
@ -7,8 +7,7 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
checkBadCountPagination,
|
checkBadCountPagination,
|
||||||
|
@ -37,7 +36,7 @@ describe('Test jobs API validators', function () {
|
||||||
password: 'my super password'
|
password: 'my super password'
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When listing jobs', function () {
|
describe('When listing jobs', function () {
|
||||||
|
|
|
@ -17,8 +17,7 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
stopFfmpeg,
|
stopFfmpeg,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
|
|
||||||
describe('Test video lives API validator', function () {
|
describe('Test video lives API validator', function () {
|
||||||
|
@ -53,7 +52,7 @@ describe('Test video lives API validator', function () {
|
||||||
const username = 'user1'
|
const username = 'user1'
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
||||||
userAccessToken = await userLogin(server, { username, password })
|
userAccessToken = await server.loginCommand.getAccessToken({ username, password })
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getMyUserInformation(server.url, server.accessToken)
|
const res = await getMyUserInformation(server.url, server.accessToken)
|
||||||
|
@ -150,7 +149,7 @@ describe('Test video lives API validator', function () {
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
const accessTokenUser = await userLogin(server, user)
|
const accessTokenUser = await server.loginCommand.getAccessToken(user)
|
||||||
const res = await getMyUserInformation(server.url, accessTokenUser)
|
const res = await getMyUserInformation(server.url, accessTokenUser)
|
||||||
const customChannelId = res.body.videoChannels[0].id
|
const customChannelId = res.body.videoChannels[0].id
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
|
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
|
@ -32,7 +31,7 @@ describe('Test logs API validators', function () {
|
||||||
password: 'my super password'
|
password: 'my super password'
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When getting logs', function () {
|
describe('When getting logs', function () {
|
||||||
|
|
|
@ -13,8 +13,7 @@ import {
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { PeerTubePlugin, PluginType } from '@shared/models'
|
import { PeerTubePlugin, PluginType } from '@shared/models'
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ describe('Test server plugins API validators', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await server.pluginsCommand.install({ npmName: npmPlugin })
|
const res = await server.pluginsCommand.install({ npmName: npmPlugin })
|
||||||
|
|
|
@ -19,7 +19,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ describe('Test server redundancy API validators', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(servers[0], user)
|
userAccessToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
videoIdLocal = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video' })).id
|
videoIdLocal = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video' })).id
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
setDefaultVideoChannel,
|
setDefaultVideoChannel,
|
||||||
updateUser,
|
updateUser,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ describe('Test upload quota', function () {
|
||||||
|
|
||||||
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
|
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
|
||||||
await registerUser(server.url, user.username, user.password)
|
await registerUser(server.url, user.username, user.password)
|
||||||
const userAccessToken = await userLogin(server, user)
|
const userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const videoAttributes = { fixture: 'video_short2.webm' }
|
const videoAttributes = { fixture: 'video_short2.webm' }
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
|
@ -65,7 +64,7 @@ describe('Test upload quota', function () {
|
||||||
|
|
||||||
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
|
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
|
||||||
await registerUser(server.url, user.username, user.password)
|
await registerUser(server.url, user.username, user.password)
|
||||||
const userAccessToken = await userLogin(server, user)
|
const userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const videoAttributes = { fixture: 'video_short2.webm' }
|
const videoAttributes = { fixture: 'video_short2.webm' }
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
|
|
|
@ -10,8 +10,7 @@ import {
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -41,7 +40,7 @@ describe('Test user subscriptions API validators', function () {
|
||||||
password: 'my super password'
|
password: 'my super password'
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When listing my subscriptions', function () {
|
describe('When listing my subscriptions', function () {
|
||||||
|
|
|
@ -27,8 +27,7 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
unblockUser,
|
unblockUser,
|
||||||
uploadVideo,
|
uploadVideo
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
|
import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
|
||||||
import {
|
import {
|
||||||
|
@ -87,7 +86,7 @@ describe('Test users API validators', function () {
|
||||||
password: user.password,
|
password: user.password,
|
||||||
videoQuota: videoQuota
|
videoQuota: videoQuota
|
||||||
})
|
})
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -104,7 +103,7 @@ describe('Test users API validators', function () {
|
||||||
role: UserRole.MODERATOR
|
role: UserRole.MODERATOR
|
||||||
})
|
})
|
||||||
|
|
||||||
moderatorAccessToken = await userLogin(server, moderator)
|
moderatorAccessToken = await server.loginCommand.getAccessToken(moderator)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -394,7 +393,7 @@ describe('Test users API validators', function () {
|
||||||
username: 'user1',
|
username: 'user1',
|
||||||
password: 'my super password'
|
password: 'my super password'
|
||||||
}
|
}
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
username: 'user3',
|
username: 'user3',
|
||||||
|
|
|
@ -19,7 +19,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoBlacklistType, VideoDetails } from '@shared/models'
|
import { VideoBlacklistType, VideoDetails } from '@shared/models'
|
||||||
|
@ -46,14 +45,14 @@ describe('Test video blacklist API validators', function () {
|
||||||
const username = 'user1'
|
const username = 'user1'
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password })
|
||||||
userAccessToken1 = await userLogin(servers[0], { username, password })
|
userAccessToken1 = await servers[0].loginCommand.getAccessToken({ username, password })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const username = 'user2'
|
const username = 'user2'
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password })
|
||||||
userAccessToken2 = await userLogin(servers[0], { username, password })
|
userAccessToken2 = await servers[0].loginCommand.getAccessToken({ username, password })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,8 +12,7 @@ import {
|
||||||
makeUploadRequest,
|
makeUploadRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo
|
||||||
userLogin
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoCreateResult } from '@shared/models'
|
import { VideoCreateResult } from '@shared/models'
|
||||||
|
|
||||||
|
@ -44,7 +43,7 @@ describe('Test video captions API validator', function () {
|
||||||
password: 'my super password'
|
password: 'my super password'
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@ import {
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
makeUploadRequest,
|
makeUploadRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoChannelUpdate } from '@shared/models'
|
import { VideoChannelUpdate } from '@shared/models'
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ describe('Test video channels API validator', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
accessTokenUser = await userLogin(server, user)
|
accessTokenUser = await server.loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
command = server.channelsCommand
|
command = server.channelsCommand
|
||||||
|
|
|
@ -15,8 +15,7 @@ import {
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo
|
||||||
userLogin
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoCreateResult } from '@shared/models'
|
import { VideoCreateResult } from '@shared/models'
|
||||||
|
|
||||||
|
@ -55,13 +54,13 @@ describe('Test video comments API validator', function () {
|
||||||
{
|
{
|
||||||
const user = { username: 'user1', password: 'my super password' }
|
const user = { username: 'user1', password: 'my super password' }
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const user = { username: 'user2', password: 'my super password' }
|
const user = { username: 'user2', password: 'my super password' }
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken2 = await userLogin(server, user)
|
userAccessToken2 = await server.loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@ import {
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
makeUploadRequest,
|
makeUploadRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoPrivacy } from '@shared/models'
|
import { VideoPrivacy } from '@shared/models'
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ describe('Test video imports API validator', function () {
|
||||||
const username = 'user1'
|
const username = 'user1'
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
||||||
userAccessToken = await userLogin(server, { username, password })
|
userAccessToken = await server.loginCommand.getAccessToken({ username, password })
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getMyUserInformation(server.url, server.accessToken)
|
const res = await getMyUserInformation(server.url, server.accessToken)
|
||||||
|
@ -167,7 +166,7 @@ describe('Test video imports API validator', function () {
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
const accessTokenUser = await userLogin(server, user)
|
const accessTokenUser = await server.loginCommand.getAccessToken(user)
|
||||||
const res = await getMyUserInformation(server.url, accessTokenUser)
|
const res = await getMyUserInformation(server.url, accessTokenUser)
|
||||||
const customChannelId = res.body.videoChannels[0].id
|
const customChannelId = res.body.videoChannels[0].id
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@ import {
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
setDefaultVideoChannel,
|
setDefaultVideoChannel
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { UserRole } from '../../../../shared/models/users'
|
import { UserRole } from '../../../../shared/models/users'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
|
@ -52,7 +51,7 @@ describe('Test video filters validators', function () {
|
||||||
|
|
||||||
const user = { username: 'user1', password: 'my super password' }
|
const user = { username: 'user1', password: 'my super password' }
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const moderator = { username: 'moderator', password: 'my super password' }
|
const moderator = { username: 'moderator', password: 'my super password' }
|
||||||
await createUser(
|
await createUser(
|
||||||
|
@ -66,7 +65,7 @@ describe('Test video filters validators', function () {
|
||||||
role: UserRole.MODERATOR
|
role: UserRole.MODERATOR
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
moderatorAccessToken = await userLogin(server, moderator)
|
moderatorAccessToken = await server.loginCommand.getAccessToken(moderator)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When setting a video filter', function () {
|
describe('When setting a video filter', function () {
|
||||||
|
|
|
@ -22,8 +22,7 @@ import {
|
||||||
removeVideo,
|
removeVideo,
|
||||||
root,
|
root,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
checkBadCountPagination,
|
checkBadCountPagination,
|
||||||
|
@ -55,7 +54,7 @@ describe('Test videos API validator', function () {
|
||||||
const username = 'user1'
|
const username = 'user1'
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
||||||
userAccessToken = await userLogin(server, { username, password })
|
userAccessToken = await server.loginCommand.getAccessToken({ username, password })
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getMyUserInformation(server.url, server.accessToken)
|
const res = await getMyUserInformation(server.url, server.accessToken)
|
||||||
|
@ -286,7 +285,7 @@ describe('Test videos API validator', function () {
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
const accessTokenUser = await userLogin(server, user)
|
const accessTokenUser = await server.loginCommand.getAccessToken(user)
|
||||||
const res = await getMyUserInformation(server.url, accessTokenUser)
|
const res = await getMyUserInformation(server.url, accessTokenUser)
|
||||||
const customChannelId = res.body.videoChannels[0].id
|
const customChannelId = res.body.videoChannels[0].id
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models'
|
import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models'
|
||||||
|
@ -280,7 +279,7 @@ describe('Test abuses', function () {
|
||||||
// register a second user to have two reporters/reportees
|
// register a second user to have two reporters/reportees
|
||||||
const user = { username: 'user2', password: 'password' }
|
const user = { username: 'user2', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user })
|
||||||
const userAccessToken = await userLogin(servers[0], user)
|
const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
// upload a third video via this user
|
// upload a third video via this user
|
||||||
const video3Attributes = {
|
const video3Attributes = {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { UserNotificationType } from '@shared/models'
|
import { UserNotificationType } from '@shared/models'
|
||||||
|
@ -86,7 +85,7 @@ describe('Test blocklist', function () {
|
||||||
videoQuotaDaily: -1
|
videoQuotaDaily: -1
|
||||||
})
|
})
|
||||||
|
|
||||||
userToken1 = await userLogin(servers[0], user)
|
userToken1 = await servers[0].loginCommand.getAccessToken(user)
|
||||||
await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
|
await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,14 +93,14 @@ describe('Test blocklist', function () {
|
||||||
const user = { username: 'user2', password: 'password' }
|
const user = { username: 'user2', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
userToken2 = await userLogin(servers[0], user)
|
userToken2 = await servers[0].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const user = { username: 'user3', password: 'password' }
|
const user = { username: 'user3', password: 'password' }
|
||||||
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
remoteUserToken = await userLogin(servers[1], user)
|
remoteUserToken = await servers[1].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[0], servers[1])
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { UserNotificationType, Video } from '@shared/models'
|
import { UserNotificationType, Video } from '@shared/models'
|
||||||
|
@ -94,7 +93,7 @@ describe('Test blocklist', function () {
|
||||||
const user = { username: 'user1', password: 'password' }
|
const user = { username: 'user1', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
userToken1 = await userLogin(servers[0], user)
|
userToken1 = await servers[0].loginCommand.getAccessToken(user)
|
||||||
await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
|
await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,14 +101,14 @@ describe('Test blocklist', function () {
|
||||||
const user = { username: 'moderator', password: 'password' }
|
const user = { username: 'moderator', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
userModeratorToken = await userLogin(servers[0], user)
|
userModeratorToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const user = { username: 'user2', password: 'password' }
|
const user = { username: 'user2', password: 'password' }
|
||||||
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
userToken2 = await userLogin(servers[1], user)
|
userToken2 = await servers[1].loginCommand.getAccessToken(user)
|
||||||
await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
|
await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { User, UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
|
import { User, UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
|
||||||
|
@ -366,7 +365,7 @@ describe('Test video blacklist', function () {
|
||||||
role: UserRole.USER
|
role: UserRole.USER
|
||||||
})
|
})
|
||||||
|
|
||||||
userWithoutFlag = await userLogin(servers[0], user)
|
userWithoutFlag = await servers[0].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const res = await getMyUserInformation(servers[0].url, userWithoutFlag)
|
const res = await getMyUserInformation(servers[0].url, userWithoutFlag)
|
||||||
const body: User = res.body
|
const body: User = res.body
|
||||||
|
@ -384,7 +383,7 @@ describe('Test video blacklist', function () {
|
||||||
role: UserRole.USER
|
role: UserRole.USER
|
||||||
})
|
})
|
||||||
|
|
||||||
userWithFlag = await userLogin(servers[0], user)
|
userWithFlag = await servers[0].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
wait,
|
wait,
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
|
@ -47,7 +46,7 @@ describe('Test ActivityPub video channels search', function () {
|
||||||
{
|
{
|
||||||
const user = { username: 'user1_server2', password: 'password' }
|
const user = { username: 'user1_server2', password: 'password' }
|
||||||
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
||||||
userServer2Token = await userLogin(servers[1], user)
|
userServer2Token = await servers[1].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const channel = {
|
const channel = {
|
||||||
name: 'channel1_server2',
|
name: 'channel1_server2',
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { Video } from '@shared/models'
|
|
||||||
import {
|
import {
|
||||||
BulkCommand,
|
BulkCommand,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -13,9 +12,9 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '../../../../shared/extra-utils/index'
|
} from '@shared/extra-utils'
|
||||||
|
import { Video } from '@shared/models'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -41,21 +40,21 @@ describe('Test bulk actions', function () {
|
||||||
const user = { username: 'user1', password: 'password' }
|
const user = { username: 'user1', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
user1Token = await userLogin(servers[0], user)
|
user1Token = await servers[0].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const user = { username: 'user2', password: 'password' }
|
const user = { username: 'user2', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
user2Token = await userLogin(servers[0], user)
|
user2Token = await servers[0].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const user = { username: 'user3', password: 'password' }
|
const user = { username: 'user3', password: 'password' }
|
||||||
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
user3Token = await userLogin(servers[1], user)
|
user3Token = await servers[1].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[0], servers[1])
|
||||||
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
unblockUser,
|
unblockUser,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
verifyEmail
|
verifyEmail
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
|
import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
|
||||||
|
@ -62,7 +61,7 @@ describe('Test emails', function () {
|
||||||
const res = await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
const res = await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userId = res.body.user.id
|
userId = res.body.user.id
|
||||||
|
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -128,7 +127,7 @@ describe('Test emails', function () {
|
||||||
it('Should login with this new password', async function () {
|
it('Should login with this new password', async function () {
|
||||||
user.password = 'super_password2'
|
user.password = 'super_password2'
|
||||||
|
|
||||||
await userLogin(server, user)
|
await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -175,7 +174,7 @@ describe('Test emails', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should login with this new password', async function () {
|
it('Should login with this new password', async function () {
|
||||||
await userLogin(server, {
|
await server.loginCommand.getAccessToken({
|
||||||
username: 'create_password',
|
username: 'create_password',
|
||||||
password: 'newly_created_password'
|
password: 'newly_created_password'
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,8 +15,7 @@ import {
|
||||||
getVideoWithToken,
|
getVideoWithToken,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
@ -49,7 +48,7 @@ describe('Test follow constraints', function () {
|
||||||
password: 'super_password'
|
password: 'super_password'
|
||||||
}
|
}
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(servers[0], user)
|
userAccessToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[0], servers[1])
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
testCaptionFile,
|
testCaptionFile,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { Video, VideoPrivacy } from '@shared/models'
|
import { Video, VideoPrivacy } from '@shared/models'
|
||||||
|
@ -330,7 +329,7 @@ describe('Test follows', function () {
|
||||||
{
|
{
|
||||||
const user = { username: 'captain', password: 'password' }
|
const user = { username: 'captain', password: 'password' }
|
||||||
await createUser({ url: servers[2].url, accessToken: servers[2].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[2].url, accessToken: servers[2].accessToken, username: user.username, password: user.password })
|
||||||
const userAccessToken = await userLogin(servers[2], user)
|
const userAccessToken = await servers[2].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const resVideos = await getVideosList(servers[2].url)
|
const resVideos = await getVideosList(servers[2].url)
|
||||||
video4 = resVideos.body.data.find(v => v.name === 'server3-4')
|
video4 = resVideos.body.data.find(v => v.name === 'server3-4')
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import { expect } from 'chai'
|
||||||
import * as chai from 'chai'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { cleanupTests, getVideo, registerUser, uploadVideo, userLogin, viewVideo, wait } from '../../../../shared/extra-utils'
|
import {
|
||||||
import { flushAndRunServer, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
|
cleanupTests,
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
flushAndRunServer,
|
||||||
|
getVideo,
|
||||||
const expect = chai.expect
|
registerUser,
|
||||||
|
setAccessTokensToServers,
|
||||||
|
uploadVideo,
|
||||||
|
viewVideo,
|
||||||
|
wait
|
||||||
|
} from '@shared/extra-utils'
|
||||||
|
|
||||||
describe('Test application behind a reverse proxy', function () {
|
describe('Test application behind a reverse proxy', function () {
|
||||||
let server = null
|
let server = null
|
||||||
|
@ -97,10 +102,10 @@ describe('Test application behind a reverse proxy', function () {
|
||||||
const user = { username: 'root', password: 'fail' }
|
const user = { username: 'root', password: 'fail' }
|
||||||
|
|
||||||
for (let i = 0; i < 19; i++) {
|
for (let i = 0; i < 19; i++) {
|
||||||
await userLogin(server, user, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.getAccessToken(user, HttpStatusCode.BAD_REQUEST_400)
|
||||||
}
|
}
|
||||||
|
|
||||||
await userLogin(server, user, HttpStatusCode.TOO_MANY_REQUESTS_429)
|
await server.loginCommand.getAccessToken(user, HttpStatusCode.TOO_MANY_REQUESTS_429)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should rate limit signup', async function () {
|
it('Should rate limit signup', async function () {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
viewVideo,
|
viewVideo,
|
||||||
wait,
|
wait,
|
||||||
waitJobs
|
waitJobs
|
||||||
|
@ -119,7 +118,7 @@ describe('Test stats (excluding redundancy)', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
await userLogin(server, user)
|
await server.loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const data = await server.statsCommand.get()
|
const data = await server.statsCommand.get()
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
SubscriptionsCommand,
|
SubscriptionsCommand,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ describe('Test users subscriptions', function () {
|
||||||
const user = { username: 'user' + server.serverNumber, password: 'password' }
|
const user = { username: 'user' + server.serverNumber, password: 'password' }
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
const accessToken = await userLogin(server, user)
|
const accessToken = await server.loginCommand.getAccessToken(user)
|
||||||
users.push({ accessToken })
|
users.push({ accessToken })
|
||||||
|
|
||||||
const videoName1 = 'video 1-' + server.serverNumber
|
const videoName1 = 'video 1-' + server.serverNumber
|
||||||
|
|
|
@ -19,7 +19,6 @@ import {
|
||||||
updateMyAvatar,
|
updateMyAvatar,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { User } from '@shared/models'
|
import { User } from '@shared/models'
|
||||||
|
@ -64,7 +63,7 @@ describe('Test users with multiple servers', function () {
|
||||||
password: user.password
|
password: user.password
|
||||||
})
|
})
|
||||||
userId = res.body.user.id
|
userId = res.body.user.id
|
||||||
userAccessToken = await userLogin(servers[0], user)
|
userAccessToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,23 +2,21 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
getUserInformation,
|
getUserInformation,
|
||||||
login,
|
MockSmtpServer,
|
||||||
registerUser,
|
registerUser,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
setAccessTokensToServers,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
userLogin,
|
verifyEmail,
|
||||||
verifyEmail
|
waitJobs
|
||||||
} from '../../../../shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
|
import { User } from '@shared/models'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
|
||||||
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
|
|
||||||
import { User } from '../../../../shared/models/users'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -91,15 +89,15 @@ describe('Test users account verification', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not allow login for user with unverified email', async function () {
|
it('Should not allow login for user with unverified email', async function () {
|
||||||
const resLogin = await login(server.url, server.client, user1, HttpStatusCode.BAD_REQUEST_400)
|
const { detail } = await server.loginCommand.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
expect(resLogin.body.detail).to.contain('User email is not verified.')
|
expect(detail).to.contain('User email is not verified.')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should verify the user via email and allow login', async function () {
|
it('Should verify the user via email and allow login', async function () {
|
||||||
await verifyEmail(server.url, userId, verificationString)
|
await verifyEmail(server.url, userId, verificationString)
|
||||||
|
|
||||||
const res = await login(server.url, server.client, user1)
|
const body = await server.loginCommand.login({ user: user1 })
|
||||||
userAccessToken = res.body.access_token
|
userAccessToken = body.access_token
|
||||||
|
|
||||||
const resUserVerified = await getUserInformation(server.url, server.accessToken, userId)
|
const resUserVerified = await getUserInformation(server.url, server.accessToken, userId)
|
||||||
expect(resUserVerified.body.emailVerified).to.be.true
|
expect(resUserVerified.body.emailVerified).to.be.true
|
||||||
|
@ -164,7 +162,7 @@ describe('Test users account verification', function () {
|
||||||
await waitJobs(server)
|
await waitJobs(server)
|
||||||
expect(emails).to.have.lengthOf(expectedEmailsLength)
|
expect(emails).to.have.lengthOf(expectedEmailsLength)
|
||||||
|
|
||||||
const accessToken = await userLogin(server, user2)
|
const accessToken = await server.loginCommand.getAccessToken(user2)
|
||||||
|
|
||||||
const resMyUserInfo = await getMyUserInformation(server.url, accessToken)
|
const resMyUserInfo = await getMyUserInformation(server.url, accessToken)
|
||||||
expect(resMyUserInfo.body.emailVerified).to.be.null
|
expect(resMyUserInfo.body.emailVerified).to.be.null
|
||||||
|
@ -181,7 +179,7 @@ describe('Test users account verification', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await userLogin(server, user2)
|
await server.loginCommand.getAccessToken(user2)
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -18,11 +18,8 @@ import {
|
||||||
getUsersListPaginationAndSort,
|
getUsersListPaginationAndSort,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
killallServers,
|
killallServers,
|
||||||
login,
|
|
||||||
logout,
|
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
rateVideo,
|
rateVideo,
|
||||||
refreshToken,
|
|
||||||
registerUserWithChannel,
|
registerUserWithChannel,
|
||||||
removeUser,
|
removeUser,
|
||||||
removeVideo,
|
removeVideo,
|
||||||
|
@ -35,7 +32,6 @@ import {
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
updateUser,
|
updateUser,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { AbuseState, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
|
import { AbuseState, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
|
||||||
|
@ -78,22 +74,22 @@ describe('Test users', function () {
|
||||||
|
|
||||||
it('Should not login with an invalid client id', async function () {
|
it('Should not login with an invalid client id', async function () {
|
||||||
const client = { id: 'client', secret: server.client.secret }
|
const client = { id: 'client', secret: server.client.secret }
|
||||||
const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400)
|
const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
|
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
|
||||||
expect(res.body.error).to.contain('client is invalid')
|
expect(body.error).to.contain('client is invalid')
|
||||||
expect(res.body.type.startsWith('https://')).to.be.true
|
expect(body.type.startsWith('https://')).to.be.true
|
||||||
expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT)
|
expect(body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login with an invalid client secret', async function () {
|
it('Should not login with an invalid client secret', async function () {
|
||||||
const client = { id: server.client.id, secret: 'coucou' }
|
const client = { id: server.client.id, secret: 'coucou' }
|
||||||
const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400)
|
const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
|
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
|
||||||
expect(res.body.error).to.contain('client is invalid')
|
expect(body.error).to.contain('client is invalid')
|
||||||
expect(res.body.type.startsWith('https://')).to.be.true
|
expect(body.type.startsWith('https://')).to.be.true
|
||||||
expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT)
|
expect(body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -101,22 +97,22 @@ describe('Test users', function () {
|
||||||
|
|
||||||
it('Should not login with an invalid username', async function () {
|
it('Should not login with an invalid username', async function () {
|
||||||
const user = { username: 'captain crochet', password: server.user.password }
|
const user = { username: 'captain crochet', password: server.user.password }
|
||||||
const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400)
|
const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
|
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
|
||||||
expect(res.body.error).to.contain('credentials are invalid')
|
expect(body.error).to.contain('credentials are invalid')
|
||||||
expect(res.body.type.startsWith('https://')).to.be.true
|
expect(body.type.startsWith('https://')).to.be.true
|
||||||
expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT)
|
expect(body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login with an invalid password', async function () {
|
it('Should not login with an invalid password', async function () {
|
||||||
const user = { username: server.user.username, password: 'mew_three' }
|
const user = { username: server.user.username, password: 'mew_three' }
|
||||||
const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400)
|
const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
|
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
|
||||||
expect(res.body.error).to.contain('credentials are invalid')
|
expect(body.error).to.contain('credentials are invalid')
|
||||||
expect(res.body.type.startsWith('https://')).to.be.true
|
expect(body.type.startsWith('https://')).to.be.true
|
||||||
expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT)
|
expect(body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be able to upload a video', async function () {
|
it('Should not be able to upload a video', async function () {
|
||||||
|
@ -139,20 +135,20 @@ describe('Test users', function () {
|
||||||
it('Should not be able to unfollow')
|
it('Should not be able to unfollow')
|
||||||
|
|
||||||
it('Should be able to login', async function () {
|
it('Should be able to login', async function () {
|
||||||
const res = await login(server.url, server.client, server.user, HttpStatusCode.OK_200)
|
const body = await server.loginCommand.login({ expectedStatus: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
accessToken = res.body.access_token
|
accessToken = body.access_token
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to login with an insensitive username', async function () {
|
it('Should be able to login with an insensitive username', async function () {
|
||||||
const user = { username: 'RoOt', password: server.user.password }
|
const user = { username: 'RoOt', password: server.user.password }
|
||||||
await login(server.url, server.client, user, HttpStatusCode.OK_200)
|
await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const user2 = { username: 'rOoT', password: server.user.password }
|
const user2 = { username: 'rOoT', password: server.user.password }
|
||||||
await login(server.url, server.client, user2, HttpStatusCode.OK_200)
|
await server.loginCommand.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const user3 = { username: 'ROOt', password: server.user.password }
|
const user3 = { username: 'ROOt', password: server.user.password }
|
||||||
await login(server.url, server.client, user3, HttpStatusCode.OK_200)
|
await server.loginCommand.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -222,7 +218,7 @@ describe('Test users', function () {
|
||||||
|
|
||||||
describe('Logout', function () {
|
describe('Logout', function () {
|
||||||
it('Should logout (revoke token)', async function () {
|
it('Should logout (revoke token)', async function () {
|
||||||
await logout(server.url, server.accessToken)
|
await server.loginCommand.logout({ token: server.accessToken })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be able to get the user information', async function () {
|
it('Should not be able to get the user information', async function () {
|
||||||
|
@ -250,9 +246,9 @@ describe('Test users', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to login again', async function () {
|
it('Should be able to login again', async function () {
|
||||||
const res = await login(server.url, server.client, server.user)
|
const body = await server.loginCommand.login()
|
||||||
server.accessToken = res.body.access_token
|
server.accessToken = body.access_token
|
||||||
server.refreshToken = res.body.refresh_token
|
server.refreshToken = body.refresh_token
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to get my user information again', async function () {
|
it('Should be able to get my user information again', async function () {
|
||||||
|
@ -268,11 +264,11 @@ describe('Test users', function () {
|
||||||
await killallServers([ server ])
|
await killallServers([ server ])
|
||||||
await reRunServer(server)
|
await reRunServer(server)
|
||||||
|
|
||||||
await getMyUserInformation(server.url, server.accessToken, 401)
|
await getMyUserInformation(server.url, server.accessToken, HttpStatusCode.UNAUTHORIZED_401)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be able to refresh an access token with an expired refresh token', async function () {
|
it('Should not be able to refresh an access token with an expired refresh token', async function () {
|
||||||
await refreshToken(server, server.refreshToken, 400)
|
await server.loginCommand.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should refresh the token', async function () {
|
it('Should refresh the token', async function () {
|
||||||
|
@ -284,7 +280,7 @@ describe('Test users', function () {
|
||||||
await killallServers([ server ])
|
await killallServers([ server ])
|
||||||
await reRunServer(server)
|
await reRunServer(server)
|
||||||
|
|
||||||
const res = await refreshToken(server, server.refreshToken)
|
const res = await server.loginCommand.refreshToken({ refreshToken: server.refreshToken })
|
||||||
server.accessToken = res.body.access_token
|
server.accessToken = res.body.access_token
|
||||||
server.refreshToken = res.body.refresh_token
|
server.refreshToken = res.body.refresh_token
|
||||||
})
|
})
|
||||||
|
@ -308,7 +304,7 @@ describe('Test users', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to login with this user', async function () {
|
it('Should be able to login with this user', async function () {
|
||||||
accessTokenUser = await userLogin(server, user)
|
accessTokenUser = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to get user information', async function () {
|
it('Should be able to get user information', async function () {
|
||||||
|
@ -562,6 +558,7 @@ describe('Test users', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Update my account', function () {
|
describe('Update my account', function () {
|
||||||
|
|
||||||
it('Should update my password', async function () {
|
it('Should update my password', async function () {
|
||||||
await updateMyUser({
|
await updateMyUser({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -571,7 +568,7 @@ describe('Test users', function () {
|
||||||
})
|
})
|
||||||
user.password = 'new password'
|
user.password = 'new password'
|
||||||
|
|
||||||
await userLogin(server, user, HttpStatusCode.OK_200)
|
await server.loginCommand.login({ user })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to change the NSFW display attribute', async function () {
|
it('Should be able to change the NSFW display attribute', async function () {
|
||||||
|
@ -781,7 +778,7 @@ describe('Test users', function () {
|
||||||
it('Should have removed the user token', async function () {
|
it('Should have removed the user token', async function () {
|
||||||
await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401)
|
await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401)
|
||||||
|
|
||||||
accessTokenUser = await userLogin(server, user)
|
accessTokenUser = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to update another user password', async function () {
|
it('Should be able to update another user password', async function () {
|
||||||
|
@ -794,10 +791,10 @@ describe('Test users', function () {
|
||||||
|
|
||||||
await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401)
|
await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401)
|
||||||
|
|
||||||
await userLogin(server, user, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
user.password = 'password updated'
|
user.password = 'password updated'
|
||||||
accessTokenUser = await userLogin(server, user)
|
accessTokenUser = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -813,7 +810,7 @@ describe('Test users', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be able to login with this user', async function () {
|
it('Should not be able to login with this user', async function () {
|
||||||
await userLogin(server, user, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not have videos of this user', async function () {
|
it('Should not have videos of this user', async function () {
|
||||||
|
@ -842,7 +839,7 @@ describe('Test users', function () {
|
||||||
password: 'my super password'
|
password: 'my super password'
|
||||||
}
|
}
|
||||||
|
|
||||||
user15AccessToken = await userLogin(server, user15)
|
user15AccessToken = await server.loginCommand.getAccessToken(user15)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have the correct display name', async function () {
|
it('Should have the correct display name', async function () {
|
||||||
|
@ -897,13 +894,13 @@ describe('Test users', function () {
|
||||||
})
|
})
|
||||||
user16Id = resUser.body.user.id
|
user16Id = resUser.body.user.id
|
||||||
|
|
||||||
user16AccessToken = await userLogin(server, user16)
|
user16AccessToken = await server.loginCommand.getAccessToken(user16)
|
||||||
|
|
||||||
await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200)
|
await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200)
|
||||||
await blockUser(server.url, user16Id, server.accessToken)
|
await blockUser(server.url, user16Id, server.accessToken)
|
||||||
|
|
||||||
await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.UNAUTHORIZED_401)
|
await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.UNAUTHORIZED_401)
|
||||||
await userLogin(server, user16, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should search user by banned status', async function () {
|
it('Should search user by banned status', async function () {
|
||||||
|
@ -930,7 +927,7 @@ describe('Test users', function () {
|
||||||
|
|
||||||
it('Should unblock a user', async function () {
|
it('Should unblock a user', async function () {
|
||||||
await unblockUser(server.url, user16Id, server.accessToken)
|
await unblockUser(server.url, user16Id, server.accessToken)
|
||||||
user16AccessToken = await userLogin(server, user16)
|
user16AccessToken = await server.loginCommand.getAccessToken(user16)
|
||||||
await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200)
|
await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -952,7 +949,7 @@ describe('Test users', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
user17Id = resUser.body.user.id
|
user17Id = resUser.body.user.id
|
||||||
user17AccessToken = await userLogin(server, user17)
|
user17AccessToken = await server.loginCommand.getAccessToken(user17)
|
||||||
|
|
||||||
const res = await getUserInformation(server.url, server.accessToken, user17Id, true)
|
const res = await getUserInformation(server.url, server.accessToken, user17Id, true)
|
||||||
const user: User = res.body
|
const user: User = res.body
|
||||||
|
|
|
@ -24,7 +24,6 @@ import {
|
||||||
testImage,
|
testImage,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
viewVideo,
|
viewVideo,
|
||||||
wait,
|
wait,
|
||||||
waitJobs,
|
waitJobs,
|
||||||
|
@ -155,7 +154,7 @@ describe('Test multiple servers', function () {
|
||||||
password: 'super_password'
|
password: 'super_password'
|
||||||
}
|
}
|
||||||
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
|
||||||
const userAccessToken = await userLogin(servers[1], user)
|
const userAccessToken = await servers[1].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const videoAttributes = {
|
const videoAttributes = {
|
||||||
name: 'my super name for server 2',
|
name: 'my super name for server 2',
|
||||||
|
|
|
@ -16,8 +16,7 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
setDefaultVideoChannel,
|
setDefaultVideoChannel,
|
||||||
uploadVideo,
|
uploadVideo
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
||||||
import { User } from '../../../../shared/models/users'
|
import { User } from '../../../../shared/models/users'
|
||||||
|
@ -82,8 +81,8 @@ describe('Test video change ownership - nominal', function () {
|
||||||
videoQuota: videoQuota
|
videoQuota: videoQuota
|
||||||
})
|
})
|
||||||
|
|
||||||
firstUserToken = await userLogin(servers[0], firstUser)
|
firstUserToken = await servers[0].loginCommand.getAccessToken(firstUser)
|
||||||
secondUserToken = await userLogin(servers[0], secondUser)
|
secondUserToken = await servers[0].loginCommand.getAccessToken(secondUser)
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getMyUserInformation(servers[0].url, firstUserToken)
|
const res = await getMyUserInformation(servers[0].url, firstUserToken)
|
||||||
|
@ -323,8 +322,8 @@ describe('Test video change ownership - quota too small', function () {
|
||||||
videoQuota: limitedVideoQuota
|
videoQuota: limitedVideoQuota
|
||||||
})
|
})
|
||||||
|
|
||||||
firstUserToken = await userLogin(server, firstUser)
|
firstUserToken = await server.loginCommand.getAccessToken(firstUser)
|
||||||
secondUserToken = await userLogin(server, secondUser)
|
secondUserToken = await server.loginCommand.getAccessToken(secondUser)
|
||||||
|
|
||||||
// Upload some videos on the server
|
// Upload some videos on the server
|
||||||
const video1Attributes = {
|
const video1Attributes = {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {
|
||||||
testImage,
|
testImage,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
wait
|
wait
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { getMyUserInformation, ServerInfo, setAccessTokensToServers, viewVideo } from '../../../../shared/extra-utils/index'
|
import { getMyUserInformation, ServerInfo, setAccessTokensToServers, viewVideo } from '../../../../shared/extra-utils/index'
|
||||||
|
@ -391,7 +390,7 @@ describe('Test video channels', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' })
|
||||||
const accessToken = await userLogin(servers[0], { username: 'toto', password: 'password' })
|
const accessToken = await servers[0].loginCommand.getAccessToken({ username: 'toto', password: 'password' })
|
||||||
|
|
||||||
const res = await getMyUserInformation(servers[0].url, accessToken)
|
const res = await getMyUserInformation(servers[0].url, accessToken)
|
||||||
const videoChannel = res.body.videoChannels[0]
|
const videoChannel = res.body.videoChannels[0]
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
dateIsValid,
|
dateIsValid,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getAccessToken,
|
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
testImage,
|
testImage,
|
||||||
|
@ -52,7 +51,7 @@ describe('Test video comments', function () {
|
||||||
username: 'user1',
|
username: 'user1',
|
||||||
password: 'password'
|
password: 'password'
|
||||||
})
|
})
|
||||||
userAccessTokenServer1 = await getAccessToken(server.url, 'user1', 'password')
|
userAccessTokenServer1 = await server.loginCommand.getAccessToken('user1', 'password')
|
||||||
|
|
||||||
command = server.commentsCommand
|
command = server.commentsCommand
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,8 +15,7 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
uploadVideo,
|
uploadVideo
|
||||||
userLogin
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { BooleanBothQuery, CustomConfig, ResultList, User, Video, VideosOverview } from '@shared/models'
|
import { BooleanBothQuery, CustomConfig, ResultList, User, Video, VideosOverview } from '@shared/models'
|
||||||
|
|
||||||
|
@ -151,7 +150,7 @@ describe('Test video NSFW policy', function () {
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
||||||
|
|
||||||
userAccessToken = await userLogin(server, { username, password })
|
userAccessToken = await server.loginCommand.getAccessToken({ username, password })
|
||||||
|
|
||||||
const res = await getMyUserInformation(server.url, userAccessToken)
|
const res = await getMyUserInformation(server.url, userAccessToken)
|
||||||
const user = res.body
|
const user = res.body
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
generateUserAccessToken,
|
generateUserAccessToken,
|
||||||
getAccessToken,
|
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
PlaylistsCommand,
|
PlaylistsCommand,
|
||||||
removeUser,
|
removeUser,
|
||||||
|
@ -21,7 +20,6 @@ import {
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
userLogin,
|
|
||||||
wait,
|
wait,
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
|
@ -122,7 +120,7 @@ describe('Test video playlists', function () {
|
||||||
username: 'user1',
|
username: 'user1',
|
||||||
password: 'password'
|
password: 'password'
|
||||||
})
|
})
|
||||||
userTokenServer1 = await getAccessToken(servers[0].url, 'user1', 'password')
|
userTokenServer1 = await servers[0].loginCommand.getAccessToken('user1', 'password')
|
||||||
}
|
}
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
@ -1129,7 +1127,7 @@ describe('Test video playlists', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
const userId = res.body.user.id
|
const userId = res.body.user.id
|
||||||
const userAccessToken = await userLogin(servers[0], user)
|
const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
|
const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
|
||||||
const userChannel = (resChannel.body as User).videoChannels[0]
|
const userChannel = (resChannel.body as User).videoChannels[0]
|
||||||
|
|
|
@ -2,23 +2,24 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { Video, VideoCreateResult } from '@shared/models'
|
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
createUser,
|
||||||
|
doubleFollow,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
|
getMyVideos,
|
||||||
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
getVideosListWithToken,
|
getVideosListWithToken,
|
||||||
|
getVideoWithToken,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo
|
updateVideo,
|
||||||
} from '../../../../shared/extra-utils/index'
|
uploadVideo,
|
||||||
import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
|
waitJobs
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
} from '@shared/extra-utils'
|
||||||
import { userLogin } from '../../../../shared/extra-utils/users/login'
|
import { Video, VideoCreateResult, VideoPrivacy } from '@shared/models'
|
||||||
import { createUser } from '../../../../shared/extra-utils/users/users'
|
|
||||||
import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos'
|
|
||||||
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -126,7 +127,7 @@ describe('Test video privacy', function () {
|
||||||
}
|
}
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
|
||||||
|
|
||||||
anotherUserToken = await userLogin(servers[0], user)
|
anotherUserToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403)
|
await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
|
@ -10,12 +11,10 @@ import {
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { Video, VideoPrivacy } from '../../../../shared/models/videos'
|
|
||||||
import { UserRole } from '../../../../shared/models/users'
|
import { UserRole } from '../../../../shared/models/users'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { Video, VideoPrivacy } from '../../../../shared/models/videos'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ describe('Test videos filter', function () {
|
||||||
role: UserRole.MODERATOR
|
role: UserRole.MODERATOR
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
server['moderatorAccessToken'] = await userLogin(server, moderator)
|
server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator)
|
||||||
|
|
||||||
await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber })
|
await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber })
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
wait
|
wait
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { Video, VideoDetails } from '@shared/models'
|
import { Video, VideoDetails } from '@shared/models'
|
||||||
|
@ -61,7 +60,7 @@ describe('Test videos history', function () {
|
||||||
password: 'super password'
|
password: 'super password'
|
||||||
}
|
}
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
||||||
userAccessToken = await userLogin(server, user)
|
userAccessToken = await server.loginCommand.getAccessToken(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should get videos, without watching history', async function () {
|
it('Should get videos, without watching history', async function () {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
testHelloWorldRegisteredSettings,
|
testHelloWorldRegisteredSettings,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '../../../shared/extra-utils'
|
} from '../../../shared/extra-utils'
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ describe('Test CLI wrapper', function () {
|
||||||
|
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super_password' })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super_password' })
|
||||||
|
|
||||||
userAccessToken = await userLogin(server, { username: 'user_1', password: 'super_password' })
|
userAccessToken = await server.loginCommand.getAccessToken({ username: 'user_1', password: 'super_password' })
|
||||||
|
|
||||||
{
|
{
|
||||||
const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
|
const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
import { cleanupTests, CLICommand, createUser, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../shared/extra-utils'
|
||||||
import {
|
|
||||||
cleanupTests,
|
|
||||||
CLICommand,
|
|
||||||
createUser,
|
|
||||||
flushAndRunServer,
|
|
||||||
login,
|
|
||||||
ServerInfo,
|
|
||||||
setAccessTokensToServers
|
|
||||||
} from '../../../shared/extra-utils'
|
|
||||||
|
|
||||||
describe('Test reset password scripts', function () {
|
describe('Test reset password scripts', function () {
|
||||||
let server: ServerInfo
|
let server: ServerInfo
|
||||||
|
@ -27,7 +18,7 @@ describe('Test reset password scripts', function () {
|
||||||
const env = server.cliCommand.getEnv()
|
const env = server.cliCommand.getEnv()
|
||||||
await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`)
|
await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`)
|
||||||
|
|
||||||
await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, HttpStatusCode.OK_200)
|
await server.loginCommand.login({ user: { username: 'user_1', password: 'coucou' } })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { User } from '@shared/models/users/user.model'
|
import { User } from '@shared/models/users/user.model'
|
||||||
import { blockUser, getMyUserInformation, setAccessTokensToServers, unblockUser, uploadVideo, userLogin } from '../../../shared/extra-utils'
|
import { blockUser, getMyUserInformation, setAccessTokensToServers, unblockUser, uploadVideo } from '../../../shared/extra-utils'
|
||||||
import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
|
import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
|
||||||
|
|
||||||
describe('Official plugin auth-ldap', function () {
|
describe('Official plugin auth-ldap', function () {
|
||||||
|
@ -21,7 +22,7 @@ describe('Official plugin auth-ldap', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login with without LDAP settings', async function () {
|
it('Should not login with without LDAP settings', async function () {
|
||||||
await userLogin(server, { username: 'fry', password: 'fry' }, 400)
|
await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login with bad LDAP settings', async function () {
|
it('Should not login with bad LDAP settings', async function () {
|
||||||
|
@ -39,7 +40,7 @@ describe('Official plugin auth-ldap', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await userLogin(server, { username: 'fry', password: 'fry' }, 400)
|
await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login with good LDAP settings but wrong username/password', async function () {
|
it('Should not login with good LDAP settings but wrong username/password', async function () {
|
||||||
|
@ -57,16 +58,16 @@ describe('Official plugin auth-ldap', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await userLogin(server, { username: 'fry', password: 'bad password' }, 400)
|
await server.loginCommand.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await userLogin(server, { username: 'fryr', password: 'fry' }, 400)
|
await server.loginCommand.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should login with the appropriate username/password', async function () {
|
it('Should login with the appropriate username/password', async function () {
|
||||||
accessToken = await userLogin(server, { username: 'fry', password: 'fry' })
|
accessToken = await server.loginCommand.getAccessToken({ username: 'fry', password: 'fry' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should login with the appropriate email/password', async function () {
|
it('Should login with the appropriate email/password', async function () {
|
||||||
accessToken = await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' })
|
accessToken = await server.loginCommand.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should login get my profile', async function () {
|
it('Should login get my profile', async function () {
|
||||||
|
@ -86,19 +87,25 @@ describe('Official plugin auth-ldap', function () {
|
||||||
it('Should not be able to login if the user is banned', async function () {
|
it('Should not be able to login if the user is banned', async function () {
|
||||||
await blockUser(server.url, userId, server.accessToken)
|
await blockUser(server.url, userId, server.accessToken)
|
||||||
|
|
||||||
await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400)
|
await server.loginCommand.login({
|
||||||
|
user: { username: 'fry@planetexpress.com', password: 'fry' },
|
||||||
|
expectedStatus: HttpStatusCode.BAD_REQUEST_400
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be able to login if the user is unbanned', async function () {
|
it('Should be able to login if the user is unbanned', async function () {
|
||||||
await unblockUser(server.url, userId, server.accessToken)
|
await unblockUser(server.url, userId, server.accessToken)
|
||||||
|
|
||||||
await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' })
|
await server.loginCommand.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login if the plugin is uninstalled', async function () {
|
it('Should not login if the plugin is uninstalled', async function () {
|
||||||
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
|
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
|
||||||
|
|
||||||
await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400)
|
await server.loginCommand.login({
|
||||||
|
user: { username: 'fry@planetexpress.com', password: 'fry' },
|
||||||
|
expectedStatus: HttpStatusCode.BAD_REQUEST_400
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
userLogin,
|
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { User, VideoPrivacy } from '@shared/models'
|
import { User, VideoPrivacy } from '@shared/models'
|
||||||
|
@ -64,7 +63,7 @@ describe('Test syndication feeds', () => {
|
||||||
{
|
{
|
||||||
const attr = { username: 'john', password: 'password' }
|
const attr = { username: 'john', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password })
|
||||||
userAccessToken = await userLogin(servers[0], attr)
|
userAccessToken = await servers[0].loginCommand.getAccessToken(attr)
|
||||||
|
|
||||||
const res = await getMyUserInformation(servers[0].url, userAccessToken)
|
const res = await getMyUserInformation(servers[0].url, userAccessToken)
|
||||||
const user: User = res.body
|
const user: User = res.body
|
||||||
|
@ -301,7 +300,7 @@ describe('Test syndication feeds', () => {
|
||||||
it('Should list no videos for a user with no videos and no subscriptions', async function () {
|
it('Should list no videos for a user with no videos and no subscriptions', async function () {
|
||||||
const attr = { username: 'feeduser', password: 'password' }
|
const attr = { username: 'feeduser', password: 'password' }
|
||||||
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password })
|
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password })
|
||||||
const feeduserAccessToken = await userLogin(servers[0], attr)
|
const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr)
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getMyUserInformation(servers[0].url, feeduserAccessToken)
|
const res = await getMyUserInformation(servers[0].url, feeduserAccessToken)
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
updateUser,
|
updateUser,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
|
||||||
viewVideo
|
viewVideo
|
||||||
} from '../../../shared/extra-utils'
|
} from '../../../shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
|
@ -138,7 +137,7 @@ describe('Test plugin action hooks', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run action:api.user.oauth2-got-token', async function () {
|
it('Should run action:api.user.oauth2-got-token', async function () {
|
||||||
await userLogin(servers[0], { username: 'created_user', password: 'super_password' })
|
await servers[0].loginCommand.getAccessToken('created_user', 'super_password')
|
||||||
|
|
||||||
await checkHook('action:api.user.oauth2-got-token')
|
await checkHook('action:api.user.oauth2-got-token')
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,14 +9,10 @@ import {
|
||||||
decodeQueryString,
|
decodeQueryString,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
loginUsingExternalToken,
|
|
||||||
logout,
|
|
||||||
PluginsCommand,
|
PluginsCommand,
|
||||||
refreshToken,
|
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
userLogin,
|
|
||||||
wait
|
wait
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { User, UserRole } from '@shared/models'
|
import { User, UserRole } from '@shared/models'
|
||||||
|
@ -43,12 +39,11 @@ async function loginExternal (options: {
|
||||||
const location = res.header.location
|
const location = res.header.location
|
||||||
const { externalAuthToken } = decodeQueryString(location)
|
const { externalAuthToken } = decodeQueryString(location)
|
||||||
|
|
||||||
const resLogin = await loginUsingExternalToken(
|
const resLogin = await options.server.loginCommand.loginUsingExternalToken({
|
||||||
options.server,
|
username: options.username,
|
||||||
options.username,
|
externalAuthToken: externalAuthToken as string,
|
||||||
externalAuthToken as string,
|
expectedStatus: options.statusCodeExpectedStep2
|
||||||
options.statusCodeExpectedStep2
|
})
|
||||||
)
|
|
||||||
|
|
||||||
return resLogin.body
|
return resLogin.body
|
||||||
}
|
}
|
||||||
|
@ -110,13 +105,17 @@ describe('Test external auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should reject auto external login with a missing or invalid token', async function () {
|
it('Should reject auto external login with a missing or invalid token', async function () {
|
||||||
await loginUsingExternalToken(server, 'cyan', '', HttpStatusCode.BAD_REQUEST_400)
|
const command = server.loginCommand
|
||||||
await loginUsingExternalToken(server, 'cyan', 'blabla', HttpStatusCode.BAD_REQUEST_400)
|
|
||||||
|
await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: '', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: 'blabla', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should reject auto external login with a missing or invalid username', async function () {
|
it('Should reject auto external login with a missing or invalid username', async function () {
|
||||||
await loginUsingExternalToken(server, '', externalAuthToken, HttpStatusCode.BAD_REQUEST_400)
|
const command = server.loginCommand
|
||||||
await loginUsingExternalToken(server, '', externalAuthToken, HttpStatusCode.BAD_REQUEST_400)
|
|
||||||
|
await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should reject auto external login with an expired token', async function () {
|
it('Should reject auto external login with an expired token', async function () {
|
||||||
|
@ -124,7 +123,11 @@ describe('Test external auth plugins', function () {
|
||||||
|
|
||||||
await wait(5000)
|
await wait(5000)
|
||||||
|
|
||||||
await loginUsingExternalToken(server, 'cyan', externalAuthToken, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.loginUsingExternalToken({
|
||||||
|
username: 'cyan',
|
||||||
|
externalAuthToken,
|
||||||
|
expectedStatus: HttpStatusCode.BAD_REQUEST_400
|
||||||
|
})
|
||||||
|
|
||||||
await server.serversCommand.waitUntilLog('expired external auth token', 2)
|
await server.serversCommand.waitUntilLog('expired external auth token', 2)
|
||||||
})
|
})
|
||||||
|
@ -182,7 +185,7 @@ describe('Test external auth plugins', function () {
|
||||||
|
|
||||||
it('Should refresh Cyan token, but not Kefka token', async function () {
|
it('Should refresh Cyan token, but not Kefka token', async function () {
|
||||||
{
|
{
|
||||||
const resRefresh = await refreshToken(server, cyanRefreshToken)
|
const resRefresh = await server.loginCommand.refreshToken({ refreshToken: cyanRefreshToken })
|
||||||
cyanAccessToken = resRefresh.body.access_token
|
cyanAccessToken = resRefresh.body.access_token
|
||||||
cyanRefreshToken = resRefresh.body.refresh_token
|
cyanRefreshToken = resRefresh.body.refresh_token
|
||||||
|
|
||||||
|
@ -192,7 +195,7 @@ describe('Test external auth plugins', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
await refreshToken(server, kefkaRefreshToken, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -212,7 +215,7 @@ describe('Test external auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should logout Cyan', async function () {
|
it('Should logout Cyan', async function () {
|
||||||
await logout(server.url, cyanAccessToken)
|
await server.loginCommand.logout({ token: cyanAccessToken })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have logged out Cyan', async function () {
|
it('Should have logged out Cyan', async function () {
|
||||||
|
@ -269,7 +272,7 @@ describe('Test external auth plugins', function () {
|
||||||
settings: { disableKefka: true }
|
settings: { disableKefka: true }
|
||||||
})
|
})
|
||||||
|
|
||||||
await userLogin(server, { username: 'kefka', password: 'fake' }, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.login({ user: { username: 'kefka', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
await loginExternal({
|
await loginExternal({
|
||||||
server,
|
server,
|
||||||
|
@ -307,9 +310,9 @@ describe('Test external auth plugins', function () {
|
||||||
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
||||||
})
|
})
|
||||||
|
|
||||||
await userLogin(server, { username: 'cyan', password: null }, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await userLogin(server, { username: 'cyan', password: '' }, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.login({ user: { username: 'cyan', password: '' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await userLogin(server, { username: 'cyan', password: 'fake' }, HttpStatusCode.BAD_REQUEST_400)
|
await server.loginCommand.login({ user: { username: 'cyan', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login kefka with another plugin', async function () {
|
it('Should not login kefka with another plugin', async function () {
|
||||||
|
@ -369,9 +372,8 @@ describe('Test external auth plugins', function () {
|
||||||
username: 'cid'
|
username: 'cid'
|
||||||
})
|
})
|
||||||
|
|
||||||
const resLogout = await logout(server.url, resLogin.access_token)
|
const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token })
|
||||||
|
expect(redirectUrl).to.equal('https://example.com/redirectUrl')
|
||||||
expect(resLogout.body.redirectUrl).to.equal('https://example.com/redirectUrl')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should call the plugin\'s onLogout method with the request', async function () {
|
it('Should call the plugin\'s onLogout method with the request', async function () {
|
||||||
|
@ -382,8 +384,7 @@ describe('Test external auth plugins', function () {
|
||||||
username: 'cid'
|
username: 'cid'
|
||||||
})
|
})
|
||||||
|
|
||||||
const resLogout = await logout(server.url, resLogin.access_token)
|
const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token })
|
||||||
|
expect(redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token)
|
||||||
expect(resLogout.body.redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,19 +2,16 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
getUsersList,
|
getUsersList,
|
||||||
login,
|
|
||||||
logout,
|
|
||||||
PluginsCommand,
|
PluginsCommand,
|
||||||
refreshToken,
|
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
userLogin,
|
|
||||||
wait
|
wait
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { User, UserRole } from '@shared/models'
|
import { User, UserRole } from '@shared/models'
|
||||||
|
@ -52,11 +49,11 @@ describe('Test id and pass auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not login', async function () {
|
it('Should not login', async function () {
|
||||||
await userLogin(server, { username: 'toto', password: 'password' }, 400)
|
await server.loginCommand.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should login Spyro, create the user and use the token', async function () {
|
it('Should login Spyro, create the user and use the token', async function () {
|
||||||
const accessToken = await userLogin(server, { username: 'spyro', password: 'spyro password' })
|
const accessToken = await server.loginCommand.getAccessToken({ username: 'spyro', password: 'spyro password' })
|
||||||
|
|
||||||
const res = await getMyUserInformation(server.url, accessToken)
|
const res = await getMyUserInformation(server.url, accessToken)
|
||||||
|
|
||||||
|
@ -68,9 +65,9 @@ describe('Test id and pass auth plugins', function () {
|
||||||
|
|
||||||
it('Should login Crash, create the user and use the token', async function () {
|
it('Should login Crash, create the user and use the token', async function () {
|
||||||
{
|
{
|
||||||
const res = await login(server.url, server.client, { username: 'crash', password: 'crash password' })
|
const body = await server.loginCommand.login({ user: { username: 'crash', password: 'crash password' } })
|
||||||
crashAccessToken = res.body.access_token
|
crashAccessToken = body.access_token
|
||||||
crashRefreshToken = res.body.refresh_token
|
crashRefreshToken = body.refresh_token
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -85,9 +82,9 @@ describe('Test id and pass auth plugins', function () {
|
||||||
|
|
||||||
it('Should login the first Laguna, create the user and use the token', async function () {
|
it('Should login the first Laguna, create the user and use the token', async function () {
|
||||||
{
|
{
|
||||||
const res = await login(server.url, server.client, { username: 'laguna', password: 'laguna password' })
|
const body = await server.loginCommand.login({ user: { username: 'laguna', password: 'laguna password' } })
|
||||||
lagunaAccessToken = res.body.access_token
|
lagunaAccessToken = body.access_token
|
||||||
lagunaRefreshToken = res.body.refresh_token
|
lagunaRefreshToken = body.refresh_token
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -102,7 +99,7 @@ describe('Test id and pass auth plugins', function () {
|
||||||
|
|
||||||
it('Should refresh crash token, but not laguna token', async function () {
|
it('Should refresh crash token, but not laguna token', async function () {
|
||||||
{
|
{
|
||||||
const resRefresh = await refreshToken(server, crashRefreshToken)
|
const resRefresh = await server.loginCommand.refreshToken({ refreshToken: crashRefreshToken })
|
||||||
crashAccessToken = resRefresh.body.access_token
|
crashAccessToken = resRefresh.body.access_token
|
||||||
crashRefreshToken = resRefresh.body.refresh_token
|
crashRefreshToken = resRefresh.body.refresh_token
|
||||||
|
|
||||||
|
@ -112,7 +109,7 @@ describe('Test id and pass auth plugins', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
await refreshToken(server, lagunaRefreshToken, 400)
|
await server.loginCommand.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -132,7 +129,7 @@ describe('Test id and pass auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should logout Crash', async function () {
|
it('Should logout Crash', async function () {
|
||||||
await logout(server.url, crashAccessToken)
|
await server.loginCommand.logout({ token: crashAccessToken })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have logged out Crash', async function () {
|
it('Should have logged out Crash', async function () {
|
||||||
|
@ -142,7 +139,7 @@ describe('Test id and pass auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should login Crash and keep the old existing profile', async function () {
|
it('Should login Crash and keep the old existing profile', async function () {
|
||||||
crashAccessToken = await userLogin(server, { username: 'crash', password: 'crash password' })
|
crashAccessToken = await server.loginCommand.getAccessToken({ username: 'crash', password: 'crash password' })
|
||||||
|
|
||||||
const res = await getMyUserInformation(server.url, crashAccessToken)
|
const res = await getMyUserInformation(server.url, crashAccessToken)
|
||||||
|
|
||||||
|
@ -162,16 +159,18 @@ describe('Test id and pass auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should reject an invalid username, email, role or display name', async function () {
|
it('Should reject an invalid username, email, role or display name', async function () {
|
||||||
await userLogin(server, { username: 'ward', password: 'ward password' }, 400)
|
const command = server.loginCommand
|
||||||
|
|
||||||
|
await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await server.serversCommand.waitUntilLog('valid username')
|
await server.serversCommand.waitUntilLog('valid username')
|
||||||
|
|
||||||
await userLogin(server, { username: 'kiros', password: 'kiros password' }, 400)
|
await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await server.serversCommand.waitUntilLog('valid display name')
|
await server.serversCommand.waitUntilLog('valid display name')
|
||||||
|
|
||||||
await userLogin(server, { username: 'raine', password: 'raine password' }, 400)
|
await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await server.serversCommand.waitUntilLog('valid role')
|
await server.serversCommand.waitUntilLog('valid role')
|
||||||
|
|
||||||
await userLogin(server, { username: 'ellone', password: 'elonne password' }, 400)
|
await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await server.serversCommand.waitUntilLog('valid email')
|
await server.serversCommand.waitUntilLog('valid email')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -181,8 +180,9 @@ describe('Test id and pass auth plugins', function () {
|
||||||
settings: { disableSpyro: true }
|
settings: { disableSpyro: true }
|
||||||
})
|
})
|
||||||
|
|
||||||
await userLogin(server, { username: 'spyro', password: 'spyro password' }, 400)
|
const command = server.loginCommand
|
||||||
await userLogin(server, { username: 'spyro', password: 'fake' }, 400)
|
await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have disabled this auth', async function () {
|
it('Should have disabled this auth', async function () {
|
||||||
|
@ -198,7 +198,10 @@ describe('Test id and pass auth plugins', function () {
|
||||||
it('Should uninstall the plugin one and do not login existing Crash', async function () {
|
it('Should uninstall the plugin one and do not login existing Crash', async function () {
|
||||||
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
|
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
|
||||||
|
|
||||||
await userLogin(server, { username: 'crash', password: 'crash password' }, 400)
|
await server.loginCommand.login({
|
||||||
|
user: { username: 'crash', password: 'crash password' },
|
||||||
|
expectedStatus: HttpStatusCode.BAD_REQUEST_400
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should display the correct configuration', async function () {
|
it('Should display the correct configuration', async function () {
|
||||||
|
|
|
@ -27,6 +27,7 @@ function makeGetRequest (options: {
|
||||||
range?: string
|
range?: string
|
||||||
redirects?: number
|
redirects?: number
|
||||||
accept?: string
|
accept?: string
|
||||||
|
host?: string
|
||||||
}) {
|
}) {
|
||||||
if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
|
if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
|
||||||
if (options.contentType === undefined) options.contentType = 'application/json'
|
if (options.contentType === undefined) options.contentType = 'application/json'
|
||||||
|
@ -38,6 +39,7 @@ function makeGetRequest (options: {
|
||||||
if (options.query) req.query(options.query)
|
if (options.query) req.query(options.query)
|
||||||
if (options.range) req.set('Range', options.range)
|
if (options.range) req.set('Range', options.range)
|
||||||
if (options.accept) req.set('Accept', options.accept)
|
if (options.accept) req.set('Accept', options.accept)
|
||||||
|
if (options.host) req.set('Host', options.host)
|
||||||
if (options.redirects) req.redirects(options.redirects)
|
if (options.redirects) req.redirects(options.redirects)
|
||||||
|
|
||||||
return req.expect(options.statusCodeExpected)
|
return req.expect(options.statusCodeExpected)
|
||||||
|
@ -113,6 +115,7 @@ function makePostBodyRequest (options: {
|
||||||
path: string
|
path: string
|
||||||
token?: string
|
token?: string
|
||||||
fields?: { [ fieldName: string ]: any }
|
fields?: { [ fieldName: string ]: any }
|
||||||
|
type?: string
|
||||||
statusCodeExpected?: HttpStatusCode
|
statusCodeExpected?: HttpStatusCode
|
||||||
}) {
|
}) {
|
||||||
if (!options.fields) options.fields = {}
|
if (!options.fields) options.fields = {}
|
||||||
|
@ -123,6 +126,7 @@ function makePostBodyRequest (options: {
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
|
|
||||||
if (options.token) req.set('Authorization', 'Bearer ' + options.token)
|
if (options.token) req.set('Authorization', 'Bearer ' + options.token)
|
||||||
|
if (options.type) req.type(options.type)
|
||||||
|
|
||||||
return req.send(options.fields)
|
return req.send(options.fields)
|
||||||
.expect(options.statusCodeExpected)
|
.expect(options.statusCodeExpected)
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
import * as request from 'supertest'
|
|
||||||
import { URL } from 'url'
|
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
function getClient (url: string) {
|
|
||||||
const path = '/api/v1/oauth-clients/local'
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.get(path)
|
|
||||||
.set('Host', new URL(url).host)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.expect(HttpStatusCode.OK_200)
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export {
|
|
||||||
getClient
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ import { AbusesCommand } from '../moderation'
|
||||||
import { OverviewsCommand } from '../overviews'
|
import { OverviewsCommand } from '../overviews'
|
||||||
import { SearchCommand } from '../search'
|
import { SearchCommand } from '../search'
|
||||||
import { SocketIOCommand } from '../socket'
|
import { SocketIOCommand } from '../socket'
|
||||||
import { AccountsCommand, BlocklistCommand, NotificationsCommand, SubscriptionsCommand } from '../users'
|
import { AccountsCommand, BlocklistCommand, LoginCommand, NotificationsCommand, SubscriptionsCommand } from '../users'
|
||||||
import {
|
import {
|
||||||
BlacklistCommand,
|
BlacklistCommand,
|
||||||
CaptionsCommand,
|
CaptionsCommand,
|
||||||
|
@ -126,6 +126,7 @@ interface ServerInfo {
|
||||||
sqlCommand?: SQLCommand
|
sqlCommand?: SQLCommand
|
||||||
notificationsCommand?: NotificationsCommand
|
notificationsCommand?: NotificationsCommand
|
||||||
serversCommand?: ServersCommand
|
serversCommand?: ServersCommand
|
||||||
|
loginCommand?: LoginCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
|
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
|
||||||
|
@ -357,6 +358,7 @@ function assignCommands (server: ServerInfo) {
|
||||||
server.sqlCommand = new SQLCommand(server)
|
server.sqlCommand = new SQLCommand(server)
|
||||||
server.notificationsCommand = new NotificationsCommand(server)
|
server.notificationsCommand = new NotificationsCommand(server)
|
||||||
server.serversCommand = new ServersCommand(server)
|
server.serversCommand = new ServersCommand(server)
|
||||||
|
server.loginCommand = new LoginCommand(server)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reRunServer (server: ServerInfo, configOverride?: any) {
|
async function reRunServer (server: ServerInfo, configOverride?: any) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ interface InternalGetCommandOptions extends InternalCommonCommandOptions {
|
||||||
accept?: string
|
accept?: string
|
||||||
redirects?: number
|
redirects?: number
|
||||||
range?: string
|
range?: string
|
||||||
|
host?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class AbstractCommand {
|
abstract class AbstractCommand {
|
||||||
|
@ -78,7 +79,7 @@ abstract class AbstractCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getRequest (options: InternalGetCommandOptions) {
|
protected getRequest (options: InternalGetCommandOptions) {
|
||||||
const { redirects, query, contentType, accept, range } = options
|
const { redirects, query, contentType, accept, range, host } = options
|
||||||
|
|
||||||
return makeGetRequest({
|
return makeGetRequest({
|
||||||
...this.buildCommonRequestOptions(options),
|
...this.buildCommonRequestOptions(options),
|
||||||
|
@ -87,6 +88,7 @@ abstract class AbstractCommand {
|
||||||
query,
|
query,
|
||||||
contentType,
|
contentType,
|
||||||
range,
|
range,
|
||||||
|
host,
|
||||||
accept
|
accept
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -109,13 +111,15 @@ abstract class AbstractCommand {
|
||||||
|
|
||||||
protected postBodyRequest (options: InternalCommonCommandOptions & {
|
protected postBodyRequest (options: InternalCommonCommandOptions & {
|
||||||
fields?: { [ fieldName: string ]: any }
|
fields?: { [ fieldName: string ]: any }
|
||||||
|
type?: string
|
||||||
}) {
|
}) {
|
||||||
const { fields } = options
|
const { type, fields } = options
|
||||||
|
|
||||||
return makePostBodyRequest({
|
return makePostBodyRequest({
|
||||||
...this.buildCommonRequestOptions(options),
|
...this.buildCommonRequestOptions(options),
|
||||||
|
|
||||||
fields
|
fields,
|
||||||
|
type
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ export * from './accounts-command'
|
||||||
export * from './accounts'
|
export * from './accounts'
|
||||||
export * from './blocklist-command'
|
export * from './blocklist-command'
|
||||||
export * from './login'
|
export * from './login'
|
||||||
|
export * from './login-command'
|
||||||
export * from './notifications'
|
export * from './notifications'
|
||||||
export * from './notifications-command'
|
export * from './notifications-command'
|
||||||
export * from './subscriptions-command'
|
export * from './subscriptions-command'
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
import { PeerTubeRequestError } from '@server/helpers/requests'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
|
import { PeerTubeProblemDocument } from '@shared/models'
|
||||||
|
import { unwrapBody } from '../requests'
|
||||||
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
|
|
||||||
|
export class LoginCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
login (options: OverrideCommandOptions & {
|
||||||
|
client?: { id?: string, secret?: string }
|
||||||
|
user?: { username: string, password: string }
|
||||||
|
} = {}) {
|
||||||
|
const { client = this.server.client, user = this.server.user } = options
|
||||||
|
const path = '/api/v1/users/token'
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
client_id: client.id,
|
||||||
|
client_secret: client.secret,
|
||||||
|
username: user.username,
|
||||||
|
password: user.password,
|
||||||
|
response_type: 'code',
|
||||||
|
grant_type: 'password',
|
||||||
|
scope: 'upload'
|
||||||
|
}
|
||||||
|
|
||||||
|
return unwrapBody<{ access_token: string, refresh_token: string } & PeerTubeProblemDocument>(this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
type: 'form',
|
||||||
|
fields: body,
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
getAccessToken (user?: { username: string, password: string }): Promise<string>
|
||||||
|
getAccessToken (username: string, password: string): Promise<string>
|
||||||
|
async getAccessToken (arg1?: { username: string, password: string } | string, password?: string) {
|
||||||
|
let user: { username: string, password: string }
|
||||||
|
|
||||||
|
if (!arg1) user = this.server.user
|
||||||
|
else if (typeof arg1 === 'object') user = arg1
|
||||||
|
else user = { username: arg1, password }
|
||||||
|
|
||||||
|
try {
|
||||||
|
const body = await this.login({ user })
|
||||||
|
|
||||||
|
return body.access_token
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error('Cannot authenticate. Please check your username/password.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loginUsingExternalToken (options: OverrideCommandOptions & {
|
||||||
|
username: string
|
||||||
|
externalAuthToken: string
|
||||||
|
}) {
|
||||||
|
const { username, externalAuthToken } = options
|
||||||
|
const path = '/api/v1/users/token'
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
client_id: this.server.client.id,
|
||||||
|
client_secret: this.server.client.secret,
|
||||||
|
username: username,
|
||||||
|
response_type: 'code',
|
||||||
|
grant_type: 'password',
|
||||||
|
scope: 'upload',
|
||||||
|
externalAuthToken
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
type: 'form',
|
||||||
|
fields: body,
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
logout (options: OverrideCommandOptions & {
|
||||||
|
token: string
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/users/revoke-token'
|
||||||
|
|
||||||
|
return unwrapBody<{ redirectUrl: string }>(this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
type: 'form',
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshToken (options: OverrideCommandOptions & {
|
||||||
|
refreshToken: string
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/users/token'
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
client_id: this.server.client.id,
|
||||||
|
client_secret: this.server.client.secret,
|
||||||
|
refresh_token: options.refreshToken,
|
||||||
|
response_type: 'code',
|
||||||
|
grant_type: 'refresh_token'
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
type: 'form',
|
||||||
|
fields: body,
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getClient (options: OverrideCommandOptions = {}) {
|
||||||
|
const path = '/api/v1/oauth-clients/local'
|
||||||
|
|
||||||
|
return this.getRequestBody<{ client_id: string, client_secret: string }>({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
host: this.server.host,
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,133 +1,19 @@
|
||||||
import * as request from 'supertest'
|
|
||||||
|
|
||||||
import { ServerInfo } from '../server/servers'
|
import { ServerInfo } from '../server/servers'
|
||||||
import { getClient } from '../server/clients'
|
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
type Client = { id?: string, secret?: string }
|
|
||||||
type User = { username: string, password: string }
|
|
||||||
type Server = { url?: string, client?: Client, user?: User }
|
|
||||||
|
|
||||||
function login (url: string, client: Client, user: User, expectedStatus = HttpStatusCode.OK_200) {
|
|
||||||
const path = '/api/v1/users/token'
|
|
||||||
|
|
||||||
const body = {
|
|
||||||
client_id: client.id,
|
|
||||||
client_secret: client.secret,
|
|
||||||
username: user.username,
|
|
||||||
password: user.password,
|
|
||||||
response_type: 'code',
|
|
||||||
grant_type: 'password',
|
|
||||||
scope: 'upload'
|
|
||||||
}
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.post(path)
|
|
||||||
.type('form')
|
|
||||||
.send(body)
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
function logout (url: string, token: string, expectedStatus = HttpStatusCode.OK_200) {
|
|
||||||
const path = '/api/v1/users/revoke-token'
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.post(path)
|
|
||||||
.set('Authorization', 'Bearer ' + token)
|
|
||||||
.type('form')
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function serverLogin (server: Server) {
|
|
||||||
const res = await login(server.url, server.client, server.user, HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
return res.body.access_token as string
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshToken (server: ServerInfo, refreshToken: string, expectedStatus = HttpStatusCode.OK_200) {
|
|
||||||
const path = '/api/v1/users/token'
|
|
||||||
|
|
||||||
const body = {
|
|
||||||
client_id: server.client.id,
|
|
||||||
client_secret: server.client.secret,
|
|
||||||
refresh_token: refreshToken,
|
|
||||||
response_type: 'code',
|
|
||||||
grant_type: 'refresh_token'
|
|
||||||
}
|
|
||||||
|
|
||||||
return request(server.url)
|
|
||||||
.post(path)
|
|
||||||
.type('form')
|
|
||||||
.send(body)
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function userLogin (server: Server, user: User, expectedStatus = HttpStatusCode.OK_200) {
|
|
||||||
const res = await login(server.url, server.client, user, expectedStatus)
|
|
||||||
|
|
||||||
return res.body.access_token as string
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getAccessToken (url: string, username: string, password: string) {
|
|
||||||
const resClient = await getClient(url)
|
|
||||||
const client = {
|
|
||||||
id: resClient.body.client_id,
|
|
||||||
secret: resClient.body.client_secret
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = { username, password }
|
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await login(url, client, user)
|
|
||||||
return res.body.access_token
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error('Cannot authenticate. Please check your username/password.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setAccessTokensToServers (servers: ServerInfo[]) {
|
function setAccessTokensToServers (servers: ServerInfo[]) {
|
||||||
const tasks: Promise<any>[] = []
|
const tasks: Promise<any>[] = []
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const p = serverLogin(server).then(t => { server.accessToken = t })
|
const p = server.loginCommand.getAccessToken()
|
||||||
|
.then(t => { server.accessToken = t })
|
||||||
tasks.push(p)
|
tasks.push(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(tasks)
|
return Promise.all(tasks)
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginUsingExternalToken (server: Server, username: string, externalAuthToken: string, expectedStatus = HttpStatusCode.OK_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 {
|
export {
|
||||||
login,
|
setAccessTokensToServers
|
||||||
logout,
|
|
||||||
serverLogin,
|
|
||||||
refreshToken,
|
|
||||||
userLogin,
|
|
||||||
getAccessToken,
|
|
||||||
setAccessTokensToServers,
|
|
||||||
Server,
|
|
||||||
Client,
|
|
||||||
User,
|
|
||||||
loginUsingExternalToken
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { UserNotification, UserNotificationSetting, UserNotificationSettingValue
|
||||||
import { MockSmtpServer } from '../mock-servers/mock-email'
|
import { MockSmtpServer } from '../mock-servers/mock-email'
|
||||||
import { doubleFollow } from '../server/follows'
|
import { doubleFollow } from '../server/follows'
|
||||||
import { flushAndRunMultipleServers, ServerInfo } from '../server/servers'
|
import { flushAndRunMultipleServers, ServerInfo } from '../server/servers'
|
||||||
import { setAccessTokensToServers, userLogin } from './login'
|
import { setAccessTokensToServers } from './login'
|
||||||
import { createUser, getMyUserInformation } from './users'
|
import { createUser, getMyUserInformation } from './users'
|
||||||
|
|
||||||
function getAllNotificationsSettings (): UserNotificationSetting {
|
function getAllNotificationsSettings (): UserNotificationSetting {
|
||||||
|
@ -662,7 +662,7 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an
|
||||||
password: user.password,
|
password: user.password,
|
||||||
videoQuota: 10 * 1000 * 1000
|
videoQuota: 10 * 1000 * 1000
|
||||||
})
|
})
|
||||||
const userAccessToken = await userLogin(servers[0], user)
|
const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
|
||||||
|
|
||||||
await servers[0].notificationsCommand.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() })
|
await servers[0].notificationsCommand.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() })
|
||||||
await servers[0].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() })
|
await servers[0].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() })
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { UserRegister } from '../../models/users/user-register.model'
|
||||||
import { UserRole } from '../../models/users/user-role'
|
import { UserRole } from '../../models/users/user-role'
|
||||||
import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateImageRequest } from '../requests/requests'
|
import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateImageRequest } from '../requests/requests'
|
||||||
import { ServerInfo } from '../server/servers'
|
import { ServerInfo } from '../server/servers'
|
||||||
import { userLogin } from './login'
|
|
||||||
|
|
||||||
function createUser (parameters: {
|
function createUser (parameters: {
|
||||||
url: string
|
url: string
|
||||||
|
@ -55,7 +54,7 @@ async function generateUser (server: ServerInfo, username: string) {
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
const resCreate = await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
const resCreate = await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
||||||
|
|
||||||
const token = await userLogin(server, { username, password })
|
const token = await server.loginCommand.getAccessToken({ username, password })
|
||||||
|
|
||||||
const resMe = await getMyUserInformation(server.url, token)
|
const resMe = await getMyUserInformation(server.url, token)
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ async function generateUserAccessToken (server: ServerInfo, username: string) {
|
||||||
const password = 'my super password'
|
const password = 'my super password'
|
||||||
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
|
||||||
|
|
||||||
return userLogin(server, { username, password })
|
return server.loginCommand.getAccessToken({ username, password })
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerUser (url: string, username: string, password: string, specialStatus = HttpStatusCode.NO_CONTENT_204) {
|
function registerUser (url: string, username: string, password: string, specialStatus = HttpStatusCode.NO_CONTENT_204) {
|
||||||
|
|
Loading…
Reference in New Issue