Skip to content

Commit

Permalink
fix page permissions (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankilevitch authored Jul 25, 2024
1 parent 5f1f510 commit d0f5f03
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
6 changes: 3 additions & 3 deletions port/page-permissions/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type ReadPagePermissionsModel struct {
}

type PagePermissionsModel struct {
ID types.String `tfsdk:"id"`
PageIdentifier types.String `tfsdk:"page_identifier"`
Read ReadPagePermissionsModel `tfsdk:"read"`
ID types.String `tfsdk:"id"`
PageIdentifier types.String `tfsdk:"page_identifier"`
Read *ReadPagePermissionsModel `tfsdk:"read"`
}
2 changes: 1 addition & 1 deletion port/page-permissions/refreshPagePermissionsToState.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func refreshPagePermissionsState(state *PagePermissionsModel, a *cli.PagePermissions, pageId string) error {
state.ID = types.StringValue(pageId)
state.PageIdentifier = types.StringValue(pageId)
state.Read = ReadPagePermissionsModel{}
state.Read = &ReadPagePermissionsModel{}

state.Read.Users = make([]types.String, len(a.Read.Users))
for i, u := range a.Read.Users {
Expand Down
37 changes: 37 additions & 0 deletions port/page-permissions/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,40 @@ func TestAccPortPagePermissionsUpdateWithUsers(t *testing.T) {
},
})
}

func TestAccPortPagePermissionsImport(t *testing.T) {
pageIdentifier := utils.GenID()
err := os.Setenv("PORT_BETA_FEATURES_ENABLED", "true")
if err != nil {
t.Fatal(err)
}
var testAccPortPageResourceBasic = createPage(pageIdentifier)

var testAccBasePagePermissionsConfigUpdate = `
resource "port_page_permissions" "microservice_permissions" {
page_identifier = port_page.microservice_dashboard_page.identifier
read = {
"roles": [
"Member",
],
"users": [],
"teams": []
}
}`

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.TestAccPreCheck(t) },
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccPortPageResourceBasic + testAccBasePagePermissionsConfigUpdate,
},
{
ResourceName: "port_page_permissions.microservice_permissions",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

0 comments on commit d0f5f03

Please sign in to comment.