Skip to content

Commit

Permalink
simplify regex tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz committed Sep 20, 2023
1 parent 077c387 commit 7232c1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"regexp"
"strings"

"github.com/MakeNowJust/heredoc/v2"
Expand Down Expand Up @@ -145,8 +144,7 @@ func resourceCloudflareAccessIdentityProviderUpdate(ctx context.Context, d *sche
}

scimSecret := d.Get("scim_config.0.secret").(string)
checkRedactedRegex := regexp.MustCompile(`^\*+$`)
if accessIdentityProvider.ScimConfig.Secret != "" && !checkRedactedRegex.MatchString(accessIdentityProvider.ScimConfig.Secret) {
if accessIdentityProvider.ScimConfig.Secret != "" && !strings.Contains(accessIdentityProvider.ScimConfig.Secret, "*") {
scimSecret = accessIdentityProvider.ScimConfig.Secret
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"log"
"os"
"regexp"
"strings"
"testing"

Expand Down Expand Up @@ -285,10 +284,10 @@ func TestAccCloudflareAccessIdentityProvider_SCIM_Config_Secret(t *testing.T) {
return errors.New("secret is empty")
}

checkRedactedRegex := regexp.MustCompile(`^\*+$`)
if checkRedactedRegex.MatchString(value) {
if strings.Contains(value, "*") {
return errors.New("secret was redacted")
}

return nil
}),
)
Expand Down Expand Up @@ -324,10 +323,10 @@ func TestAccCloudflareAccessIdentityProvider_SCIM_Secret_Enabled_After_Resource_
return errors.New("secret is empty")
}

checkRedactedRegex := regexp.MustCompile(`^\*+$`)
if checkRedactedRegex.MatchString(value) {
if strings.Contains(value, "*") {
return errors.New("secret was redacted")
}

return nil
}),
)
Expand Down

0 comments on commit 7232c1a

Please sign in to comment.