Skip to content

Commit

Permalink
add wrong alias test for data keycloak authentication flow
Browse files Browse the repository at this point in the history
  • Loading branch information
David MEJIA committed Feb 18, 2021
1 parent 0a9fa3c commit 41765c6
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion provider/data_source_keycloak_authentication_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package provider

import (
"fmt"
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
Expand Down Expand Up @@ -53,6 +54,23 @@ func testAccCheckDataKeycloakAuthenticationFlow(resourceName string) resource.Te
}
}

func TestAccKeycloakDataSourceAuthenticationExecution_wrongAlias(t *testing.T) {
t.Parallel()
alias := acctest.RandomWithPrefix("tf-acc")

resource.Test(t, resource.TestCase{
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckKeycloakAuthenticationExecutionConfigDestroy,
Steps: []resource.TestStep{
{
Config: testDataSourceKeycloakAuthenticationFlow_wrongAlias(alias),
ExpectError: regexp.MustCompile("no authentication flow found for alias .*"),
},
},
})
}

func testDataSourceKeycloakAuthenticationFlow_basic(alias string) string {
return fmt.Sprintf(`
data "keycloak_realm" "realm" {
Expand All @@ -66,7 +84,29 @@ resource "keycloak_authentication_flow" "flow" {
data "keycloak_authentication_flow" "flow" {
realm_id = data.keycloak_realm.realm.id
alias = keycloak_authentication_flow.flow.alias
alias = keycloak_authentication_flow.flow.alias
depends_on = [
keycloak_authentication_flow.flow,
]
}
`, testAccRealm.Realm, alias)
}

func testDataSourceKeycloakAuthenticationFlow_wrongAlias(alias string) string {
return fmt.Sprintf(`
data "keycloak_realm" "realm" {
realm = "%s"
}
resource "keycloak_authentication_flow" "flow" {
realm_id = data.keycloak_realm.realm.id
alias = "%s"
}
data "keycloak_authentication_flow" "flow" {
realm_id = data.keycloak_realm.realm.id
alias = "foo"
depends_on = [
keycloak_authentication_flow.flow,
Expand Down

0 comments on commit 41765c6

Please # to comment.