Skip to content

Commit

Permalink
Fix tests (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
p53 committed Jul 14, 2022
1 parent 6389b9a commit 565982c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cookies_test.go
Expand Up @@ -395,7 +395,7 @@ func TestCustomCookieNames(t *testing.T) {
c := newFakeKeycloakConfig()
testCase.ProxySettings(c)
p := newFakeProxy(c, &fakeAuthConfig{})
p.idp.setTokenExpiration(1000 * time.Millisecond)
p.idp.setTokenExpiration(2000 * time.Millisecond)
p.RunTests(t, testCase.ExecutionSettings)
},
)
Expand Down
54 changes: 26 additions & 28 deletions middleware_test.go
Expand Up @@ -46,10 +46,12 @@ func TestMetricsMiddleware(t *testing.T) {
cfg.EncryptionKey = testEncryptionKey
requests := []fakeRequest{
{
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: delay,
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: func(int, *resty.Request, *resty.Response) {
<-time.After(time.Duration(int64(2500)) * time.Millisecond)
},
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
},
Expand Down Expand Up @@ -82,24 +84,14 @@ func TestMetricsMiddleware(t *testing.T) {
ExpectedCode: http.StatusOK,
ExpectedContentContains: "action=\"exchange\"",
},
{
URI: cfg.WithOAuthURI(metricsURL),
ExpectedCode: http.StatusOK,
ExpectedContentContains: "action=\"login\"",
},
{
URI: cfg.WithOAuthURI(metricsURL),
ExpectedCode: http.StatusOK,
ExpectedContentContains: "action=\"logout\"",
},
{
URI: cfg.WithOAuthURI(metricsURL),
ExpectedCode: http.StatusOK,
ExpectedContentContains: "action=\"renew\"",
},
}
p := newFakeProxy(cfg, &fakeAuthConfig{})
p.idp.setTokenExpiration(1000 * time.Millisecond)
p.idp.setTokenExpiration(2000 * time.Millisecond)
p.RunTests(t, requests)
}

Expand Down Expand Up @@ -1267,10 +1259,12 @@ func TestAccessTokenEncryption(t *testing.T) {
},
ExecutionSettings: []fakeRequest{
{
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: delay,
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: func(int, *resty.Request, *resty.Response) {
<-time.After(time.Duration(int64(2500)) * time.Millisecond)
},
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
ExpectedLoginCookiesValidator: map[string]func(*testing.T, *Config, string) bool{cfg.CookieAccessName: checkAccessTokenEncryption},
Expand All @@ -1296,10 +1290,12 @@ func TestAccessTokenEncryption(t *testing.T) {
},
ExecutionSettings: []fakeRequest{
{
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: delay,
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: func(int, *resty.Request, *resty.Response) {
<-time.After(time.Duration(int64(2500)) * time.Millisecond)
},
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
ExpectedLoginCookiesValidator: map[string]func(*testing.T, *Config, string) bool{cfg.CookieAccessName: checkAccessTokenEncryption},
Expand All @@ -1326,10 +1322,12 @@ func TestAccessTokenEncryption(t *testing.T) {
},
ExecutionSettings: []fakeRequest{
{
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: delay,
URI: fakeAuthAllURL,
HasLogin: true,
Redirects: true,
OnResponse: func(int, *resty.Request, *resty.Response) {
<-time.After(time.Duration(int64(2500)) * time.Millisecond)
},
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
ExpectedLoginCookiesValidator: map[string]func(*testing.T, *Config, string) bool{cfg.CookieAccessName: checkAccessTokenEncryption},
Expand All @@ -1354,7 +1352,7 @@ func TestAccessTokenEncryption(t *testing.T) {
testCase.Name,
func(t *testing.T) {
testCase.ProxySettings(c)
p := newFakeProxy(c, &fakeAuthConfig{Expiration: 1000 * time.Millisecond})
p := newFakeProxy(c, &fakeAuthConfig{Expiration: 2000 * time.Millisecond})
p.RunTests(t, testCase.ExecutionSettings)
},
)
Expand Down

0 comments on commit 565982c

Please sign in to comment.