Skip to content

Commit

Permalink
Merge pull request #3 from devlead/feature/site
Browse files Browse the repository at this point in the history
Add properties
  • Loading branch information
devlead authored Dec 8, 2023
2 parents dbae568 + b374941 commit 5741856
Show file tree
Hide file tree
Showing 47 changed files with 3,376 additions and 584 deletions.
7 changes: 7 additions & 0 deletions src/ARI.Tests/ARI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
<ItemGroup>
<None Remove="Resources\GraphOrg.json" />
<None Remove="Resources\Subscription1_ResourceGroup1_Resources.json" />
<None Remove="Resources\Subscription1_ResourceGroup1_Site_Config.json" />
<None Remove="Resources\Subscription1_ResourceGroup2_Resources.json" />
<None Remove="Resources\Subscription1_ResourceGroup2_Site_Config.json" />
<None Remove="Resources\Subscription1_ResourceGroup3_Resources.json" />
<None Remove="Resources\Subscription1_ResourceGroup3_Site_Config.json" />
<None Remove="Resources\Subscription1_ResourceGroups.json" />
<None Remove="Resources\Subscription2_ResourceGroup1_Resources.json" />
<None Remove="Resources\Subscription2_ResourceGroups.json" />
Expand All @@ -20,9 +23,12 @@

<ItemGroup>
<EmbeddedResource Include="Resources\GraphOrg.json" />
<EmbeddedResource Include="Resources\Subscription1_ResourceGroup1_Site_Config.json" />
<EmbeddedResource Include="Resources\Subscription1_ResourceGroup2_Site_Config.json" />
<EmbeddedResource Include="Resources\Subscription1_ResourceGroup3_Resources.json" />
<EmbeddedResource Include="Resources\Subscription1_ResourceGroup2_Resources.json" />
<EmbeddedResource Include="Resources\Subscription1_ResourceGroup1_Resources.json" />
<EmbeddedResource Include="Resources\Subscription1_ResourceGroup3_Site_Config.json" />
<EmbeddedResource Include="Resources\Subscription2_ResourceGroup1_Resources.json" />
<EmbeddedResource Include="Resources\Subscription2_ResourceGroups.json" />
<EmbeddedResource Include="Resources\Subscriptions.json" />
Expand All @@ -41,6 +47,7 @@
<Using Include="ARI.Tests.Extensions" />
<Using Include="ARI.Services" />
<Using Include="ARI.Services.ARM" />
<Using Include="ARI.Services.Markdown" />
<Using Include="ARI.Extensions" />
</ItemGroup>

Expand Down
38 changes: 37 additions & 1 deletion src/ARI.Tests/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ public static class Subscription1
public static class ResourceGroup1
{
public const string Name = "lab-dev";
public static class Site
{
public const string Name = "lab-web-web-dev";
}
}
public static class ResourceGroup2
{
public const string Name = "lab-stg";
public static class Site
{
public const string Name = "lab-web-web-stg";
}
}
public static class ResourceGroup3
{
public const string Name = "lab-prd";
public static class Site
{
public const string Name = "lab-web-web-prd";
}
}
}
public static class Subscription2
Expand Down Expand Up @@ -55,14 +67,26 @@ public static class Subscription1
public static class ResourceGroup1
{
public const string Resources = $"https://management.azure.com/subscriptions/{Tenant.Subscription1.Id}/resourceGroups/{Tenant.Subscription1.ResourceGroup1.Name}/resources?$expand=createdTime,changedTime,provisioningState&api-version=2021-04-01";
public static class Site
{
public const string Config = $"https://management.azure.com/subscriptions/{Tenant.Subscription1.Id}/resourceGroups/{Tenant.Subscription1.ResourceGroup1.Name}/providers/Microsoft.Web/sites/{Tenant.Subscription1.ResourceGroup1.Site.Name}/config?api-version=2022-03-01";
}
}
public static class ResourceGroup2
{
public const string Resources = $"https://management.azure.com/subscriptions/{Tenant.Subscription1.Id}/resourceGroups/{Tenant.Subscription1.ResourceGroup2.Name}/resources?$expand=createdTime,changedTime,provisioningState&api-version=2021-04-01";
public static class Site
{
public const string Config = $"https://management.azure.com/subscriptions/{Tenant.Subscription1.Id}/resourceGroups/{Tenant.Subscription1.ResourceGroup2.Name}/providers/Microsoft.Web/sites/{Tenant.Subscription1.ResourceGroup2.Site.Name}/config?api-version=2022-03-01";
}
}
public static class ResourceGroup3
{
public const string Resources = $"https://management.azure.com/subscriptions/{Tenant.Subscription1.Id}/resourceGroups/{Tenant.Subscription1.ResourceGroup3.Name}/resources?$expand=createdTime,changedTime,provisioningState&api-version=2021-04-01";
public static class Site
{
public const string Config = $"https://management.azure.com/subscriptions/{Tenant.Subscription1.Id}/resourceGroups/{Tenant.Subscription1.ResourceGroup3.Name}/providers/Microsoft.Web/sites/{Tenant.Subscription1.ResourceGroup3.Site.Name}/config?api-version=2022-03-01";
}
}
}

