Skip to content

Commit a898d79

Browse files
author
Maddie Clayton
authored
Merge branch 'preview' into deleteAC
2 parents 7d4d810 + fb55055 commit a898d79

33 files changed

+3131
-4571
lines changed

src/Common/Commands.Common.Graph.RBAC/ActiveDirectory/ActiveDirectoryClient.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,18 @@ public void RemoveAllSpCredentials(string spObjectId)
689689
PatchSpPasswordCredentials(spObjectId, passwordCredentials: null);
690690
}
691691

692+
public string GetObjectIdFromUPN(string upn)
693+
{
694+
var odataQueryFilter = new Rest.Azure.OData.ODataQuery<User>(s => s.UserPrincipalName == upn);
695+
var user = GraphClient.Users.List(odataQueryFilter.ToString()).SingleOrDefault();
696+
if (user == null)
697+
{
698+
throw new InvalidOperationException(String.Format(ProjectResources.UserWithUPNDoesntExist, upn));
699+
}
700+
701+
return user.ObjectId;
702+
}
703+
692704
public string GetObjectIdFromSPN(string spn)
693705
{
694706
var odataQueryFilter = new Rest.Azure.OData.ODataQuery<ServicePrincipal>(s => s.ServicePrincipalNames.Contains(spn));

src/Common/Commands.Common.Graph.RBAC/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Common/Commands.Common.Graph.RBAC/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,7 @@
144144
<data name="ServicePrincipalWithSPNDoesntExist" xml:space="preserve">
145145
<value>Service principal with SPN '{0}' does not exist.</value>
146146
</data>
147+
<data name="UserWithUPNDoesntExist" xml:space="preserve">
148+
<value>User with UPN '{0}' does not exist.</value>
149+
</data>
147150
</root>

src/ResourceManager/Subscription/AzureRM.Subscription.Preview.Netcore.psd1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ NestedModules = @('.\Microsoft.Azure.Commands.Subscription.dll')
7272
FunctionsToExport = @()
7373

7474
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75-
CmdletsToExport = 'Get-AzureRmSubscriptionDefinition',
76-
'New-AzureRmSubscriptionDefinition'
75+
CmdletsToExport = 'New-AzureRmSubscription'
7776

7877
# Variables to export from this module
7978
# VariablesToExport = @()

src/ResourceManager/Subscription/AzureRM.Subscription.Preview.psd1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ NestedModules = @('.\Microsoft.Azure.Commands.Subscription.dll')
7272
FunctionsToExport = @()
7373

7474
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75-
CmdletsToExport = 'Get-AzureRmSubscriptionDefinition',
76-
'New-AzureRmSubscriptionDefinition'
75+
CmdletsToExport = 'New-AzureRmSubscription'
7776

7877
# Variables to export from this module
7978
# VariablesToExport = @()
@@ -96,7 +95,7 @@ PrivateData = @{
9695
PSData = @{
9796

9897
# Tags applied to this module. These help with module discovery in online galleries.
99-
Tags = 'Azure','ARM','Subscription','SubscriptionDefinition'
98+
Tags = 'Azure','ARM','Subscription'
10099

101100
# A URL to the license for this module.
102101
LicenseUri = 'https://aka.ms/azps-license'

src/ResourceManager/Subscription/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Set minimum dependency of module to PowerShell 5.0
2222

2323
## Version 0.1.2
24+
* New cmdlet New-AzureRmSubscription to enable subscription creation under a specific EA enrollment account.
2425
* Updated to the latest version of the Azure ClientRuntime
2526

2627
## Version 0.1.1

src/ResourceManager/Subscription/Commands.Subscription.Test/Commands.Subscription.Test.csproj

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Management.Subscription, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6666
<SpecificVersion>False</SpecificVersion>
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Subscription.1.0.0-preview\lib\net452\Microsoft.Azure.Management.Subscription.dll</HintPath>
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Subscription.1.1.0-preview\lib\net452\Microsoft.Azure.Management.Subscription.dll</HintPath>
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7070
<SpecificVersion>False</SpecificVersion>
@@ -129,22 +129,16 @@
129129
</ItemGroup>
130130
<ItemGroup>
131131
<Compile Include="Properties\AssemblyInfo.cs" />
132-
<Compile Include="ScenarioTests\SubscriptionDefinitionTests.cs" />
132+
<Compile Include="ScenarioTests\SubscriptionTests.cs" />
133133
<Compile Include="ScenarioTests\TestController.cs" />
134134
</ItemGroup>
135135
<ItemGroup>
136136
<None Include="MSSharedLibKey.snk" />
137137
<None Include="packages.config" />
138-
<None Include="ScenarioTests\SubscriptionDefinitionTests.ps1">
138+
<None Include="ScenarioTests\SubscriptionTests.ps1">
139139
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
140140
</None>
141-
<None Include="SessionRecords\Subscription.Test.ScenarioTests.SubscriptionDefinitionTests\TestGetSubscriptionDefinitionByName.json">
142-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
143-
</None>
144-
<None Include="SessionRecords\Subscription.Test.ScenarioTests.SubscriptionDefinitionTests\TestListSubscriptionDefinitions.json">
145-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
146-
</None>
147-
<None Include="SessionRecords\Subscription.Test.ScenarioTests.SubscriptionDefinitionTests\TestNewSubscriptionDefinition.json">
141+
<None Include="SessionRecords\Subscription.Test.ScenarioTests.SubscriptionTests\TestNewSubscription.json">
148142
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
149143
</None>
150144
</ItemGroup>

src/ResourceManager/Subscription/Commands.Subscription.Test/ScenarioTests/SubscriptionDefinitionTests.ps1

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
namespace Subscription.Test.ScenarioTests
2222
{
2323
/// <summary>
24-
/// The following tests require four subscription definitions to be created manually at this time. This can
25-
/// be done by calling New-AzureRmSubscriptionDefinition. At this time, this can only be done when your tenant is
26-
/// whitelisted by Microsoft.
24+
/// The following tests require four subscriptions to be created manually. This can be done by
25+
/// calling New-AzureRmSubscription. At this time, this can only be done by EA customers.
2726
/// </summary>
28-
public class SubscriptionDefinitionTests
27+
public class SubscriptionTests
2928
{
3029
private XunitTracingInterceptor _logger;
3130

32-
public SubscriptionDefinitionTests(Xunit.Abstractions.ITestOutputHelper output)
31+
public SubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
3332
{
3433
_logger = new XunitTracingInterceptor(output);
3534
XunitTracingInterceptor.AddToContext(_logger);
@@ -38,22 +37,9 @@ public SubscriptionDefinitionTests(Xunit.Abstractions.ITestOutputHelper output)
3837

3938
[Fact]
4039
[Trait(Category.AcceptanceType, Category.CheckIn)]
41-
public void TestListSubscriptionDefinitions()
40+
public void TestNewSubscription()
4241
{
43-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListSubscriptionDefinitions");
44-
}
45-
46-
[Fact]
47-
[Trait(Category.AcceptanceType, Category.CheckIn)]
48-
public void TestGetSubscriptionDefinitionByName()
49-
{
50-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetSubscriptionDefinitionByName");
51-
}
52-
[Fact]
53-
[Trait(Category.AcceptanceType, Category.CheckIn)]
54-
public void TestNewSubscriptionDefinition()
55-
{
56-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscriptionDefinition");
42+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscription");
5743
}
5844
}
5945
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Create subscription
18+
#>
19+
function Test-NewSubscription
20+
{
21+
# $accounts = Get-AzureRmEnrollmentAccount
22+
$accounts = @(@{ ObjectId = "cdf813b6-bdc2-4df5-b150-00ccfd7580e2" })
23+
24+
# Verify the caller has at least one enrollment account.
25+
Assert-True { $accounts.Count -gt 0 }
26+
27+
$myNewSubName = GetAssetName
28+
29+
$newSub = New-AzureRmSubscription -EnrollmentAccountObjectId $accounts[0].ObjectId -Name $myNewSubName -OfferType MS-AZR-0017P
30+
31+
Assert-AreEqual $myNewSubName $newSub.Name
32+
Assert-NotNull $newSub.SubscriptionId
33+
}

src/ResourceManager/Subscription/Commands.Subscription.Test/ScenarioTests/TestController.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using Microsoft.Azure.Gallery;
1717
using Microsoft.Azure.Management.Authorization;
1818
using Microsoft.Azure.Management.Resources;
19-
using Microsoft.Azure.Subscriptions;
2019
using Microsoft.Azure.Test;
2120
using Microsoft.Azure.Test.HttpRecorder;
2221
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
@@ -26,7 +25,6 @@
2625
using System.Collections.Generic;
2726
using System.IO;
2827
using System.Linq;
29-
using SubscriptionDefinitionClient = Microsoft.Azure.Management.Subscription.SubscriptionDefinitionsClient;
3028
using TestBase = Microsoft.Azure.Test.TestBase;
3129
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
3230
using TestUtilities = Microsoft.Azure.Test.TestUtilities;
@@ -41,14 +39,14 @@ public class TestController : RMTestBase
4139

4240
public ResourceManagementClient ResourceManagementClient { get; private set; }
4341

44-
public SubscriptionClient SubscriptionClient { get; private set; }
42+
public Microsoft.Azure.Subscriptions.SubscriptionClient OldSubscriptionClient { get; private set; }
43+
44+
public Microsoft.Azure.Management.Subscription.SubscriptionClient SubscriptionClient { get; private set; }
4545

4646
public GalleryClient GalleryClient { get; private set; }
4747

4848
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
49-
50-
public SubscriptionDefinitionClient SubscriptionDefinitionClient { get; private set; }
51-
49+
5250
public static TestController NewInstance
5351
{
5452
get
@@ -65,17 +63,17 @@ protected TestController()
6563
protected void SetupManagementClients(MockContext context)
6664
{
6765
ResourceManagementClient = GetResourceManagementClient();
68-
SubscriptionClient = GetSubscriptionClient();
66+
OldSubscriptionClient = GetOldSubscriptionClient();
67+
SubscriptionClient = GetSubscriptionClient(context);
6968
GalleryClient = GetGalleryClient();
7069
AuthorizationManagementClient = GetAuthorizationManagementClient();
71-
SubscriptionDefinitionClient = GetSubscriptionDefinitionManagementClient(context);
72-
70+
7371
_helper.SetupManagementClients(
7472
ResourceManagementClient,
73+
OldSubscriptionClient,
7574
SubscriptionClient,
7675
GalleryClient,
77-
AuthorizationManagementClient,
78-
SubscriptionDefinitionClient);
76+
AuthorizationManagementClient);
7977
}
8078

8179
public void RunPowerShellTest(ServiceManagemenet.Common.Models.XunitTracingInterceptor logger, params string[] scripts)
@@ -166,19 +164,19 @@ private AuthorizationManagementClient GetAuthorizationManagementClient()
166164
return TestBase.GetServiceClient<AuthorizationManagementClient>(_csmTestFactory);
167165
}
168166

169-
private SubscriptionClient GetSubscriptionClient()
167+
private Microsoft.Azure.Subscriptions.SubscriptionClient GetOldSubscriptionClient()
170168
{
171-
return TestBase.GetServiceClient<SubscriptionClient>(_csmTestFactory);
169+
return TestBase.GetServiceClient<Microsoft.Azure.Subscriptions.SubscriptionClient>(_csmTestFactory);
172170
}
173171

174-
private GalleryClient GetGalleryClient()
172+
private Microsoft.Azure.Management.Subscription.SubscriptionClient GetSubscriptionClient(MockContext context)
175173
{
176-
return TestBase.GetServiceClient<GalleryClient>(_csmTestFactory);
174+
return context.GetServiceClient<Microsoft.Azure.Management.Subscription.SubscriptionClient>(TestEnvironmentFactory.GetTestEnvironment());
177175
}
178176

179-
private SubscriptionDefinitionClient GetSubscriptionDefinitionManagementClient(MockContext context)
177+
private GalleryClient GetGalleryClient()
180178
{
181-
return context.GetServiceClient<SubscriptionDefinitionClient>(TestEnvironmentFactory.GetTestEnvironment());
179+
return TestBase.GetServiceClient<GalleryClient>(_csmTestFactory);
182180
}
183181
}
184182
}

0 commit comments

Comments
 (0)