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

feat: allow configuration of display_name for oidc identity providers #1033

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion provider/resource_keycloak_oidc_google_identity_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ func resourceKeycloakOidcGoogleIdentityProvider() *schema.Resource {
},
"display_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Not used by this provider, Will be implicitly Google",
Description: "The human-friendly name of the identity provider, used in the log in form.",
},
"provider_id": {
Type: schema.TypeString,
Expand Down
29 changes: 29 additions & 0 deletions provider/resource_keycloak_oidc_google_identity_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ func TestAccKeycloakOidcGoogleIdentityProvider_basic(t *testing.T) {
})
}

func TestAccKeycloakOidcGoogleIdentityProvider_customDisplayName(t *testing.T) {
resource.Test(t, resource.TestCase{
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckKeycloakOidcGoogleIdentityProviderDestroy(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
data "keycloak_realm" "realm" {
realm = "%s"
}

resource "keycloak_oidc_google_identity_provider" "google" {
realm = data.keycloak_realm.realm.id
client_id = "example_id"
client_secret = "example_token"

display_name = "Example Google"
}
`, testAccRealm.Realm),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOidcGoogleIdentityProviderExists("keycloak_oidc_google_identity_provider.google"),
resource.TestCheckResourceAttr("keycloak_oidc_google_identity_provider.google", "display_name", "Example Google"),
),
},
},
})
}

func TestAccKeycloakOidcGoogleIdentityProvider_extraConfig(t *testing.T) {
customConfigValue := acctest.RandomWithPrefix("tf-acc")

Expand Down
6 changes: 6 additions & 0 deletions provider/resource_keycloak_oidc_identity_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ func resourceKeycloakOidcIdentityProvider() *schema.Resource {
Default: "oidc",
Description: "provider id, is always oidc, unless you have a custom implementation",
},
"display_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The human-friendly name of the identity provider, used in the log in form.",
},
"backchannel_supported": {
Type: schema.TypeBool,
Optional: true,
Expand Down
38 changes: 38 additions & 0 deletions provider/resource_keycloak_oidc_identity_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,44 @@ func TestAccKeycloakOidcIdentityProvider_basic(t *testing.T) {
})
}

func TestAccKeycloakOidcIdentityProvider_customDisplayName(t *testing.T) {
t.Parallel()

oidcName := acctest.RandomWithPrefix("tf-acc")

resource.Test(t, resource.TestCase{
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckKeycloakOidcIdentityProviderDestroy(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
data "keycloak_realm" "realm" {
realm = "%s"
}

resource "keycloak_oidc_identity_provider" "oidc" {
realm = data.keycloak_realm.realm.id
alias = "%s"
authorization_url = "https://example.com/auth"
token_url = "https://example.com/token"
client_id = "example_id"
client_secret = "example_token"

issuer = "hello"

display_name = "Example Provider"
}
`, testAccRealm.Realm, oidcName),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOidcIdentityProviderExists("keycloak_oidc_identity_provider.oidc"),
resource.TestCheckResourceAttr("keycloak_oidc_identity_provider.oidc", "display_name", "Example Provider"),
),
},
},
})
}

func TestAccKeycloakOidcIdentityProvider_extraConfig(t *testing.T) {
t.Parallel()

Expand Down