Expand Down Expand Up @@ -92,14 +116,26 @@ public static class Subscription1
public static class ResourceGroup1
{
public static string Resources { get; } = GetResourceString($"{nameof(Subscription1)}_{nameof(ResourceGroup1)}_{nameof(Resources)}.json");
public static class Site
{
public static string Config { get; } = GetResourceString($"{nameof(Subscription1)}_{nameof(ResourceGroup1)}_{nameof(Site)}_{nameof(Config)}.json");
}
}
public static class ResourceGroup2
{
public static string Resources { get; } = GetResourceString($"{nameof(Subscription1)}_{nameof(ResourceGroup2)}_{nameof(Resources)}.json");
public static class Site
{
public static string Config { get; } = GetResourceString($"{nameof(Subscription1)}_{nameof(ResourceGroup2)}_{nameof(Site)}_{nameof(Config)}.json");
}
}
public static class ResourceGroup3
{
public static string Resources { get; } = GetResourceString($"{nameof(Subscription1)}_{nameof(ResourceGroup3)}_{nameof(Resources)}.json");
public static class Site
{
public static string Config { get; } = GetResourceString($"{nameof(Subscription1)}_{nameof(ResourceGroup3)}_{nameof(Site)}_{nameof(Config)}.json");
}
}
}

Expand All @@ -108,7 +144,7 @@ public static class Subscription2
public static string ResourceGroups { get; } = GetResourceString($"{nameof(Subscription2)}_{nameof(ResourceGroups)}.json");
public static class ResourceGroup1
{
public static string Resources { get; } = GetResourceString($"{nameof(Subscription1)}_{nameof(ResourceGroup1)}_{nameof(Resources)}.json");
public static string Resources { get; } = GetResourceString($"{nameof(Subscription2)}_{nameof(ResourceGroup1)}_{nameof(Resources)}.json");
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/ARI.Tests/Extensions/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ static MockHttpClient CreateClient()
RequestUri.AbsoluteUri: Constants.Request.Uri.Subscription2.ResourceGroup1.Resources
} => GetMockJsonResponse(Constants.Response.Json.Subscription2.ResourceGroup1.Resources),

{
Method.Method: Constants.Request.Method.Get,
RequestUri.AbsoluteUri: Constants.Request.Uri.Subscription1.ResourceGroup1.Site.Config
} => GetMockJsonResponse(Constants.Response.Json.Subscription1.ResourceGroup1.Site.Config),

{
Method.Method: Constants.Request.Method.Get,
RequestUri.AbsoluteUri: Constants.Request.Uri.Subscription1.ResourceGroup2.Site.Config
} => GetMockJsonResponse(Constants.Response.Json.Subscription1.ResourceGroup2.Site.Config),

{
Method.Method: Constants.Request.Method.Get,
RequestUri.AbsoluteUri: Constants.Request.Uri.Subscription1.ResourceGroup3.Site.Config
} => GetMockJsonResponse(Constants.Response.Json.Subscription1.ResourceGroup3.Site.Config),

