GODT-1166: Reduce the number of auth for live test

- Changed: Do not reauth controller clients.
- Changed: Verbosisty is set only once before run
- Changed: AddUser takes TestAccount as argument
- Added: Setup/clean up before/after test run
- Added: Access to the current refresh token from pmapi.Client interface.
- Added: Context function to add test a user to bridge without login, just call users.FinishLogin.
- Added: PMAPIController.GetAuthClient returns authenticated client for username.
- Added: Persistent clients does not loggout after every scenario.
- Changed: Disabled no-internet tests.
This commit is contained in:
Jakub
2021-05-19 09:57:36 +02:00
committed by Jakub Cuth
parent 5bf359d34f
commit 0c6a098af9
25 changed files with 334 additions and 86 deletions

View File

@ -51,24 +51,25 @@ func (ctl *Controller) checkScope(uid string) bool {
}
func (ctl *Controller) createSessionIfAuthorized(username string, password []byte) (*fakeSession, error) {
// get user
user, ok := ctl.usersByUsername[username]
if !ok || !bytes.Equal(user.password, password) {
return nil, errWrongNameOrPassword
}
// create session
return ctl.createSession(username, !user.has2FA), nil
}
func (ctl *Controller) createSession(username string, hasFullScope bool) *fakeSession {
session := &fakeSession{
username: username,
uid: ctl.tokenGenerator.next("uid"),
acc: ctl.tokenGenerator.next("acc"),
ref: ctl.tokenGenerator.next("ref"),
hasFullScope: !user.has2FA,
hasFullScope: hasFullScope,
}
ctl.sessionsByUID[session.uid] = session
return session, nil
return session
}
func (ctl *Controller) refreshSessionIfAuthorized(uid, ref string) (*fakeSession, error) {