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

bugfix: allow disabling review settings for azuread_access_package_assignment_policy #1394

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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
github.com/hashicorp/terraform-plugin-testing v1.5.1
github.com/manicminer/hamilton v0.68.0
github.com/manicminer/hamilton v0.70.0
golang.org/x/text v0.14.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/manicminer/hamilton v0.68.0 h1:2ZKQRTegktxJIoLBWxI43HczpTiwXl6brvwTXy75gPk=
github.com/manicminer/hamilton v0.68.0/go.mod h1:u80g9rPtJpCG7EC0iayttt8UfeAp6jknClixgZGE950=
github.com/manicminer/hamilton v0.70.0 h1:XMgVcwVtUGq2aBXqVAynaUDZdPXCXC8/rd7D5Zsg3UM=
github.com/manicminer/hamilton v0.70.0/go.mod h1:u80g9rPtJpCG7EC0iayttt8UfeAp6jknClixgZGE950=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@ import (

type RoleEligibilityScheduleRequestResource struct{}

func TestAccRoleEligibilityScheduleRequest_basic(t *testing.T) {
func TestAccRoleEligibilityScheduleRequest_builtin(t *testing.T) {
data := acceptance.BuildTestData(t, "azuread_directory_role_eligibility_schedule_request", "test")
r := RoleEligibilityScheduleRequestResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.builtin(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
})
}

func TestAccRoleEligibilityScheduleRequest_custom(t *testing.T) {
data := acceptance.BuildTestData(t, "azuread_directory_role_eligibility_schedule_request", "test")
r := RoleEligibilityScheduleRequestResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.custom(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand All @@ -48,7 +62,7 @@ func (r RoleEligibilityScheduleRequestResource) Exists(ctx context.Context, clie
return pointer.To(resr.ID != nil && *resr.ID == state.ID), nil
}

func (r RoleEligibilityScheduleRequestResource) basic(data acceptance.TestData) string {
func (r RoleEligibilityScheduleRequestResource) builtin(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azuread" {}

Expand All @@ -74,3 +88,36 @@ resource "azuread_directory_role_eligibility_schedule_request" "test" {
}
`, data.RandomInteger, data.RandomPassword)
}

func (r RoleEligibilityScheduleRequestResource) custom(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azuread" {}

data "azuread_domains" "test" {
only_initial = true
}

resource "azuread_user" "test" {
user_principal_name = "acctestManager.%[1]d@${data.azuread_domains.test.domains.0.domain_name}"
display_name = "acctestManager-%[1]d"
password = "%[2]s"
}

resource "azuread_custom_directory_role" "test" {
display_name = "acctestCustomRole-%[1]d"
enabled = true
version = "1.0"

permissions {
allowed_resource_actions = ["microsoft.directory/applications/standard/read"]
}
}

resource "azuread_directory_role_eligibility_schedule_request" "test" {
role_definition_id = azuread_custom_directory_role.test.object_id
principal_id = azuread_user.test.object_id
directory_scope_id = "/"
justification = "abc"
}
`, data.RandomInteger, data.RandomPassword)
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func TestAccAccessPackageAssignmentPolicy_update(t *testing.T) {
),
},
data.ImportStep(),
{
Config: r.simple(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
11 changes: 11 additions & 0 deletions internal/services/identitygovernance/identitygovernance.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ func expandAssignmentReviewSettings(input []interface{}) (*msgraph.AssignmentRev

result.Reviewers = expandUserSets(in["reviewer"].([]interface{}))

if result.AccessReviewTimeoutBehavior == "" &&
(result.DurationInDays == nil || *result.DurationInDays == 0) &&
(result.IsAccessRecommendationEnabled == nil || !*result.IsAccessRecommendationEnabled) &&
(result.IsApprovalJustificationRequired == nil || !*result.IsApprovalJustificationRequired) &&
(result.IsEnabled == nil || !*result.IsEnabled) &&
result.RecurrenceType == "" &&
result.ReviewerType == "" &&
(result.Reviewers == nil || len(*result.Reviewers) == 0) {
return nil, nil
}

return &result, nil
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

165 changes: 165 additions & 0 deletions vendor/github.com/manicminer/hamilton/msgraph/attribute_set.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading