Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into auth0_v1
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkappa authored Sep 17, 2018
2 parents 317c001 + 58acc8b commit e6315fc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To use the provider define the `auth0` provider in your `*.tf` file.

```
provider "auth0" {
"domain" = "<doman>"
"domain" = "<domain>"
"client_id" = "<client-id>"
"client_secret" = "<client-secret>"
}
Expand Down
1 change: 1 addition & 0 deletions auth0/resource_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func buildConnection(d *schema.ResourceData) *management.Connection {
PasswordHistory: options["password_history"].(map[string]interface{}),
PasswordNoPersonalInfo: options["password_no_personal_info"].(map[string]interface{}),
PasswordDictionary: options["password_dictionary"].(map[string]interface{}),

APIEnableUsers: auth0.Bool(options["api_enable_users"].(bool)),
BasicProfile: auth0.Bool(options["basic_profile"].(bool)),
ExtAdmin: auth0.Bool(options["ext_admin"].(bool)),
Expand Down
4 changes: 3 additions & 1 deletion auth0/resource_auth0_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/yieldr/go-auth0/management"
)

var ruleNameRegexp = regexp.MustCompile("^[^\\s-][\\w -]+[^\\s-]$")

func newRule() *schema.Resource {
return &schema.Resource{

Expand All @@ -25,7 +27,7 @@ func newRule() *schema.Resource {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile("^[^\\s-][\\w-]+[^\\s-]$"),
ruleNameRegexp,
"Can only contain alphanumeric characters, spaces and '-'. "+
"Can neither start nor end with '-' or spaces."),
},
Expand Down
44 changes: 44 additions & 0 deletions auth0/resource_auth0_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform/terraform"
)

Expand Down Expand Up @@ -35,3 +36,46 @@ resource "auth0_rule" "my_rule" {
enabled = true
}
`

func TestRuleNameRegexp(t *testing.T) {
testCases := []struct {
name string
valid bool
}{
{
name: "my-rule-1",
valid: true,
},
{
name: "rule 2 name with spaces",
valid: true,
},
{
name: " rule with a space prefix",
valid: false,
},
{
name: "rule with a space suffix ",
valid: false,
},
{
name: " ", // rule with only one space,
valid: false,
},
{
name: " ", // rule with only three spaces,
valid: false,
},
}

vf := validation.StringMatch(ruleNameRegexp, "invalid name")
for _, tc := range testCases {
_, errs := vf(tc.name, "name")
if errs != nil && tc.valid {
t.Fatalf("Expected %q to be valid, but got validation errors %v", tc.name, errs)
}
if errs == nil && !tc.valid {
t.Fatalf("Expected %q to be invalid, but got no validation errors.", tc.name)
}
}
}
1 change: 1 addition & 0 deletions vendor/github.com/yieldr/go-auth0/management/management.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e6315fc

Please sign in to comment.