@@ -480,3 +480,39 @@ func TestVPCPermissions(t *testing.T) {
480480 })
481481 })
482482}
483+
484+ func TestPrivateZonePermissions (t * testing.T ) {
485+ t .Run ("Should include" , func (t * testing.T ) {
486+ t .Run ("create hosted zone permissions when PHZ not specified" , func (t * testing.T ) {
487+ ic := validInstallConfig ()
488+ ic .AWS .HostedZone = ""
489+ requiredPerms := RequiredPermissionGroups (ic )
490+ assert .Contains (t , requiredPerms , PermissionCreateHostedZone )
491+ })
492+ t .Run ("delete hosted zone permissions when PHZ not specified on standard regions" , func (t * testing.T ) {
493+ ic := validInstallConfig ()
494+ ic .AWS .HostedZone = ""
495+ requiredPerms := RequiredPermissionGroups (ic )
496+ assert .Contains (t , requiredPerms , PermissionDeleteHostedZone )
497+ })
498+ })
499+ t .Run ("Should not include" , func (t * testing.T ) {
500+ t .Run ("create hosted zone permissions when PHZ specified" , func (t * testing.T ) {
501+ ic := validInstallConfig ()
502+ requiredPerms := RequiredPermissionGroups (ic )
503+ assert .NotContains (t , requiredPerms , PermissionCreateHostedZone )
504+ })
505+ t .Run ("delete hosted zone permissions" , func (t * testing.T ) {
506+ t .Run ("on secret regions" , func (t * testing.T ) {
507+ ic := validInstallConfig ()
508+ requiredPerms := RequiredPermissionGroups (ic )
509+ assert .NotContains (t , requiredPerms , PermissionDeleteHostedZone )
510+ })
511+ t .Run ("when PHZ specified" , func (t * testing.T ) {
512+ ic := validInstallConfig ()
513+ requiredPerms := RequiredPermissionGroups (ic )
514+ assert .NotContains (t , requiredPerms , PermissionDeleteHostedZone )
515+ })
516+ })
517+ })
518+ }
0 commit comments