From 57e0570af5d631dc834983ca77b23cebad671799 Mon Sep 17 00:00:00 2001 From: Guilherme Cassolato Date: Mon, 16 Oct 2023 12:45:29 +0200 Subject: [PATCH 1/2] fix: flaky authconfig conversion tests due to random orderring of elements within array --- api/v1beta2/auth_config_conversion_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/v1beta2/auth_config_conversion_test.go b/api/v1beta2/auth_config_conversion_test.go index 5e4b91f4..64148cfb 100644 --- a/api/v1beta2/auth_config_conversion_test.go +++ b/api/v1beta2/auth_config_conversion_test.go @@ -41,6 +41,12 @@ func TestConvertTo(t *testing.T) { sort.Slice(converted.Spec.Callbacks, func(i, j int) bool { return converted.Spec.Callbacks[i].Name < converted.Spec.Callbacks[j].Name }) + sort.Slice(converted.Spec.DenyWith.Unauthenticated.Headers, func(i, j int) bool { + return converted.Spec.DenyWith.Unauthenticated.Headers[i].Name < converted.Spec.DenyWith.Unauthenticated.Headers[j].Name + }) + sort.Slice(converted.Spec.DenyWith.Unauthorized.Headers, func(i, j int) bool { + return converted.Spec.DenyWith.Unauthorized.Headers[i].Name < converted.Spec.DenyWith.Unauthorized.Headers[j].Name + }) expected := hubAuthConfig() if !reflect.DeepEqual(expected, converted) { From 666d1bda991f89095bfc2f1f5ddc9b6e0cf68e0e Mon Sep 17 00:00:00 2001 From: Guilherme Cassolato Date: Mon, 16 Oct 2023 12:46:55 +0200 Subject: [PATCH 2/2] fix: flaky tests due to weak concurrency coordination using sleep directive --- pkg/evaluators/identity/oidc_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/evaluators/identity/oidc_test.go b/pkg/evaluators/identity/oidc_test.go index 8955fb06..bde5e1f0 100644 --- a/pkg/evaluators/identity/oidc_test.go +++ b/pkg/evaluators/identity/oidc_test.go @@ -111,12 +111,12 @@ func TestOidcProviderRefresh(t *testing.T) { authCredMock := mock_auth.NewMockAuthCredentials(ctrl) - evaluator := NewOIDC(fmt.Sprintf("http://%v", oidcServerHost), authCredMock, 1, context.TODO()) + evaluator := NewOIDC(fmt.Sprintf("http://%v", oidcServerHost), authCredMock, 3, context.TODO()) defer evaluator.Clean(context.Background()) assert.Check(t, evaluator.refresher != nil) - time.Sleep(2 * time.Second) + time.Sleep(4 * time.Second) assert.Equal(t, 2, count) assert.Equal(t, fmt.Sprintf("http://%v/auth?count=2", oidcServerHost), evaluator.provider.Endpoint().AuthURL) }