Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
41 changes: 41 additions & 0 deletions src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// ----------------------------------------------------------------------------------
//
// 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_TopicsGetKey()
{
EventGridController.NewInstance.RunPsTest(_logger, "SystemTopicTests");
}
}
}
107 changes: 107 additions & 0 deletions src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# ----------------------------------------------------------------------------------
#
# 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
}
}

8 changes: 6 additions & 2 deletions src/EventGrid/EventGrid.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
# Visual Studio Version 16
VisualStudioVersion = 16.0.32228.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventGrid", "EventGrid\EventGrid.csproj", "{07EF53EF-7CB0-4E7D-B41A-BBF96E5357D7}"
EndProject
Expand Down Expand Up @@ -48,6 +48,10 @@ Global
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.Build.0 = Release|Any CPU
{1E60D2AC-DEA7-403C-86DC-7B8C47F54668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E60D2AC-DEA7-403C-86DC-7B8C47F54668}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E60D2AC-DEA7-403C-86DC-7B8C47F54668}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
7 changes: 6 additions & 1 deletion src/EventGrid/EventGrid/Az.EventGrid.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ CmdletsToExport = 'New-AzEventGridTopic', 'Get-AzEventGridTopic',
'Get-AzEventGridDomain', 'Get-AzEventGridDomainTopic',
'Get-AzEventGridDomainKey', 'New-AzEventGridDomainKey',
'Remove-AzEventGridDomain', 'New-AzEventGridDomainTopic',
'Remove-AzEventGridDomainTopic'
'Remove-AzEventGridDomainTopic', 'Get-AzEventGridSystemTopic',
'New-AzEventGridSystemTopic','Update-AzEventGridSystemTopic',
'Remove-AzEventGridSystemTopic', 'Get-AzEventGridFullUrlForSystemTopicEventSubscription',
'Get-AzEventGridSystemTopicEventSubscription', 'New-AzEventGridSystemTopicEventSubscription',
'Remove-AzEventGridSystemTopicEventSubscription', 'Update-AzEventGridSystemTopicEventSubscription',
'Get-AzEventGridSystemTopicEventSubscriptionsDeliveryAttribute'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
2 changes: 2 additions & 0 deletions src/EventGrid/EventGrid/AzureEventGridCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public abstract class AzureEventGridCmdletBase : AzureRMCmdlet
protected const string EventSubscriptionDomainTopicNameParameterSet = "EventSubscriptionDomainTopicNameParameterSet";

protected const string TopicNameParameterSet = "TopicNameParameterSet";
protected const string SystemTopicNameParameterSet = "SystemTopicNameParameterSet";
protected const string SystemTopicEventSuscriptionParameterSet = "SystemTopicEventSuscriptionParameterSet";
protected const string ResourceGroupNameParameterSet = "ResourceGroupNameParameterSet";
protected const string CustomTopicEventSubscriptionParameterSet = "CustomTopicEventSubscriptionParameterSet";
protected const string SubscriptionAndResourceGroupEventSubscriptionParameterSet = "SubscriptionAndResourceGroupEventSubscriptionParameterSet";
Expand Down
73 changes: 72 additions & 1 deletion src/EventGrid/EventGrid/Domain/NewAzureEventGridDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,62 @@ public class NewAzureEventGridDomain : AzureEventGridCmdletBase
[ValidateNotNullOrEmpty]
public string PublicNetworkAccess { get; set; } = EventGridConstants.Enabled;

/// <summary>
/// DisableLocalAuth
/// </summary>
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = EventGridConstants.DisableLocalAuthHelp,
ParameterSetName = DomainNameParameterSet)]
[ValidateSet(EventGridConstants.Enabled, EventGridConstants.Disabled, IgnoreCase = true)]
[ValidateNotNullOrEmpty]
public SwitchParameter DisableLocalAuth { get; set; }

/// <summary>
/// DisableLocalAuth
/// </summary>
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = EventGridConstants.AutoCreateTopicWithFirstSubscriptionHelp,
ParameterSetName = DomainNameParameterSet)]
[ValidateSet(EventGridConstants.Enabled, EventGridConstants.Disabled, IgnoreCase = true)]
[ValidateNotNullOrEmpty]
public SwitchParameter AutoCreateTopicWithFirstSubscription { get; set; }

/// <summary>
/// DisableLocalAuth
/// </summary>
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = EventGridConstants.AutoDeleteTopicWithLastSubscriptionHelp,
ParameterSetName = DomainNameParameterSet)]
[ValidateSet(EventGridConstants.Enabled, EventGridConstants.Disabled, IgnoreCase = true)]
[ValidateNotNullOrEmpty]
public SwitchParameter AutoDeleteTopicWithLastSubscription { get; set; }

/// <summary>
/// string which represents the IdentityType.
/// </summary>
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = EventGridConstants.IdentityTypeHelp,
ParameterSetName = DomainNameParameterSet)]
[ValidateSet("SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None", IgnoreCase = true)]
public string IdentityType { get; set; }

/// <summary>
/// string array of identity ids for user assigned identities
/// </summary>
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = EventGridConstants.IdentityIdsHelp)]
public string[] IdentityIds { get; set; }

public override void ExecuteCmdlet()
{
// Create a new Event Grid Domain
Expand All @@ -130,6 +186,16 @@ public override void ExecuteCmdlet()

EventGridUtils.ValidateInputMappingInfo(this.InputSchema, inputMappingFieldsDictionary, inputMappingDefaultValuesDictionary);

Dictionary<string, UserIdentityProperties> userAssignedIdentities = null;
if (IdentityIds != null && IdentityIds.Length > 0)
{
userAssignedIdentities = new Dictionary<string, UserIdentityProperties>();
foreach (string identityId in IdentityIds)
{
userAssignedIdentities.Add(identityId, new UserIdentityProperties());
}
}

if (this.ShouldProcess(this.Name, $"Create a new EventGrid domain {this.Name} in Resource Group {this.ResourceGroupName}"))
{
Domain domain = this.Client.CreateDomain(
Expand All @@ -141,7 +207,12 @@ public override void ExecuteCmdlet()
inputMappingFieldsDictionary,
inputMappingDefaultValuesDictionary,
inboundIpRuleDictionary,
this.PublicNetworkAccess);
this.PublicNetworkAccess,
this.IdentityType,
userAssignedIdentities,
this.DisableLocalAuth.IsPresent,
this.AutoCreateTopicWithFirstSubscription.IsPresent,
this.AutoDeleteTopicWithLastSubscription.IsPresent);

PSDomain psDomain = new PSDomain(domain);
this.WriteObject(psDomain);
Expand Down
2 changes: 1 addition & 1 deletion src/EventGrid/EventGrid/EventGrid.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" />
</ItemGroup>

</Project>
Loading