@@ -342,25 +342,16 @@ func TestRateLimit(t *testing.T) {
342
342
s .Close ()
343
343
})
344
344
345
- res1 , err := http .Post (s .URL + "/oauth2/sign_in" , "application/json" , bytes .NewReader ([]byte (`{"password":"my-secret -password"}` )))
345
+ resp , err := http .Post (s .URL + "/oauth2/sign_in" , "application/json" , bytes .NewReader ([]byte (`{"password":"bad -password"}` )))
346
346
g .Expect (err ).NotTo (HaveOccurred ())
347
- g .Expect (res1 ).To (HaveHTTPStatus (http .StatusOK ))
347
+ g .Expect (resp ).To (HaveHTTPStatus (http .StatusUnauthorized ))
348
348
349
- g . Eventually ( func () (* http.Response , error ) {
349
+ goodSignIn := func () (* http.Response , error ) {
350
350
return http .Post (s .URL + "/oauth2/sign_in" , "application/json" , bytes .NewReader ([]byte (`{"password":"my-secret-password"}` )))
351
- }).Should (HaveHTTPStatus (http .StatusTooManyRequests ))
352
-
353
- time .Sleep (time .Second )
354
-
355
- res3 , err := http .Post (s .URL + "/oauth2/sign_in" , "application/json" , bytes .NewReader ([]byte (`{"password":"my-secret-password"}` )))
356
- g .Expect (err ).NotTo (HaveOccurred ())
357
- g .Expect (res3 ).To (HaveHTTPStatus (http .StatusOK ))
358
-
351
+ }
352
+ g .Eventually (goodSignIn ).Should (HaveHTTPStatus (http .StatusTooManyRequests ))
359
353
time .Sleep (time .Second )
360
-
361
- res4 , err := http .Post (s .URL + "/oauth2/sign_in" , "application/json" , bytes .NewReader ([]byte (`{"password":"bad-password"}` )))
362
- g .Expect (err ).NotTo (HaveOccurred ())
363
- g .Expect (res4 ).To (HaveHTTPStatus (http .StatusUnauthorized ))
354
+ g .Expect (goodSignIn ()).To (HaveHTTPStatus (http .StatusOK ))
364
355
}
365
356
366
357
func TestUserPrincipalValid (t * testing.T ) {
0 commit comments