Skip to content

Commit 9c39f5d

Browse files
committed
Updating tests to verify new endpoint
1 parent f1d931b commit 9c39f5d

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

src/Common/Commands.Common.Authentication.Abstractions/AzureEnvironment.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ static IDictionary<string, AzureEnvironment> InitializeBuiltInEnvironments()
7474
DataLakeEndpointResourceId = null,
7575
GraphEndpointResourceId = AzureEnvironmentConstants.ChinaGraphEndpoint,
7676
BatchEndpointResourceId = AzureEnvironmentConstants.ChinaBatchEndpointResourceId,
77-
AzureOperationalInsightsEndpointResourceId = null,
78-
AzureOperationalInsightsEndpoint = null,
7977
AdTenant = "Common"
8078
};
8179
var azureUSGovernment = new AzureEnvironment
@@ -99,8 +97,6 @@ static IDictionary<string, AzureEnvironment> InitializeBuiltInEnvironments()
9997
DataLakeEndpointResourceId = null,
10098
GraphEndpointResourceId = AzureEnvironmentConstants.USGovernmentGraphEndpoint,
10199
BatchEndpointResourceId = AzureEnvironmentConstants.USGovernmentBatchEndpointResourceId,
102-
AzureOperationalInsightsEndpointResourceId = null,
103-
AzureOperationalInsightsEndpoint = null,
104100
AdTenant = "Common"
105101
};
106102
var azureGermany = new AzureEnvironment
@@ -124,8 +120,6 @@ static IDictionary<string, AzureEnvironment> InitializeBuiltInEnvironments()
124120
DataLakeEndpointResourceId = null,
125121
GraphEndpointResourceId = AzureEnvironmentConstants.GermanGraphEndpoint,
126122
BatchEndpointResourceId = AzureEnvironmentConstants.GermanBatchEndpointResourceId,
127-
AzureOperationalInsightsEndpointResourceId = null,
128-
AzureOperationalInsightsEndpoint = null,
129123
AdTenant = "Common"
130124
};
131125
return new Dictionary<string, AzureEnvironment>(StringComparer.InvariantCultureIgnoreCase)
@@ -147,7 +141,7 @@ public static IDictionary<string, AzureEnvironment> PublicEnvironments
147141
{
148142
get
149143
{
150-
if (Interlocked.Exchange(ref _initialized, 1) == 1)
144+
if (Interlocked.Exchange(ref _initialized, 1) == 0)
151145
{
152146
_builtInEnvironments = InitializeBuiltInEnvironments();
153147
}
@@ -270,16 +264,6 @@ public AzureEnvironment(IAzureEnvironment other)
270264
/// </summary>
271265
public string AzureDataLakeStoreFileSystemEndpointSuffix { get; set; }
272266

273-
/// <summary>
274-
/// The token audience required for communicating with the Azure Log Analytics query service in this environment
275-
/// </summary>
276-
public string AzureOperationalInsightsEndpointResourceId { get; set; }
277-
278-
/// <summary>
279-
/// The endpoint to use when communicating with the Azure Log Analytics query service in this environment
280-
/// </summary>
281-
public string AzureOperationalInsightsEndpoint { get; set; }
282-
283267
/// <summary>
284268
/// The name of the default AdTenant in this environment
285269
/// </summary>

src/ResourceManager/Profile/Commands.Profile.Test/AzureRMProfileTests.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ public void ProfileSerializeDeserializeWorks()
671671
Name = "testCloud",
672672
ActiveDirectoryAuthority = "http://contoso.com"
673673
};
674+
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, "http://contoso.io");
675+
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, "http://insights.contoso.io/");
674676
var account = new AzureAccount
675677
{
676678
@@ -713,6 +715,10 @@ public void ProfileSerializeDeserializeWorks()
713715
var jCurrentProfile = currentProfile.ToString();
714716
var jDeserializedProfile = deserializedProfile.ToString();
715717
Assert.Equal(jCurrentProfile, jDeserializedProfile);
718+
Assert.True(deserializedProfile.DefaultContext.Environment.IsPropertySet(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint));
719+
Assert.True(deserializedProfile.DefaultContext.Environment.IsPropertySet(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId));
720+
Assert.Equal("http://contoso.io", deserializedProfile.DefaultContext.Environment.GetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint));
721+
Assert.Equal("http://insights.contoso.io/", deserializedProfile.DefaultContext.Environment.GetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId));
716722
}
717723

