diff --git a/keycloak/user.go b/keycloak/user.go index 434bd5c2f..8318d2af6 100644 --- a/keycloak/user.go +++ b/keycloak/user.go @@ -140,7 +140,7 @@ func (keycloakClient *KeycloakClient) GetUserByUsername(ctx context.Context, rea var users []*User params := map[string]string{ - "username": escapeBackslashes(username), + "username": username, } err := keycloakClient.get(ctx, fmt.Sprintf("/realms/%s/users", realmId), &users, params) diff --git a/keycloak/util.go b/keycloak/util.go index c9c9e4b9e..0090c155f 100644 --- a/keycloak/util.go +++ b/keycloak/util.go @@ -49,7 +49,3 @@ func atoiAndTreatEmptyStringAsZero(s string) (int, error) { return strconv.Atoi(s) } - -func escapeBackslashes(s string) string { - return strings.ReplaceAll(s, "\\", "\\\\") -} diff --git a/provider/resource_keycloak_group_memberships_test.go b/provider/resource_keycloak_group_memberships_test.go index bea358eb8..7315ec4e5 100644 --- a/provider/resource_keycloak_group_memberships_test.go +++ b/provider/resource_keycloak_group_memberships_test.go @@ -2,13 +2,14 @@ package provider import ( "fmt" + "regexp" + "strings" + "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/mrparkers/terraform-provider-keycloak/keycloak" - "regexp" - "strings" - "testing" ) func TestAccKeycloakGroupMemberships_basic(t *testing.T) { @@ -35,24 +36,6 @@ func TestAccKeycloakGroupMemberships_basic(t *testing.T) { }) } -func TestAccKeycloakGroupMemberships_basicUserWithBackslash(t *testing.T) { - t.Parallel() - - groupName := acctest.RandomWithPrefix("tf-acc") - username := acctest.RandString(5) + `\\` + acctest.RandString(5) - - resource.Test(t, resource.TestCase{ - ProviderFactories: testAccProviderFactories, - PreCheck: func() { testAccPreCheck(t) }, - Steps: []resource.TestStep{ - { - Config: testKeycloakGroupMemberships_basic(groupName, username), - Check: testAccCheckUserBelongsToGroup("keycloak_group_memberships.group_members", strings.ReplaceAll(username, `\\`, `\`)), - }, - }, - }) -} - func TestAccKeycloakGroupMemberships_moreThan100members(t *testing.T) { t.Parallel()