_ => new HttpResponseMessage
{
StatusCode = System.Net.HttpStatusCode.NotFound
Expand Down
2 changes: 2 additions & 0 deletions src/ARI.Tests/Fixture/ARIServiceProviderFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public static ServiceProvider GetServiceProvider(Func<IServiceCollection, IServi
.AddSingleton<SubscriptionService>()
.AddSingleton<ResourceGroupService>()
.AddSingleton<ResourceService>()
.AddSingleton<WebAppConfigService>()
.AddSingleton<MarkdownServiceBase, WebAppConfigServiceMarkdownService>()
.AddMockHttpClient();

return (configure?.Invoke(serviceCollection) ?? serviceCollection).BuildServiceProvider();
Expand Down
68 changes: 58 additions & 10 deletions src/ARI.Tests/Fixture/MocksFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
using ARI.Models.Tenant.Subscription;
using ARI.Models.Tenant.Subscription.ResourceGroup;
using ARI.Models.Tenant.Subscription.ResourceGroup.Resource;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Nodes;

namespace ARI.Tests.Fixture;
public static class MocksFixture
{
public static AzureTenant AzureTenant { get; } = new (
public static AzureTenant AzureTenant { get; } = new AzureTenant(
"Id",
"TenantId",
"CountryCode",
"DisplayName",
new[] { "Domain1", "Domain2" },
"TenantCategory",
"DefaultDomain",
"TenantType",
"TenantBrandingLogoUrl"
);
public static Subscription Subscription { get; } = new(
) with {
TenantId = "TenantId"
};
public static Subscription Subscription { get; } = new Subscription(
"Id",
"SubscriptionId",
"TenantId",
"DisplayName",
"State",
new SubscriptionPolicies(
Expand All @@ -31,7 +31,11 @@ public static class MocksFixture
),
"AuthorizationSource",
Array.Empty<ManagedByTenant>()
);
) with
{
TenantId = "TenantId",
SubscriptionId = "SubscriptionId"
};
public static IDictionary<string, string> Tags { get; } = new AzureResourceTags
{
{ "Tag3", "Value4" },
Expand All @@ -40,7 +44,7 @@ public static class MocksFixture
{ "Tag0", "Value3" }
}.AsReadOnly();

public static ResourceGroup ResourceGroup { get; } = new(
public static ResourceGroup ResourceGroup { get; } = new ResourceGroup(
"Id",
"Location",
"ManagedBy",
Expand All @@ -50,7 +54,11 @@ public static class MocksFixture
{ "provisioningState", "Succeeded" }
},
"Type"
);
) with
{
TenantId = "TenantId",
SubscriptionId = "SubscriptionId"
};
public static ICollection<AzureResourceBase> Children { get; } = new AzureResourceBase[]
{
AzureTenant,
Expand Down Expand Up @@ -80,4 +88,44 @@ public static class MocksFixture
"Tier"
)
);
#pragma warning disable CS8601 // Possible null reference assignment.
public static IDictionary<string, JsonValue> Properties { get; } = JsonSerializer.Deserialize<SortedDictionary<string, JsonValue>>(
"""
{
"alwaysOn": false,
"http20Enabled": false,
"loadBalancing": "LeastRequests",
"minTlsVersion": "1.2",
"numberOfWorkers": 1,
"use32BitWorkerProcess": true,
"vnetName": "",
"webSocketsEnabled": false,
"requestTracingEnabled": false,
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": "VS2019",
"httpLoggingEnabled": false,
"azureMonitorLogCategories": null,
"acrUseManagedIdentityCreds": false,
"acrUserManagedIdentityID": null,
"logsDirectorySizeLimit": 35,
"detailedErrorLoggingEnabled": false,
"publishingUsername": "$lab-web-web-dev",
"defaultDocuments": [
"Default.htm",
"Default.html",
"Default.asp",
"index.htm",
"index.html",
"iisstart.htm",
"default.aspx",
"index.php",
"hostingstart.html"
],
"experiments": {
"rampUpRules": []
}
}
"""
);
#pragma warning restore CS8601 // Possible null reference assignment.
}
Loading

0 comments on commit 5741856

Please sign in to comment.