718724
[Fact]
@@ -743,11 +749,12 @@ public void SavingProfileWorks()
743749
""BatchEndpointResourceId"": null,
744750
""AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix"": null,
745751
""AzureDataLakeStoreFileSystemEndpointSuffix"": null,
746-
""AzureOperationalInsightsEndpointResourceId"": null,
747-
""AzureOperationalInsightsEndpoint"": null,
748752
""AdTenant"": null,
749753
""VersionProfiles"": [],
750-
""ExtendedProperties"": {}
754+
""ExtendedProperties"": {
755+
""OperationalInsightsEndpoint"": ""http://contoso.io"",
756+
""OperationalInsightsEndpointResourceId"": ""http://insights.contoso.io/""
757+
}
751758
}
752759
},
753760
""Contexts"": {
@@ -797,11 +804,12 @@ public void SavingProfileWorks()
797804
""BatchEndpointResourceId"": null,
798805
""AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix"": null,
799806
""AzureDataLakeStoreFileSystemEndpointSuffix"": null,
800-
""AzureOperationalInsightsEndpointResourceId"": null,
801-
""AzureOperationalInsightsEndpoint"": null,
802807
""AdTenant"": null,
803808
""VersionProfiles"": [],
804-
""ExtendedProperties"": {}
809+
""ExtendedProperties"": {
810+
""OperationalInsightsEndpoint"": ""http://contoso.io"",
811+
""OperationalInsightsEndpointResourceId"": ""http://insights.contoso.io/""
812+
}
805813
},
806814
""VersionProfile"": null,
807815
""TokenCache"": {
@@ -822,6 +830,8 @@ public void SavingProfileWorks()
822830
Name = "testCloud",
823831
ActiveDirectoryAuthority = "http://contoso.com"
824832
};
833+
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, "http://contoso.io");
834+
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, "http://insights.contoso.io/");
825835
var account = new AzureAccount
826836
{
827837

src/ResourceManager/Profile/Commands.Profile.Test/TypeConversionTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ public void CanConvertValidEnvironments(string name, bool onPremise, string acti
124124
environment.TrafficManagerDnsSuffix);
125125
CheckEndpoint(AzureEnvironment.Endpoint.BatchEndpointResourceId, azEnvironment,
126126
environment.BatchEndpointResourceId);
127-
CheckEndpoint(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId, azEnvironment,
127+
CheckEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, azEnvironment,
128128
environment.AzureOperationalInsightsEndpointResourceId);
129-
CheckEndpoint(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint, azEnvironment,
129+
CheckEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, azEnvironment,
130130
environment.AzureOperationalInsightsEndpoint);
131131
Assert.Equal(azEnvironment.Name, environment.Name);
132132
Assert.Equal(azEnvironment.OnPremise, environment.EnableAdfsAuthentication);
@@ -161,8 +161,8 @@ public void CanConvertNullPSEnvironments()
161161
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.StorageEndpointSuffix));
162162
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.TrafficManagerDnsSuffix));
163163
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.BatchEndpointResourceId));
164-
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId));
165-
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint));
164+
Assert.False(environment.IsEndpointSet(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId));
165+
Assert.False(environment.IsEndpointSet(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint));
166166
}
167167
[Theory]
168168
[InlineData("TestAll", true, "https://login.microsoftonline.com", "https://management.core.windows.net/",
@@ -247,9 +247,9 @@ public void CanConvertValidPSEnvironments(string name, bool onPremise, string ac
247247
environment.TrafficManagerDnsSuffix);
248248
CheckEndpoint(AzureEnvironment.Endpoint.BatchEndpointResourceId, azEnvironment,
249249
environment.BatchEndpointResourceId);
250-
CheckEndpoint(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId, azEnvironment,
250+
CheckEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, azEnvironment,
251251
environment.AzureOperationalInsightsEndpointResourceId);
252-
CheckEndpoint(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint, azEnvironment,
252+
CheckEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, azEnvironment,
253253
environment.AzureOperationalInsightsEndpoint);
254254
Assert.Equal(azEnvironment.Name, environment.Name);
255255
Assert.Equal(azEnvironment.OnPremise, environment.EnableAdfsAuthentication);
@@ -302,9 +302,9 @@ private AzureEnvironment CreateEnvironment(string name, bool onPremise, string a
302302
trafficManagerSuffix);
303303
CheckEndpoint(AzureEnvironment.Endpoint.BatchEndpointResourceId, environment,
304304
batchResource);
305-
CheckEndpoint(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId, environment,
305+
CheckEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, environment,
306306
azureOperationalInsightsEndpointResourceId);
307-
CheckEndpoint(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint, environment,
307+
CheckEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, environment,
308308
azureOperationalInsightsEndpoint);
309309
return environment;
310310

0 commit comments

Comments
 (0)