public void GetPlan() { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ 'id': '/subscriptions/7354d868-a0a8-47b0-9566-6e753aec1754/resourceGroups/TestRG/providers/Microsoft.Subscriptions.Admin/plans/TestPlan', 'name': 'TestPlan', 'type': 'Microsoft.Subscriptions.Admin/plans', 'location': 'local', 'properties': { 'name': 'TestPlan', 'displayName': 'TestPlan', 'subscriptionCount': 0, 'quotaIds': [ '/subscriptions/7354d868-a0a8-47b0-9566-6e753aec1754/providers/Microsoft.Sql.Admin/locations/local/quotas/Default_BasicTierQuota' ] } }") }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ManagedPlans.Get("TestRG", "TestPlan"); // Validate Headers Assert.Equal(HttpMethod.Get, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal("TestPlan", result.Plan.Name); Assert.Equal("local", result.Plan.Location); Assert.Equal(0, result.Plan.Properties.SubscriptionCount); Assert.Equal("/subscriptions/7354d868-a0a8-47b0-9566-6e753aec1754/providers/Microsoft.Sql.Admin/locations/local/quotas/Default_BasicTierQuota", result.Plan.Properties.QuotaIds[0]); }
public void GetLocation() { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ 'id': '/subscriptions/7b9e2b97-c218-4577-9582-6f390d5cd2e7/providers/Microsoft.Subscriptions.Admin/locations/chicago', 'name': 'chicago', 'displayName': 'chicago', 'latitude': '80.5', 'longitude': '-45.5' }") }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ManagedLocations.Get("chicago"); // Validate Headers Assert.Equal(HttpMethod.Get, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal("chicago", result.Location.Name); Assert.Equal("-45.5", result.Location.Longitude); Assert.Equal("80.5", result.Location.Latitude); Assert.Equal("chicago", result.Location.DisplayName); }
public void GetSubscription() { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ 'id': '/subscriptions/7B9E2B97-C218-4577-9582-6F390D5CD2E7/providers/Microsoft.Subscriptions/subscriptions/001f675f-daad-4357-993f-2203a22a1935', 'subscriptionId': '001f675f-daad-4357-993f-2203a22a1935', 'displayName': 'TestUser', 'owner': '*****@*****.**', 'tenantId': '4993704a-4e53-4e79-95dd-5f1747eb7554', 'offerId': '/subscriptions/7B9E2B97-C218-4577-9582-6F390D5CD2E7/resourceGroups/TestRG/providers/Microsoft.Subscriptions.Admin/offers/TestOffer', 'state': 'Enabled' }") }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ManagedSubscriptions.Get("001f675f-daad-4357-993f-2203a22a1935"); // Validate Headers Assert.Equal(HttpMethod.Get, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal("001f675f-daad-4357-993f-2203a22a1935", result.Subscription.SubscriptionId); Assert.Equal("/subscriptions/7B9E2B97-C218-4577-9582-6F390D5CD2E7/resourceGroups/TestRG/providers/Microsoft.Subscriptions.Admin/offers/TestOffer", result.Subscription.OfferId); Assert.Equal("*****@*****.**", result.Subscription.Owner); Assert.Equal(SubscriptionState.Enabled, result.Subscription.State); Assert.Equal("4993704a-4e53-4e79-95dd-5f1747eb7554", result.Subscription.TenantId); }
public void GetOffer() { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ 'id': '/subscriptions/ade8c959-cf50-475a-83f1-5851c07902de/resourceGroups/TestRG/providers/Microsoft.Subscriptions.Admin/offers/TestOffer', 'name': 'TestOffer', 'type': 'Microsoft.Subscriptions.Admin/offers', 'location': 'local', 'properties': { 'name': 'TestOffer', 'displayName': 'TestOffer', 'state': 'Private', 'subscriptionCount': 0, 'maxSubscriptionsPerAccount': 2, 'basePlanIds': [ '/subscriptions/ADE8C959-CF50-475A-83F1-5851C07902DE/resourceGroups/TestRG/providers/Microsoft.Subscriptions.Admin/plans/TestPlan' ], 'addonPlans': [ ] } }") }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ManagedOffers.Get("TestRG", "TestOffer"); // Validate Headers Assert.Equal(HttpMethod.Get, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal("TestOffer", result.Offer.Name); Assert.Equal("local", result.Offer.Location); Assert.Equal(0, result.Offer.Properties.SubscriptionCount); Assert.Equal(2, result.Offer.Properties.MaxSubscriptionsPerAccount); Assert.Equal(AccessibilityState.Private, result.Offer.Properties.State); Assert.Equal("/subscriptions/ADE8C959-CF50-475A-83F1-5851C07902DE/resourceGroups/TestRG/providers/Microsoft.Subscriptions.Admin/plans/TestPlan", result.Offer.Properties.BasePlanIds[0]); Assert.Equal(0, result.Offer.Properties.AddonPlans.Count); }
public AzureStackClient GetAzureStackAdminClient(RecordedDelegatingHandler handler) { var token = new TokenCloudCredentials(Guid.NewGuid().ToString(), "abc123"); handler.IsPassThrough = false; return new AzureStackClient(new Uri("https://armuri"), token, "2015-11-01").WithHandler(handler); }
public void DeleteLocation() { var response = new HttpResponseMessage(HttpStatusCode.OK); var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ManagedLocations.Delete("chicago"); // Validate headers Assert.Equal(HttpMethod.Delete, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal(HttpStatusCode.OK, result.StatusCode); }
public void GetResourceProviderManifest() { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ 'id': '/subscriptions/b5c4cce5-bf48-4c87-a083-eb99fda1f60e/resourceGroups/System/providers/Microsoft.Subscriptions.Providers/manifests/Microsoft.Sql.Admin', 'name': 'Microsoft.Sql.Admin', 'type': 'Microsoft.Subscriptions.Providers/manifests', 'location': 'local', 'properties': { 'displayName': 'Microsoft.Sql.Admin', 'namespace': 'Microsoft.Sql.Admin', 'providerLocation': 'local', 'providerType': 'NotSpecified', 'extensions': [ { 'name': 'SqlAdminExtension', 'uri': 'https://azstack:13002/' } ], 'resourceTypes': [ { 'name': 'hostingservers', 'routingType': 'Default', 'resourceDeletionPolicy': 'NotSpecified', 'endpoints': [ { 'apiVersions': [ '2014-04-01-preview' ], 'enabled': true, 'endpointUri': 'https://azstack:30010', 'timeout': 'PT0S' } ], 'marketplaceType': 'NotSpecified' } ], 'enabled': true, 'provisioningState': 'Succeeded' } }") }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ProviderRegistrations.Get("TestRG", "Microsoft.Sql.Admin"); // Validate Headers Assert.Equal(HttpMethod.Get, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal("Microsoft.Sql.Admin", result.ProviderRegistration.Name); Assert.Equal("local", result.ProviderRegistration.Location); Assert.Equal("Microsoft.Sql.Admin", result.ProviderRegistration.Properties.Namespace); Assert.Equal("local", result.ProviderRegistration.Properties.ProviderLocation); Assert.Equal("hostingservers", result.ProviderRegistration.Properties.ResourceTypes[0].Name); Assert.Equal("hostingservers", result.ProviderRegistration.Properties.Extensions[0].Name); Assert.Equal("2014-04-01-preview", result.ProviderRegistration.Properties.ResourceTypes[0].Endpoints[0].ApiVersions[0]); Assert.Equal("https://azstack:30010", result.ProviderRegistration.Properties.ResourceTypes[0].Endpoints[0].EndpointUri); Assert.Equal(new TimeSpan(0, 0, 0), result.ProviderRegistration.Properties.ResourceTypes[0].Endpoints[0].Timeout); Assert.Equal(true, result.ProviderRegistration.Properties.ResourceTypes[0].Endpoints[0].Enabled); Assert.Equal(RoutingType.Default, result.ProviderRegistration.Properties.ResourceTypes[0].RoutingType); Assert.Equal(ResourceDeletionPolicy.NotSpecified, result.ProviderRegistration.Properties.ResourceTypes[0].ResourceDeletionPolicy); Assert.Equal(MarketplaceType.NotSpecified, result.ProviderRegistration.Properties.ResourceTypes[0].MarketplaceType); // Assert.Equal(ProvisioningState.Succeeded, result.ProviderRegistration.Properties.ProvisioningState); }
public void DeleteResourceProviderManifest() { var response = new HttpResponseMessage(HttpStatusCode.OK); var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ProviderRegistrations.Delete("system", "Microsoft.Sql.Admin"); // Validate headers Assert.Equal(HttpMethod.Delete, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal(HttpStatusCode.OK, result.StatusCode); }
public void CreateOrUpdatePlan() { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ 'id': '/subscriptions/7354d868-a0a8-47b0-9566-6e753aec1754/resourceGroups/TestRG-3e1d9655-b0c4-487d-9b9e-027748e8914d/providers/Microsoft.Subscriptions.Admin/plans/TestPlan', 'name': 'TestPlan', 'type': 'Microsoft.Subscriptions.Admin/plans', 'location': 'local', 'properties': { 'name': 'TestPlan', 'displayName': 'TestPlan', 'subscriptionCount': 0, 'quotaIds': [ '/subscriptions/7354d868-a0a8-47b0-9566-6e753aec1754/providers/Microsoft.Sql.Admin/locations/local/quotas/Default_BasicTierQuota' ] } }") }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = this.GetAzureStackAdminClient(handler); var result = client.ManagedPlans.CreateOrUpdate( "TestRG", new ManagedPlanCreateOrUpdateParameters() { Plan = new AdminPlanModel() { Location = "local", Name = "TestPlan", Properties = new AdminPlanPropertiesDefinition() { Name = "TestPlan", DisplayName = "TestPlan", QuotaIds = new []{"/subscriptions/7354d868-a0a8-47b0-9566-6e753aec1754/providers/Microsoft.Sql.Admin/locations/local/quotas/Default_BasicTierQuota"} } } } ); // Validate Headers Assert.Equal(HttpMethod.Put, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("Authorization")); // Validate result Assert.Equal("TestPlan", result.Plan.Name); Assert.Equal("local", result.Plan.Location); Assert.Equal(0, result.Plan.Properties.SubscriptionCount); Assert.Equal("/subscriptions/7354d868-a0a8-47b0-9566-6e753aec1754/providers/Microsoft.Sql.Admin/locations/local/quotas/Default_BasicTierQuota", result.Plan.Properties.QuotaIds[0]); }