Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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 src/EventGrid/EventGrid.Test/EventGrid.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.EventGrid" Version="6.0.0" />
<PackageReference Include="Microsoft.Azure.Management.EventGrid" Version="7.0.0" />
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="4.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Relay" Version="2.0.2" />
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="3.0.0" />
Expand Down
11 changes: 9 additions & 2 deletions src/EventGrid/EventGrid.Test/ScenarioTests/DomainTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public void EventGrid_DomainsCreateGetAndDelete()
EventGridController.NewInstance.RunPsTest(_logger, "DomainTests");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_DomainsidentityTests()
{
EventGridController.NewInstance.RunPsTest(_logger, "DomainIdentityTests");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_DomainsGetKey()
Expand All @@ -59,11 +66,11 @@ public void EventGrid_DomainsInputMappingCreateGetAndDelete()
EventGridController.NewInstance.RunPsTest(_logger, "DomainInputMappingTests");
}

[Fact]
/*[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_DomainTopics()
{
EventGridController.NewInstance.RunPsTest(_logger, "DomainTopicTests");
}
}*/
}
}
67 changes: 67 additions & 0 deletions src/EventGrid/EventGrid.Test/ScenarioTests/DomainTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,73 @@ function DomainTests {
}
}

<#
.SYNOPSIS
Tests EventGrid Domain Identity
#>
function DomainIdentityTests {
# Setup
$location = Get-LocationForEventGrid
$domainName = Get-DomainName
$domainName2 = Get-DomainName
$domainName3 = Get-DomainName
$domainName4 = Get-DomainName

$resourceGroupName = Get-ResourceGroupName
$secondResourceGroup = Get-ResourceGroupName

$subscriptionId = Get-SubscriptionId

New-ResourceGroup $resourceGroupName $location

New-ResourceGroup $secondResourceGroup $location

try
{
Write-Debug "Creating a new EventGrid domain: $domainName in resource group $resourceGroupName"
Write-Debug "Domain: $domainName"
$result = New-AzEventGridDomain -ResourceGroup $resourceGroupName -Name $domainName -Location $location -IdentityType 'SystemAssigned'
Assert-True {$result.ProvisioningState -eq "Succeeded"}
Assert-True {$result.Identity.IdentityType -eq "SystemAssigned"}

Write-Debug "Creating a second EventGrid domain: $domainName2 in resource group $secondResourceGroup with tags and none Identity"
$result = New-AzEventGridDomain -ResourceGroup $secondResourceGroup -Name $domainName2 -Location $location -Tag @{ Dept = "IT"; Environment = "Test" } -IdentityType 'None'
Assert-True {$result.ProvisioningState -eq "Succeeded"}
Assert-True {$result.Identity.IdentityType -eq "None"}

Write-Debug "Creating a third EventGrid domain: $domainName3 in resource group $secondResourceGroup with user assigned identity"
$userIdentity = "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/amh/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testIdentity1"
$result = New-AzEventGridDomain -ResourceGroup $secondResourceGroup -Name $domainName3 -Location $location -IdentityType 'UserAssigned' -IdentityId $userIdentity
Assert-True {$result.ProvisioningState -eq "Succeeded"}
Assert-True {$result.Identity.IdentityType -eq "UserAssigned"} "Domain not created with user identity"



Write-Debug "Deleting domain: $domainName"
Remove-AzEventGridDomain -ResourceGroup $resourceGroupName -Name $domainName

Write-Debug "Deleting domain: $domainName2 using the ResourceID parameter set"
Remove-AzEventGridDomain -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$secondResourceGroup/providers/Microsoft.EventGrid/domains/$domainName2"

Write-Debug "Deleting domain: $domainName3 using the ResourceID parameter"
Remove-AzEventGridDomain -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$secondResourceGroup/providers/Microsoft.EventGrid/domains/$domainName3"

# Remove-AzEventGridDomain -ResourceGroup $secondResourceGroup -Name $domainName3

# Verify that all domains have been deleted correctly
$returnedDomains1 = Get-AzEventGridDomain -ResourceGroup $resourceGroupName
Assert-True {$returnedDomains1.PsDomainsList.Count -eq 0}

$returnedDomains2 = Get-AzEventGridDomain -ResourceGroup $secondResourceGroup
Assert-True {$returnedDomains2.PsDomainsList.Count -eq 0}
}
finally
{
Remove-ResourceGroup $resourceGroupName
Remove-ResourceGroup $secondResourceGroup
}
}

