mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-22 01:56:44 +00:00
fix: address review comments
This commit is contained in:
@ -35,8 +35,8 @@ func BridgeChecksFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^"([^"]*)" does not have loaded store$`, userDoesNotHaveLoadedStore)
|
||||
s.Step(`^"([^"]*)" has running event loop$`, userHasRunningEventLoop)
|
||||
s.Step(`^"([^"]*)" does not have running event loop$`, userDoesNotHaveRunningEventLoop)
|
||||
s.Step(`^"([^"]*)" does not have API auth$`, doesNotHaveAPIAuth)
|
||||
s.Step(`^"([^"]*)" has API auth$`, hasAPIAuth)
|
||||
s.Step(`^"([^"]*)" does not have API auth$`, isNotAuthorized)
|
||||
s.Step(`^"([^"]*)" has API auth$`, isAuthorized)
|
||||
}
|
||||
|
||||
func bridgeResponseIs(expectedResponse string) error {
|
||||
@ -91,9 +91,7 @@ func userIsConnected(bddUserID string) error {
|
||||
if err != nil {
|
||||
return internalError(err, "getting user %s", account.Username())
|
||||
}
|
||||
a.Eventually(ctx.GetTestingT(), func() bool {
|
||||
return bridgeUser.IsConnected()
|
||||
}, 5*time.Second, 10*time.Millisecond)
|
||||
a.Eventually(ctx.GetTestingT(), bridgeUser.IsConnected, 5*time.Second, 10*time.Millisecond)
|
||||
a.NotEmpty(t, bridgeUser.GetPrimaryAddress())
|
||||
a.NotEmpty(t, bridgeUser.GetStoreAddresses())
|
||||
return ctx.GetTestingError()
|
||||
@ -175,7 +173,7 @@ func userDoesNotHaveRunningEventLoop(bddUserID string) error {
|
||||
return ctx.GetTestingError()
|
||||
}
|
||||
|
||||
func hasAPIAuth(accountName string) error {
|
||||
func isAuthorized(accountName string) error {
|
||||
account := ctx.GetTestAccount(accountName)
|
||||
if account == nil {
|
||||
return godog.ErrPending
|
||||
@ -184,14 +182,11 @@ func hasAPIAuth(accountName string) error {
|
||||
if err != nil {
|
||||
return internalError(err, "getting user %s", account.Username())
|
||||
}
|
||||
a.Eventually(ctx.GetTestingT(),
|
||||
bridgeUser.HasAPIAuth,
|
||||
5*time.Second, 10*time.Millisecond,
|
||||
)
|
||||
a.Eventually(ctx.GetTestingT(), bridgeUser.IsAuthorized, 5*time.Second, 10*time.Millisecond)
|
||||
return ctx.GetTestingError()
|
||||
}
|
||||
|
||||
func doesNotHaveAPIAuth(accountName string) error {
|
||||
func isNotAuthorized(accountName string) error {
|
||||
account := ctx.GetTestAccount(accountName)
|
||||
if account == nil {
|
||||
return godog.ErrPending
|
||||
@ -200,6 +195,6 @@ func doesNotHaveAPIAuth(accountName string) error {
|
||||
if err != nil {
|
||||
return internalError(err, "getting user %s", account.Username())
|
||||
}
|
||||
a.False(ctx.GetTestingT(), bridgeUser.HasAPIAuth())
|
||||
a.Eventually(ctx.GetTestingT(), func() bool { return !bridgeUser.IsAuthorized() }, 5*time.Second, 10*time.Millisecond)
|
||||
return ctx.GetTestingError()
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ func (api *FakePMAPI) Auth(username, password string, authInfo *pmapi.AuthInfo)
|
||||
auth := &pmapi.Auth{
|
||||
TwoFA: user.get2FAInfo(),
|
||||
RefreshToken: session.refreshToken,
|
||||
ExpiresIn: 86400,
|
||||
ExpiresIn: 86400, // seconds
|
||||
}
|
||||
auth.DANGEROUSLYSetUID(session.uid)
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ func (api *FakePMAPI) GetEvent(eventID string) (*pmapi.Event, error) {
|
||||
// Request for empty ID returns the latest event.
|
||||
if eventID == "" {
|
||||
if len(api.events) == 0 {
|
||||
return &pmapi.Event{EventID: ""}, nil
|
||||
return &pmapi.Event{EventID: "first-event-id"}, nil
|
||||
}
|
||||
return api.events[len(api.events)-1], nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user