diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e4dee3e..dabcd386 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ env: GO_VERSION: "1.18" PORT_CLIENT_ID: ${{ secrets.PORT_CLIENT_ID }} PORT_CLIENT_SECRET: ${{ secrets.PORT_CLIENT_SECRET }} + CI_USER_NAME: ${{ secrets.CI_USER_NAME }} jobs: lint: @@ -47,4 +48,4 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Run dialect tests - run: make acctest PORT_CLIENT_ID=${{ secrets.PORT_CLIENT_ID }} PORT_CLIENT_SECRET=${{ secrets.PORT_CLIENT_SECRET }} PORT_BASE_URL=${{ secrets.PORT_BASE_URL }} + run: make acctest CI_USER_NAME=${{ secrets.CI_USER_NAME }} PORT_CLIENT_ID=${{ secrets.PORT_CLIENT_ID }} PORT_CLIENT_SECRET=${{ secrets.PORT_CLIENT_SECRET }} PORT_BASE_URL=${{ secrets.PORT_BASE_URL }} diff --git a/internal/cli/page.go b/internal/cli/page.go index eb064110..5221f926 100644 --- a/internal/cli/page.go +++ b/internal/cli/page.go @@ -40,13 +40,18 @@ func (c *PortClient) CreatePage(ctx context.Context, page *Page) (*Page, error) return nil, err } if !pb.OK { - if resp.IsSuccess() { return nil, nil } return nil, fmt.Errorf("failed to create page, got: %s", resp.Body()) } - return &pb.Page, nil + // For forward compatibility, handle cases where the response body is empty when a page is created. + // The current API response body is { "ok": true, "identifier": "page_identifier" }, + // but it is expected to be the page object in the future to align with other API endpoints. + if pb.Page.Identifier != "" { + return &pb.Page, nil + } + return nil, nil } func (c *PortClient) UpdatePage(ctx context.Context, pageId string, page *Page) (*Page, error) { diff --git a/port/team/resource_test.go b/port/team/resource_test.go index 39dd231c..f65d38fe 100644 --- a/port/team/resource_test.go +++ b/port/team/resource_test.go @@ -3,6 +3,7 @@ package team_test import ( "fmt" "github.com/port-labs/terraform-provider-port-labs/v2/internal/utils" + "os" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -36,6 +37,7 @@ func TestAccPortTeam(t *testing.T) { func TestAccPortTeamUpdate(t *testing.T) { teamName := utils.GenID() + userName := os.Getenv("CI_USER_NAME") var testAccTeamConfigCreate = fmt.Sprintf(` resource "port_team" "team" { name = "%s" @@ -47,8 +49,8 @@ func TestAccPortTeamUpdate(t *testing.T) { resource "port_team" "team" { name = "%s" description = "Test description2" - users = ["pluacbcqsnsqhfvcqs@cazlg.com"] - }`, teamName) + users = ["%s"] + }`, teamName, userName) resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.TestAccPreCheck(t) }, @@ -68,7 +70,7 @@ func TestAccPortTeamUpdate(t *testing.T) { resource.TestCheckResourceAttr("port_team.team", "name", teamName), resource.TestCheckResourceAttr("port_team.team", "description", "Test description2"), resource.TestCheckResourceAttr("port_team.team", "users.#", "1"), - resource.TestCheckResourceAttr("port_team.team", "users.0", "pluacbcqsnsqhfvcqs@cazlg.com"), + resource.TestCheckResourceAttr("port_team.team", "users.0", userName), ), }, }, @@ -115,12 +117,13 @@ func TestAccPortTeamEmptyDescription(t *testing.T) { func TestAccPortTeamImport(t *testing.T) { teamName := utils.GenID() + userName := os.Getenv("CI_USER_NAME") var testAccTeamConfigCreate = fmt.Sprintf(` resource "port_team" "team" { name = "%s" description = "Test description" - users = ["pluacbcqsnsqhfvcqs@cazlg.com"] - }`, teamName) + users = ["%s"] + }`, teamName, userName) resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.TestAccPreCheck(t) }, @@ -132,7 +135,7 @@ func TestAccPortTeamImport(t *testing.T) { resource.TestCheckResourceAttr("port_team.team", "name", teamName), resource.TestCheckResourceAttr("port_team.team", "description", "Test description"), resource.TestCheckResourceAttr("port_team.team", "users.#", "1"), - resource.TestCheckResourceAttr("port_team.team", "users.0", "pluacbcqsnsqhfvcqs@cazlg.com"), + resource.TestCheckResourceAttr("port_team.team", "users.0", userName), ), }, {