<#
.SYNOPSIS
Tests EventGrid Domain Key retrieval related operations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public void EventGrid_EventSubscription_CustomTopics_WebhookBatching()
EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_CustomTopic_Webhook_Batching");
}

[Fact]
/* not applicable [Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_EventSubscription_CustomTopics_WebhookAad()
{
EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_CustomTopic_Webhook_AAD");
}
}*/

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
Expand Down Expand Up @@ -110,11 +110,11 @@ public void EventGrid_EventSubscription_Domains()
EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_Domains");
}

[Fact]
/* no longer applicable[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_EventSubscription_DomainTopics()
{
EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_DomainTopics");
}
}*/
}
}
48 changes: 48 additions & 0 deletions src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests
{
public class SystemTopicTests : RMTestBase
{
public XunitTracingInterceptor _logger;

public SystemTopicTests(ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_SystemTopicsCRUD()
{
EventGridController.NewInstance.RunPsTest(_logger, "SystemTopicTests");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_SystemTopicsIdentityTests()
{
EventGridController.NewInstance.RunPsTest(_logger, "SystemTopicIdentityTests");
}
}
}
179 changes: 179 additions & 0 deletions src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Tests EventGrid Topic Create, Get and List operations.
#>
function SystemTopicTests {
# Setup
$location = Get-LocationForEventGrid
$topicName = Get-TopicName
$topicName2 = Get-TopicName
$topicName3 = Get-TopicName
$topicName4 = Get-TopicName
$resourceGroupName = Get-ResourceGroupName
$secondResourceGroup = Get-ResourceGroupName
$subscriptionId = Get-SubscriptionId

New-ResourceGroup $resourceGroupName $location

New-ResourceGroup $secondResourceGroup $location

$sbNamespaceName = Get-ServiceBusNameSpaceName
$sbNamespaceName2 = Get-ServiceBusNameSpaceName
$sbNamespaceName3 = Get-ServiceBusNameSpaceName
$sbQueueName = Get-ServiceBusQueueName
$sbTopicName = Get-ServiceBusTopicName

$sbNamespaceInRg1 = New-ServiceBusNamespace $ResourceGroupName $sbNamespaceName $Location

$sbNamespace1InRg2 = New-ServiceBusNamespace $secondResourceGroup $sbNamespaceName2 $Location

$sbNamespace2InRg2 = New-ServiceBusNamespace $secondResourceGroup $sbNamespaceName3 $Location

try
{
Write-Debug "Creating a new EventGrid SystemTopic: $topicName in resource group $resourceGroupName"
Write-Debug "Topic: $topicName"
$result = New-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName -Source $sbNamespaceInRg1.Id -TopicType 'Microsoft.ServiceBus.Namespaces' -Location $location
Assert-True {$result.ProvisioningState -eq "Succeeded"}

Write-Debug "Getting the created topic within the resource group"
$createdTopic = Get-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName
Assert-True {$createdTopic.Count -eq 1}
Assert-True {$createdTopic.TopicName -eq $topicName} "System Topic created earlier is not found."

Write-Debug "Creating a second EventGrid SystemTopic: $topicName2 in resource group $secondResourceGroup"
$result = New-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2 -Source $sbNamespace1InRg2.Id -TopicType 'Microsoft.ServiceBus.Namespaces' -Location $location -Tag @{ Dept = "IT"; Environment = "Test" }
Assert-True {$result.ProvisioningState -eq "Succeeded"}

Write-Debug "Creating a third EventGrid SystemTopic: $topicName3 in resource group $secondResourceGroup"
$result = New-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName3 -Source $sbNamespace2InRg2.Id -TopicType 'Microsoft.ServiceBus.Namespaces' -Location $location
Assert-True {$result.ProvisioningState -eq "Succeeded"}

Write-Debug "Listing all the system topics created in the resourceGroup $secondResourceGroup"
$allCreatedTopics = Get-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup
Assert-True {$allCreatedTopics.PsSystemTopicsList.Count -ge 0 } "Topic created earlier is not found in the list"

Write-Debug "Listing the topics created in the resourceGroup $secondResourceGroup using Top option"
$allCreatedTopics = Get-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Top 1
Assert-True {$allCreatedTopics.NextLink -ne $null } "NextLink should not be null as more topics should be available under resource group.."

Write-Debug "Listing the next topics created in the resourceGroup $secondResourceGroup using NextLink"
$allCreatedTopics = Get-AzEventGridSystemTopic -NextLink $allCreatedTopics.NextLink

Write-Debug "Getting the first 1 topic created in the subscription using Top options"
$allCreatedTopics = Get-AzEventGridSystemTopic -Top 1
Assert-True {$allCreatedTopics.PsSystemTopicsList.Count -ge 0} "SystemTopics created earlier are not found."
Assert-True {$allCreatedTopics.NextLink -ne $null } "NextLink should not be null as more SystemTopics should be available under the azure subscription."

Write-Debug "Getting all the SystemTopics created in the subscription"
$allCreatedTopics = Get-AzEventGridSystemTopic
Assert-True {$allCreatedTopics.PsSystemTopicsList.Count -ge 0} "Topics created earlier are not found."

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName3


}
finally
{
Remove-AzServiceBusNamespace -ResourceGroup $resourceGroupName -Name $sbNamespaceInRg1
Remove-AzServiceBusNamespace -ResourceGroup $secondResourceGroup -Name $sbNamespace1InRg2
Remove-AzServiceBusNamespace -ResourceGroup $secondResourceGroup -Name $sbNamespace2InRg2

Remove-ResourceGroup $resourceGroupName
Remove-ResourceGroup $secondResourceGroup
}
}



<#
.SYNOPSIS
Tests EventGrid system Topic Create with identity
#>
function SystemTopicIdentityTests {
# Setup
$location = Get-LocationForEventGrid
$topicName = Get-TopicName
$topicName2 = Get-TopicName
$topicName3 = Get-TopicName
$topicName4 = Get-TopicName
$resourceGroupName = Get-ResourceGroupName
$secondResourceGroup = Get-ResourceGroupName
$subscriptionId = Get-SubscriptionId

New-ResourceGroup $resourceGroupName $location

New-ResourceGroup $secondResourceGroup $location

$sbNamespaceName = Get-ServiceBusNameSpaceName
$sbNamespaceName2 = Get-ServiceBusNameSpaceName
$sbNamespaceName3 = Get-ServiceBusNameSpaceName
$sbQueueName = Get-ServiceBusQueueName
$sbTopicName = Get-ServiceBusTopicName

$sbNamespaceInRg1 = New-ServiceBusNamespace $ResourceGroupName $sbNamespaceName $Location

$sbNamespace1InRg2 = New-ServiceBusNamespace $secondResourceGroup $sbNamespaceName2 $Location

$sbNamespace2InRg2 = New-ServiceBusNamespace $secondResourceGroup $sbNamespaceName3 $Location

try
{
Write-Debug "Creating a new EventGrid SystemTopic: $topicName in resource group $resourceGroupName"
Write-Debug "Topic: $topicName"
$result = New-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName -Source $sbNamespaceInRg1.Id -TopicType 'Microsoft.ServiceBus.Namespaces' -Location $location -IdentityType 'SystemAssigned'
Assert-True {$result.ProvisioningState -eq "Succeeded"}
Assert-True {$result.Identity.IdentityType -eq "SystemAssigned"}

Write-Debug "Creating a second EventGrid SystemTopic: $topicName2 in resource group $secondResourceGroup"
$result = New-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2 -Source $sbNamespace1InRg2.Id -TopicType 'Microsoft.ServiceBus.Namespaces' -Location $location -IdentityType 'None'
Assert-True {$result.ProvisioningState -eq "Succeeded"}
Assert-True {$result.Identity.IdentityType -eq "None"}

Write-Debug "Updating second EventGrid SystemTopic: $topicName2 in resource group $secondResourceGroup with user assigned identity"
$userIdentity = "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/amh/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testIdentity1"
$result = Update-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2 -IdentityType 'UserAssigned' -IdentityId $userIdentity
Assert-True {$result.ProvisioningState -eq "Succeeded"}
Assert-True {$result.Identity.IdentityType -eq "UserAssigned"}


Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2


}
finally
{
Remove-AzServiceBusNamespace -ResourceGroup $resourceGroupName -Name $sbNamespaceInRg1
Remove-AzServiceBusNamespace -ResourceGroup $secondResourceGroup -Name $sbNamespace1InRg2
Remove-AzServiceBusNamespace -ResourceGroup $secondResourceGroup -Name $sbNamespace2InRg2

Remove-ResourceGroup $resourceGroupName
Remove-ResourceGroup $secondResourceGroup
}
}

7 changes: 7 additions & 0 deletions src/EventGrid/EventGrid.Test/ScenarioTests/TopicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public void EventGrid_TopicsCreateGetAndDelete()
EventGridController.NewInstance.RunPsTest(_logger, "TopicTests");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_TopicsIdentityTests()
{
EventGridController.NewInstance.RunPsTest(_logger, "TopicsIdentityTests");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EventGrid_TopicsSet()
Expand Down
Loading