Verified Commit 41d1d075 authored by Chocobozzz's avatar Chocobozzz
Browse files

Introduce login command

parent 6c5065a0
......@@ -11,7 +11,6 @@ import {
ServerInfo,
setAccessTokensToServers,
uploadVideo,
userLogin,
waitJobs
} from '../../../../shared/extra-utils'
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 })
}
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' })
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' })
......
......@@ -18,7 +18,6 @@ import {
ServerInfo,
setAccessTokensToServers,
uploadVideo,
userLogin,
waitJobs
} from '@shared/extra-utils'
import { AbuseCreate, AbuseState } from '@shared/models'
......@@ -47,7 +46,7 @@ describe('Test abuses API validators', function () {
const username = 'user1'
const password = 'my super 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')
......
......@@ -11,8 +11,7 @@ import {
makeGetRequest,
makePostBodyRequest,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
......@@ -37,7 +36,7 @@ describe('Test blocklist API validators', function () {
const user = { username: 'user1', password: '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])
})
......
......@@ -6,8 +6,7 @@ import {
createUser,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
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' }
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 () {
......
......@@ -11,8 +11,7 @@ import {
makeGetRequest,
makePutBodyRequest,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '@shared/extra-utils'
import { CustomConfig } from '@shared/models'
......@@ -208,7 +207,7 @@ describe('Test config API validators', function () {
password: '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 () {
......
......@@ -7,8 +7,7 @@ import {
createUser,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
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' }
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 () {
......
......@@ -7,8 +7,7 @@ import {
createUser,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
......@@ -32,7 +31,7 @@ describe('Test debug API validators', function () {
password: 'my super 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 () {
......
......@@ -9,8 +9,7 @@ import {
makeDeleteRequest, makeGetRequest,
makePostBodyRequest,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import {
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 })
userAccessToken = await userLogin(server, user)
userAccessToken = await server.loginCommand.getAccessToken(user)
})
describe('When adding follows', function () {
......
......@@ -7,8 +7,7 @@ import {
createUser,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
......@@ -37,7 +36,7 @@ describe('Test jobs API validators', function () {
password: 'my super 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 () {
......
......@@ -17,8 +17,7 @@ import {
ServerInfo,
setAccessTokensToServers,
stopFfmpeg,
uploadVideoAndGetId,
userLogin
uploadVideoAndGetId
} from '../../../../shared/extra-utils'
describe('Test video lives API validator', function () {
......@@ -53,7 +52,7 @@ describe('Test video lives API validator', function () {
const username = 'user1'
const password = 'my super 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)
......@@ -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 })
const accessTokenUser = await userLogin(server, user)
const accessTokenUser = await server.loginCommand.getAccessToken(user)
const res = await getMyUserInformation(server.url, accessTokenUser)
const customChannelId = res.body.videoChannels[0].id
......
......@@ -7,8 +7,7 @@ import {
createUser,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
......@@ -32,7 +31,7 @@ describe('Test logs API validators', function () {
password: 'my super 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 () {
......
......@@ -13,8 +13,7 @@ import {
makePostBodyRequest,
makePutBodyRequest,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '@shared/extra-utils'
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 })
userAccessToken = await userLogin(server, user)
userAccessToken = await server.loginCommand.getAccessToken(user)
{
const res = await server.pluginsCommand.install({ npmName: npmPlugin })
......
......@@ -19,7 +19,6 @@ import {
ServerInfo,
setAccessTokensToServers,
uploadVideoAndGetId,
userLogin,
waitJobs
} 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 })
userAccessToken = await userLogin(servers[0], user)
userAccessToken = await servers[0].loginCommand.getAccessToken(user)
videoIdLocal = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video' })).id
......
......@@ -15,7 +15,6 @@ import {
setDefaultVideoChannel,
updateUser,
uploadVideo,
userLogin,
waitJobs
} from '../../../../shared/extra-utils'
......@@ -50,7 +49,7 @@ describe('Test upload quota', function () {
const user = { username: 'registered' + randomInt(1, 1500), password: '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' }
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' }
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' }
for (let i = 0; i < 5; i++) {
......
......@@ -10,8 +10,7 @@ import {
makeGetRequest,
makePostBodyRequest,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import {
......@@ -41,7 +40,7 @@ describe('Test user subscriptions API validators', function () {
password: 'my super 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 () {
......
......@@ -27,8 +27,7 @@ import {
ServerInfo,
setAccessTokensToServers,
unblockUser,
uploadVideo,
userLogin
uploadVideo
} from '../../../../shared/extra-utils'
import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
import {
......@@ -87,7 +86,7 @@ describe('Test users API validators', function () {
password: user.password,
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
})
moderatorAccessToken = await userLogin(server, moderator)
moderatorAccessToken = await server.loginCommand.getAccessToken(moderator)
}
{
......@@ -394,7 +393,7 @@ describe('Test users API validators', function () {
username: 'user1',
password: 'my super password'
}
userAccessToken = await userLogin(server, user)
userAccessToken = await server.loginCommand.getAccessToken(user)
const fields = {
username: 'user3',
......
......@@ -19,7 +19,6 @@ import {
ServerInfo,
setAccessTokensToServers,
uploadVideo,
userLogin,
waitJobs
} from '@shared/extra-utils'
import { VideoBlacklistType, VideoDetails } from '@shared/models'
......@@ -46,14 +45,14 @@ describe('Test video blacklist API validators', function () {
const username = 'user1'
const password = 'my super 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 password = 'my super 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,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
userLogin
uploadVideo
} from '@shared/extra-utils'
import { VideoCreateResult } from '@shared/models'
......@@ -44,7 +43,7 @@ describe('Test video captions API validator', function () {
password: 'my super 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,
makeUploadRequest,
ServerInfo,
setAccessTokensToServers,
userLogin
setAccessTokensToServers
} from '@shared/extra-utils'
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 })
accessTokenUser = await userLogin(server, user)
accessTokenUser = await server.loginCommand.getAccessToken(user)
}
command = server.channelsCommand
......
......@@ -15,8 +15,7 @@ import {
makePostBodyRequest,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
userLogin
uploadVideo
} from '@shared/extra-utils'
import { VideoCreateResult } from '@shared/models'
......@@ -55,13 +54,13 @@ describe('Test video comments API validator', function () {
{
const user = { username: 'user1', password: 'my super 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' }
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)
}
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment