@@ -369,6 +369,25 @@ func TestAccConditionalAccessPolicy_insiderRisk(t *testing.T) {
369369 })
370370}
371371
372+ func TestAccConditionalAccessPolicy_guestsOrExternalUsersServiceProviderExternalTenantExcluded (t * testing.T ) {
373+ data := acceptance .BuildTestData (t , "azuread_conditional_access_policy" , "test" )
374+ r := ConditionalAccessPolicyResource {}
375+
376+ data .ResourceTest (t , r , []acceptance.TestStep {
377+ {
378+ Config : r .guestsOrExternalUsersServiceProviderExternalTenantExcluded (data ),
379+ Check : acceptance .ComposeTestCheckFunc (
380+ check .That (data .ResourceName ).ExistsInAzure (r ),
381+ check .That (data .ResourceName ).Key ("id" ).Exists (),
382+ check .That (data .ResourceName ).Key ("display_name" ).HasValue (fmt .Sprintf ("acctest-CONPOLICY-%d" , data .RandomInteger )),
383+ check .That (data .ResourceName ).Key ("conditions.0.users.0.excluded_guests_or_external_users.0.external_tenants.0.membership_kind" ).HasValue ("enumerated" ),
384+ check .That (data .ResourceName ).Key ("conditions.0.users.0.excluded_guests_or_external_users.0.external_tenants.0.members.#" ).HasValue ("1" ),
385+ ),
386+ },
387+ data .ImportStep (),
388+ })
389+ }
390+
372391func (r ConditionalAccessPolicyResource ) Exists (ctx context.Context , clients * clients.Client , state * pluginsdk.InstanceState ) (* bool , error ) {
373392 id , err := stable .ParseIdentityConditionalAccessPolicyID (state .ID )
374393 if err != nil {
@@ -949,3 +968,38 @@ resource "azuread_conditional_access_policy" "test" {
949968}
950969` , data .RandomInteger )
951970}
971+
972+ func (ConditionalAccessPolicyResource ) guestsOrExternalUsersServiceProviderExternalTenantExcluded (data acceptance.TestData ) string {
973+ return fmt .Sprintf (`
974+ resource "azuread_conditional_access_policy" "test" {
975+ display_name = "acctest-CONPOLICY-%[1]d"
976+ state = "disabled"
977+
978+ conditions {
979+ client_app_types = ["browser"]
980+
981+ applications {
982+ included_applications = ["None"]
983+ }
984+
985+ users {
986+ included_users = ["None"]
987+ excluded_guests_or_external_users {
988+ guest_or_external_user_types = ["serviceProvider"]
989+ external_tenants {
990+ membership_kind = "enumerated"
991+ members = [
992+ "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
993+ ]
994+ }
995+ }
996+ }
997+ }
998+
999+ grant_controls {
1000+ operator = "OR"
1001+ built_in_controls = ["block"]
1002+ }
1003+ }
1004+ ` , data .RandomInteger )
1005+ }
0 commit comments