From eae55a8595e820551fcd5cedd2f9622ef63993ca Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Wed, 2 Mar 2022 12:03:22 -0500 Subject: [PATCH] Fix typo in group removed warning Signed-off-by: Monis Khan --- internal/oidc/token/token_handler.go | 6 +++--- test/integration/supervisor_warnings_test.go | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/oidc/token/token_handler.go b/internal/oidc/token/token_handler.go index 5cd82ada..2ae6705d 100644 --- a/internal/oidc/token/token_handler.go +++ b/internal/oidc/token/token_handler.go @@ -416,12 +416,12 @@ func getDownstreamGroupsFromPinnipedSession(session *psession.PinnipedSession) ( return downstreamGroups, nil } -func warnIfGroupsChanged(ctx context.Context, oldGroups []string, refreshedGroups []string, username string) { - added, removed := diffSortedGroups(oldGroups, refreshedGroups) +func warnIfGroupsChanged(ctx context.Context, oldGroups, newGroups []string, username string) { + added, removed := diffSortedGroups(oldGroups, newGroups) if len(added) > 0 { warning.AddWarning(ctx, "", fmt.Sprintf("User %q has been added to the following groups: %q", username, added)) } if len(removed) > 0 { - warning.AddWarning(ctx, "", fmt.Sprintf("User %q has been removed from the following groups: %q: ", username, removed)) + warning.AddWarning(ctx, "", fmt.Sprintf("User %q has been removed from the following groups: %q", username, removed)) } } diff --git a/test/integration/supervisor_warnings_test.go b/test/integration/supervisor_warnings_test.go index 735926d1..aea7d17b 100644 --- a/test/integration/supervisor_warnings_test.go +++ b/test/integration/supervisor_warnings_test.go @@ -97,6 +97,11 @@ func TestSupervisorWarnings_Browser(t *testing.T) { TLS: &authv1alpha.TLSSpec{CertificateAuthorityData: testCABundleBase64}, }) + const ( + yellowColor = "\u001b[33;1m" + resetColor = "\u001b[0m" + ) + t.Run("LDAP group refresh flow", func(t *testing.T) { if len(env.ToolsNamespace) == 0 && !env.HasCapability(testlib.CanReachInternetLDAPPorts) { t.Skip("LDAP integration test requires connectivity to an LDAP server") @@ -232,8 +237,8 @@ func TestSupervisorWarnings_Browser(t *testing.T) { requireKubectlGetNamespaceOutput(t, env, string(kubectlPtyOutputBytes2)) } // the output should include a warning that the groups have changed. - require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf("User %q has been added to the following groups: %q", env.SupervisorUpstreamLDAP.TestUserMailAttributeValue, env.SupervisorUpstreamLDAP.TestUserDirectGroupsDNs)) - require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf("User %q has been removed from the following groups: [\"some-other-group\" \"some-wrong-group\"]", env.SupervisorUpstreamLDAP.TestUserMailAttributeValue)) + require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf(`%sWarning:%s User %q has been added to the following groups: %q`+"\r\n", yellowColor, resetColor, env.SupervisorUpstreamLDAP.TestUserMailAttributeValue, env.SupervisorUpstreamLDAP.TestUserDirectGroupsDNs)) + require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf(`%sWarning:%s User %q has been removed from the following groups: ["some-other-group" "some-wrong-group"]`+"\r\n", yellowColor, resetColor, env.SupervisorUpstreamLDAP.TestUserMailAttributeValue)) t.Logf("second kubectl command took %s", time.Since(startTime2).String()) }) @@ -431,8 +436,8 @@ func TestSupervisorWarnings_Browser(t *testing.T) { requireKubectlGetNamespaceOutput(t, env, string(kubectlPtyOutputBytes2)) } // the output should include a warning that the groups have changed. - require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf("User %q has been added to the following groups: %q", env.SupervisorUpstreamOIDC.Username, env.SupervisorUpstreamOIDC.ExpectedGroups)) - require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf("User %q has been removed from the following groups: [\"some-other-group\" \"some-wrong-group\"]", env.SupervisorUpstreamOIDC.Username)) + require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf(`%sWarning:%s User %q has been added to the following groups: %q`+"\r\n", yellowColor, resetColor, env.SupervisorUpstreamOIDC.Username, env.SupervisorUpstreamOIDC.ExpectedGroups)) + require.Contains(t, string(kubectlPtyOutputBytes2), fmt.Sprintf(`%sWarning:%s User %q has been removed from the following groups: ["some-other-group" "some-wrong-group"]`+"\r\n", yellowColor, resetColor, env.SupervisorUpstreamOIDC.Username)) t.Logf("second kubectl command took %s", time.Since(startTime2).String()) })