Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering of redirect_uris in resource okta_app_oauth #1171

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions okta/resource_okta_app_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func resourceAppOAuth() *schema.Resource {
Description: "List of scopes to use for the request",
},
"redirect_uris": {
Type: schema.TypeSet,
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "List of URIs for use in the redirect-based flow. This is required for all application types except service. Note: see okta_app_oauth_redirect_uri for appending to this list in a decentralized way.",
Expand Down Expand Up @@ -596,7 +596,7 @@ func setOAuthClientSettings(d *schema.ResourceData, oauthClient *okta.OpenIdConn
grantTypes[i] = string(*oauthClient.GrantTypes[i])
}
aggMap := map[string]interface{}{
"redirect_uris": convertStringSliceToSet(oauthClient.RedirectUris),
"redirect_uris": oauthClient.RedirectUris,
"response_types": convertStringSliceToSet(respTypes),
"grant_types": convertStringSliceToSet(grantTypes),
"post_logout_redirect_uris": convertStringSliceToSet(oauthClient.PostLogoutRedirectUris),
Expand Down Expand Up @@ -734,7 +734,7 @@ func buildAppOAuth(d *schema.ResourceData) *okta.OpenIdConnectApplication {
InitiateLoginUri: d.Get("login_uri").(string),
LogoUri: d.Get("logo_uri").(string),
PolicyUri: d.Get("policy_uri").(string),
RedirectUris: convertInterfaceToStringSetNullable(d.Get("redirect_uris")),
monde marked this conversation as resolved.
Show resolved Hide resolved
RedirectUris: convertInterfaceToStringArr(d.Get("redirect_uris")),
PostLogoutRedirectUris: convertInterfaceToStringSetNullable(d.Get("post_logout_redirect_uris")),
ResponseTypes: oktaRespTypes,
TosUri: d.Get("tos_uri").(string),
Expand Down
38 changes: 38 additions & 0 deletions okta/resource_okta_app_oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,41 @@ resource "%s" "test" {
client_id = "%s"
}`, appOAuth, name, name, name)
}

// TestAccResourceOktaAppOauth_redirect_uris relates to issue 1170
// Enable terraform to maintain order of redirect_uris
// https://github.com/okta/terraform-provider-okta/issues/1170
func TestAccResourceOktaAppOauth_redirect_uris(t *testing.T) {
resourceName := fmt.Sprintf("%s.test", appOAuth)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProvidersFactories,
CheckDestroy: createCheckResourceDestroy(appOAuth, createDoesAppExist(okta.NewOpenIdConnectApplication())),
Steps: []resource.TestStep{
{
Config: `
resource "okta_app_oauth" "test" {
label = "example"
type = "web"
grant_types = ["authorization_code"]
wildcard_redirect = "SUBDOMAIN"
redirect_uris = [
"https://one.example.com/",
"https://two.example.com/",
"https://*.example.com/"
]
response_types = ["code"]
}
`,
Check: resource.ComposeTestCheckFunc(
ensureResourceExists(resourceName, createDoesAppExist(okta.NewOpenIdConnectApplication())),
resource.TestCheckResourceAttr(resourceName, "redirect_uris.#", "3"),
resource.TestCheckResourceAttr(resourceName, "wildcard_redirect", "SUBDOMAIN"),
resource.TestCheckResourceAttr(resourceName, "redirect_uris.0", "https://one.example.com/"),
resource.TestCheckResourceAttr(resourceName, "redirect_uris.1", "https://two.example.com/"),
resource.TestCheckResourceAttr(resourceName, "redirect_uris.2", "https://*.example.com/"),
),
},
},
})
}