-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvements to allow user_ids / permissions to work more robustly
- Loading branch information
Showing
4 changed files
with
92 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,22 +14,61 @@ func TestAccRole(t *testing.T) { | |
"auth0": Provider(), | ||
}, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: testAccRole, | ||
{ | ||
Config: testAccRoleCreate, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("auth0_role.my_role", "name", "Application - Role Acceptance Test"), | ||
resource.TestCheckResourceAttr("auth0_role.my_role", "description", "Test Applications Role Long Description"), | ||
), | ||
}, | ||
{ | ||
Config: testAccRoleUpdate, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("auth0_role.my_role", "description", "Test Applications Role Long Description And Then Some"), | ||
resource.TestCheckResourceAttr("auth0_role.my_role", "user_ids.0", "auth0|neo"), | ||
resource.TestCheckResourceAttr("auth0_role.my_role", "user_ids.1", "auth0|trinity"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccRole = ` | ||
const testAccRoleCreate = ` | ||
provider "auth0" {} | ||
resource "auth0_role" "my_role" { | ||
name = "Application - Role Acceptance Test" | ||
description = "Test Applications Role Long Description" | ||
} | ||
` | ||
|
||
const testAccRoleUpdate = ` | ||
provider "auth0" {} | ||
resource "auth0_user" "neo" { | ||
connection_name = "Username-Password-Authentication" | ||
email = "[email protected]" | ||
username = "neo" | ||
nickname = "neo" | ||
password = "IAmThe#1" | ||
user_id = "neo" | ||
} | ||
resource "auth0_user" "trinity" { | ||
connection_name = "Username-Password-Authentication" | ||
email = "[email protected]" | ||
username = "trinity" | ||
nickname = "trinity" | ||
password = "TheM4trixH4$Y0u" | ||
user_id = "trinity" | ||
} | ||
resource "auth0_role" "my_role" { | ||
name = "Application Role Acceptance Test" | ||
description = "Test Applications Role Long Description And Then Some" | ||
user_ids = [ | ||
auth0_user.neo.id, | ||
auth0_user.trinity.id | ||
] | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
provider "auth0" {} | ||
|
||
resource "auth0_resource_server" "my_resource_server" { | ||
name = "My Resource Server (Managed by Terraform)" | ||
identifier = "my-resource-server-identifier" | ||
signing_alg = "RS256" | ||
token_lifetime = 86400 | ||
name = "My Resource Server (Managed by Terraform)" | ||
identifier = "my-resource-server-identifier" | ||
signing_alg = "RS256" | ||
token_lifetime = 86400 | ||
skip_consent_for_verifiable_first_party_clients = true | ||
|
||
enforce_policies = true | ||
|
||
// Permissions | ||
# Permissions | ||
scopes { | ||
value = "read:something" | ||
value = "read:something" | ||
description = "read something" | ||
} | ||
} | ||
|
||
resource "auth0_user" "user" { | ||
connection_name = "Username-Password-Authentication" | ||
user_id = "auth0|1234567890" | ||
email = "[email protected]" | ||
password = "passpass$12$12" | ||
nickname = "testnick" | ||
user_id = "auth0|1234567890" | ||
email = "[email protected]" | ||
password = "passpass$12$12" | ||
nickname = "testnick" | ||
username = "testnick" | ||
} | ||
|
||
resource "auth0_role" "my_role" { | ||
name = "My Role - (Managed by Terraform)" | ||
name = "My Role - (Managed by Terraform)" | ||
description = "Role Description..." | ||
|
||
user_ids = ["${auth0_user.user.id}"] | ||
user_ids = [ auth0_user.user.id ] | ||
|
||
permissions { | ||
resource_server_identifier = "${auth0_resource_server.my_resource_server.identifier}" | ||
name = "read:something" | ||
resource_server_identifier = auth0_resource_server.my_resource_server.identifier | ||
name = "read:something" | ||
} | ||
} |