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

test(account): fix failing team tests #1405

Merged
merged 1 commit into from
Oct 23, 2023
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
5 changes: 4 additions & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ jobs:
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
AIVEN_ORGANIZATION_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
AIVEN_ACCOUNT_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
PKG: ${{matrix.pkg}}

sweep:
Expand Down Expand Up @@ -106,4 +108,5 @@ jobs:
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}

AIVEN_ORGANIZATION_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
AIVEN_ACCOUNT_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"log"
"math/big"
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -133,6 +134,10 @@ func TestAccAivenAccountAuthentication_saml_invalid_certificate(t *testing.T) {
}

func TestAccAivenAccountAuthentication_auto_join_team_id(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ACCOUNT_NAME"); !ok {
t.Skip("AIVEN_ACCOUNT_NAME env variable is required to run this test")
}

resourceName := "aiven_account_authentication.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand Down Expand Up @@ -177,19 +182,21 @@ data "aiven_account_authentication" "auth" {
}

func testAccAccountAuthenticationWithAutoJoinTeamIDResource(name string) string {
orgName := os.Getenv("AIVEN_ACCOUNT_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%[1]s"
}

resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-team-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%[2]s"
}

resource "aiven_account_authentication" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-auth-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-auth-%[2]s"
type = "saml"
enabled = false
auto_join_team_id = aiven_account_team.foo.team_id
Expand All @@ -207,7 +214,7 @@ data "aiven_account_authentication" "auth" {
name = aiven_account_authentication.foo.name

depends_on = [aiven_account_authentication.foo]
}`, name, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountAuthenticationResourceDestroy(s *terraform.State) error {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package account_test

import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
Expand All @@ -10,6 +11,10 @@ import (
)

func TestAccAivenAccountTeamDataSource_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ACCOUNT_NAME"); !ok {
t.Skip("AIVEN_ACCOUNT_NAME env variable is required to run this test")
}

datasourceName := "data.aiven_account_team.team"
resourceName := "aiven_account_team.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package account_test

import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
Expand All @@ -10,6 +11,10 @@ import (
)

func TestAccAivenAccountTeamMemberDataSource_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ACCOUNT_NAME"); !ok {
t.Skip("AIVEN_ACCOUNT_NAME env variable is required to run this test")
}

datasourceName := "data.aiven_account_team_member.member"
resourceName := "aiven_account_team_member.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"os"
"testing"

"github.com/aiven/aiven-go-client/v2"
Expand All @@ -16,6 +17,10 @@ import (
)

func TestAccAivenAccountTeamMember_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ACCOUNT_NAME"); !ok {
t.Skip("AIVEN_ACCOUNT_NAME env variable is required to run this test")
}

resourceName := "aiven_account_team_member.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand All @@ -37,20 +42,22 @@ func TestAccAivenAccountTeamMember_basic(t *testing.T) {
}

func testAccAccountTeamMemberResource(name string) string {
orgName := os.Getenv("AIVEN_ACCOUNT_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%[1]s"
}

resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-team-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%[2]s"
}

resource "aiven_account_team_member" "foo" {
team_id = aiven_account_team.foo.team_id
account_id = aiven_account_team.foo.account_id
user_email = "ivan.savciuc+%[email protected]"
user_email = "ivan.savciuc+%[2][email protected]"
}

data "aiven_account_team_member" "member" {
Expand All @@ -59,7 +66,7 @@ data "aiven_account_team_member" "member" {
user_email = aiven_account_team_member.foo.user_email

depends_on = [aiven_account_team_member.foo]
}`, name, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountTeamMemberResourceDestroy(s *terraform.State) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"os"
"testing"

"github.com/aiven/aiven-go-client/v2"
Expand All @@ -16,6 +17,10 @@ import (
)

func TestAccAivenAccountTeamProject_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ACCOUNT_NAME"); !ok {
t.Skip("AIVEN_ACCOUNT_NAME env variable is required to run this test")
}

resourceName := "aiven_account_team_project.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand All @@ -37,23 +42,25 @@ func TestAccAivenAccountTeamProject_basic(t *testing.T) {
}

func testAccAccountTeamProjectResource(name string) string {
orgName := os.Getenv("AIVEN_ACCOUNT_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%[1]s"
}

resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-team-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%[2]s"
}

resource "aiven_project" "foo" {
project = "test-acc-pr-%s"
project = "test-acc-pr-%[2]s"
account_id = aiven_account_team.foo.account_id
}

resource "aiven_account_team_project" "foo" {
account_id = aiven_account.foo.account_id
account_id = data.aiven_account.foo.account_id
team_id = aiven_account_team.foo.team_id
project_name = aiven_project.foo.project
team_type = "admin"
Expand All @@ -65,7 +72,7 @@ data "aiven_account_team_project" "project" {
project_name = aiven_account_team_project.foo.project_name

depends_on = [aiven_account_team_project.foo]
}`, name, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountTeamProjectResourceDestroy(s *terraform.State) error {
Expand Down
15 changes: 11 additions & 4 deletions internal/sdkprovider/service/account/account_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"os"
"testing"

"github.com/aiven/aiven-go-client/v2"
Expand All @@ -16,6 +17,10 @@ import (
)

func TestAccAivenAccountTeam_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ACCOUNT_NAME"); !ok {
t.Skip("AIVEN_ACCOUNT_NAME env variable is required to run this test")
}

resourceName := "aiven_account_team.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand All @@ -36,13 +41,15 @@ func TestAccAivenAccountTeam_basic(t *testing.T) {
}

func testAccAccountTeamResource(name string) string {
orgName := os.Getenv("AIVEN_ACCOUNT_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%s"
}

resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%s"
}

Expand All @@ -51,7 +58,7 @@ data "aiven_account_team" "team" {
account_id = aiven_account_team.foo.account_id

depends_on = [aiven_account_team.foo]
}`, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountTeamResourceDestroy(s *terraform.State) error {
Expand Down