@@ -76,11 +76,6 @@ resource "github_organization_ruleset" "test" {
7676 bypass_mode = "always"
7777 }
7878
79- bypass_actors {
80- actor_type = "EnterpriseOwner"
81- bypass_mode = "always"
82- }
83-
8479 conditions {
8580 repository_name {
8681 include = ["~ALL"]
@@ -165,16 +160,14 @@ resource "github_organization_ruleset" "test" {
165160 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "name" , rulesetName ),
166161 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "target" , "branch" ),
167162 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "enforcement" , "active" ),
168- resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.#" , "4 " ),
163+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.#" , "3 " ),
169164 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.actor_type" , "DeployKey" ),
170165 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.bypass_mode" , "always" ),
171166 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.1.actor_id" , "5" ),
172167 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.1.actor_type" , "RepositoryRole" ),
173168 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.1.bypass_mode" , "always" ),
174169 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.2.actor_type" , "OrganizationAdmin" ),
175170 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.2.bypass_mode" , "always" ),
176- resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.3.actor_type" , "EnterpriseOwner" ),
177- resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.3.bypass_mode" , "always" ),
178171 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "rules.0.pull_request.0.allowed_merge_methods.#" , "3" ),
179172 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "rules.0.required_workflows.0.do_not_enforce_on_create" , "true" ),
180173 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "rules.0.required_workflows.0.required_workflow.0.path" , workflowFilePath ),
@@ -1403,6 +1396,62 @@ resource "github_organization_ruleset" "test" {
14031396 },
14041397 })
14051398 })
1399+
1400+ t .Run ("create_branch_ruleset_with_enterprise_features" , func (t * testing.T ) {
1401+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
1402+ rulesetName := fmt .Sprintf ("%s-branch-ruleset-%s" , testResourcePrefix , randomID )
1403+
1404+ config := fmt .Sprintf (`
1405+ resource "github_organization_ruleset" "test" {
1406+ name = "%s"
1407+ target = "branch"
1408+ enforcement = "active"
1409+
1410+ conditions {
1411+ ref_name {
1412+ include = ["~ALL"]
1413+ exclude = []
1414+ }
1415+
1416+ repository_name {
1417+ include = ["~ALL"]
1418+ exclude = []
1419+ }
1420+ }
1421+
1422+ bypass_actors {
1423+ actor_type = "EnterpriseOwner"
1424+ bypass_mode = "always"
1425+ }
1426+
1427+ rules {
1428+ branch_name_pattern {
1429+ name = "test"
1430+ negate = false
1431+ operator = "starts_with"
1432+ pattern = "test"
1433+ }
1434+ }
1435+ }
1436+ ` , rulesetName )
1437+
1438+ resource .Test (t , resource.TestCase {
1439+ PreCheck : func () { skipUnlessEnterprise (t ) },
1440+ ProviderFactories : providerFactories ,
1441+ Steps : []resource.TestStep {
1442+ {
1443+ Config : config ,
1444+ Check : resource .ComposeTestCheckFunc (
1445+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "name" , rulesetName ),
1446+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "enforcement" , "active" ),
1447+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.#" , "1" ),
1448+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.actor_type" , "EnterpriseOwner" ),
1449+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.bypass_mode" , "always" ),
1450+ ),
1451+ },
1452+ },
1453+ })
1454+ })
14061455}
14071456
14081457func TestOrganizationPushRulesetSupport (t * testing.T ) {
0 commit comments