-
Notifications
You must be signed in to change notification settings - Fork 1
/
auth_mock.go
42 lines (34 loc) · 1.26 KB
/
auth_mock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package adapter
type (
RefreshTokenRecord struct {
UserId string
Token string
RefreshToken string
}
GetTokenRecord struct {
UserId string
Password string
}
TokenResponse struct {
TokenResponseDTO *TokenResponseDTO
Err error
}
AdapterMock struct {
RefreshTokenRecordArray []*RefreshTokenRecord
RefreshTokenResponseArray []*TokenResponse
GetTokenRecordArray []*GetTokenRecord
GetTokenResponseArray []*TokenResponse
}
)
func (mock *AdapterMock) RefreshToken(userId string, token string, refreshToken string) (*TokenResponseDTO, error) {
refreshTokenRecord := &RefreshTokenRecord{UserId: userId, Token: token, RefreshToken: refreshToken}
mock.RefreshTokenRecordArray = append(mock.RefreshTokenRecordArray, refreshTokenRecord)
response := mock.RefreshTokenResponseArray[len(mock.RefreshTokenRecordArray)-1]
return response.TokenResponseDTO, response.Err
}
func (mock *AdapterMock) GetToken(userId string, password string) (*TokenResponseDTO, error) {
getTokenRecord := &GetTokenRecord{UserId: userId, Password: password}
mock.GetTokenRecordArray = append(mock.GetTokenRecordArray, getTokenRecord)
response := mock.GetTokenResponseArray[len(mock.GetTokenRecordArray)-1]
return response.TokenResponseDTO, response.Err
}