-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from sagittaras/tests/route53
Tests for Route53 module
- Loading branch information
Showing
29 changed files
with
662 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ obj/ | |
/packages/ | ||
riderModule.iml | ||
/_ReSharper.Caches/ | ||
.idea/ | ||
.idea/ | ||
*.DotSettings.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.KMS; | ||
|
||
/// <summary> | ||
/// Assertion for AWS::KMS::Alias. | ||
/// </summary> | ||
public class AliasAssertion : ResourceAssertion<AliasProperties> | ||
{ | ||
public override string Type => "AWS::KMS::Alias"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.KMS; | ||
|
||
/// <summary> | ||
/// Properties for AWS::KMS::Alias. | ||
/// </summary> | ||
public class AliasProperties : ResourceProperties | ||
{ | ||
/// <summary> | ||
/// Name of the key alias. | ||
/// </summary> | ||
public string? AliasName { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.KMS; | ||
|
||
/// <summary> | ||
/// Assertion for AWS::KMS::Key. | ||
/// </summary> | ||
public class KeyAssertion : ResourceAssertion<KeyProperties> | ||
{ | ||
public override string Type => "AWS::KMS::Key"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.KMS; | ||
|
||
/// <summary> | ||
/// Properties for AWS::KMS::Key. | ||
/// </summary> | ||
public class KeyProperties : ResourceProperties | ||
{ | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Sagittaras.CDK.Testing.KMS/Sagittaras.CDK.Testing.KMS.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>1.0.0-preview-01</Version> | ||
<Title>CDK KMS testing library</Title> | ||
<Authors>Sagittaras Games</Authors> | ||
<PackageProjectUrl>https://github.com/sagittaras/cdk.framework</PackageProjectUrl> | ||
<PackageLicenseUrl>https://github.com/sagittaras/cdk.framework/blob/main/LICENSE</PackageLicenseUrl> | ||
<RepositoryUrl>https://github.com/sagittaras/cdk.framework</RepositoryUrl> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Sagittaras.CDK.Testing\Sagittaras.CDK.Testing.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Assertion for Aws::Route53::DNSSEC. | ||
/// </summary> | ||
public class DnsSecAssertion : ResourceAssertion<DnsSecProperties> | ||
{ | ||
/// <inheritdoc /> | ||
public override string Type => "AWS::Route53::DNSSEC"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Class defining DNS SEC dependency on Key Signing Key. | ||
/// </summary> | ||
public class DnsSecDependency : ResourceDependency | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="kskName">Identification of KSK by its name.</param> | ||
public DnsSecDependency(string kskName) | ||
{ | ||
With(new KeySigningKeyAssertion | ||
{ | ||
Properties = new KeySigningKeyProperties | ||
{ | ||
Name = kskName | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Properties for AWS::Route53::DNSSEC. | ||
/// </summary> | ||
public class DnsSecProperties : ResourceProperties | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Assertion for AWS::Route53::HostedZone. | ||
/// </summary> | ||
public class HostedZoneAssertion : ResourceAssertion<HostedZoneProperties> | ||
{ | ||
/// <inheritdoc /> | ||
public override string Type => "AWS::Route53::HostedZone"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Properties describing the Hosted Zone in the CloudFormation template. | ||
/// </summary> | ||
public class HostedZoneProperties : ResourceProperties | ||
{ | ||
private string? _name; | ||
|
||
/// <summary> | ||
/// Name of the hosted zone. | ||
/// </summary> | ||
/// <remarks> | ||
/// Automatically appends the trailing dot that is generated for CloudFormation template. | ||
/// </remarks> | ||
public string? Name | ||
{ | ||
get => _name; | ||
set => _name = value?.TrimEnd('.') + "."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Assertion for AWS::Route53::KeySigningKey. | ||
/// </summary> | ||
public class KeySigningKeyAssertion : ResourceAssertion<KeySigningKeyProperties> | ||
{ | ||
/// <inheritdoc /> | ||
public override string Type => "AWS::Route53::KeySigningKey"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Properties for AWS::Route53::KeySigningKey. | ||
/// </summary> | ||
public class KeySigningKeyProperties : ResourceProperties | ||
{ | ||
/// <summary> | ||
/// Current status of the KSK. | ||
/// </summary> | ||
public string? Status { get; set; } | ||
|
||
/// <summary> | ||
/// Name of the KSK. | ||
/// </summary> | ||
public string? Name { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Assertion for AWS::Route53::RecordSet. | ||
/// </summary> | ||
public class RecordSetAssertion : ResourceAssertion<RecordSetProperties> | ||
{ | ||
/// <inheritdoc /> | ||
public override string Type => "AWS::Route53::RecordSet"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Route53; | ||
|
||
/// <summary> | ||
/// Properties for AWS::Route53::RecordSet. | ||
/// </summary> | ||
public class RecordSetProperties : ResourceProperties | ||
{ | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Sagittaras.CDK.Testing.Route53/Sagittaras.CDK.Testing.Route53.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>1.0.0-preview-01</Version> | ||
<Title>CDK Route53 test library</Title> | ||
<Authors>Sagittaras Games</Authors> | ||
<PackageProjectUrl>https://github.com/sagittaras/cdk.framework</PackageProjectUrl> | ||
<PackageLicenseUrl>https://github.com/sagittaras/cdk.framework/blob/main/LICENSE</PackageLicenseUrl> | ||
<RepositoryUrl>https://github.com/sagittaras/cdk.framework</RepositoryUrl> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Sagittaras.CDK.Testing\Sagittaras.CDK.Testing.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
34 changes: 34 additions & 0 deletions
34
Sagittaras.CDK.Testing/Extensions/TemplateAssertionExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Amazon.CDK.Assertions; | ||
using Sagittaras.CDK.Testing.Resources; | ||
|
||
namespace Sagittaras.CDK.Testing.Extensions; | ||
|
||
/// <summary> | ||
/// Extends the assertion template from the CDK by custom assertion methods. | ||
/// </summary> | ||
public static class TemplateAssertionExtension | ||
{ | ||
/// <summary> | ||
/// Asserts that the template has a resource with the given description. | ||
/// </summary> | ||
/// <param name="template"></param> | ||
/// <param name="assertion"></param> | ||
/// <typeparam name="TResourceAssertion"></typeparam> | ||
public static void Assert<TResourceAssertion>(this Template template, TResourceAssertion assertion) | ||
where TResourceAssertion : IResourceAssertion | ||
{ | ||
template.HasResource(assertion.Type, assertion.GetResourceDescription(template)); | ||
} | ||
|
||
/// <summary> | ||
/// Asserts that the template has a given number of resources of the given type. | ||
/// </summary> | ||
/// <param name="template"></param> | ||
/// <param name="count"></param> | ||
/// <typeparam name="TResourceAssertion"></typeparam> | ||
public static void AssertCount<TResourceAssertion>(this Template template, int count) | ||
where TResourceAssertion : IResourceAssertion, new() | ||
{ | ||
template.ResourceCountIs(new TResourceAssertion().Type, count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Amazon.CDK.Assertions; | ||
|
||
namespace Sagittaras.CDK.Testing.Resources; | ||
|
||
/// <summary> | ||
/// Basic interface describing the assertion for AWS resource. | ||
/// </summary> | ||
public interface IResourceAssertion | ||
{ | ||
/// <summary> | ||
/// AWS Resource type. | ||
/// </summary> | ||
string Type { get; } | ||
|
||
/// <summary> | ||
/// Maps on which resources the current resource depends on. | ||
/// </summary> | ||
IResourceDependency? DependsOn { get; set; } | ||
|
||
/// <summary> | ||
/// Converts the resource description to a dictionary suitable for template assertion. | ||
/// </summary> | ||
/// <returns></returns> | ||
IDictionary<string, object> GetResourceDescription(Template template); | ||
} | ||
|
||
/// <summary> | ||
/// Extends the basic resource assertion with properties. | ||
/// </summary> | ||
/// <typeparam name="TProperties">Type of the properties used for the resource.</typeparam> | ||
public interface IResourceAssertion<TProperties> : IResourceAssertion | ||
where TProperties : IResourceProperties, new() | ||
{ | ||
/// <summary> | ||
/// Properties that helps to identify the resource. | ||
/// </summary> | ||
TProperties? Properties { get; set; } | ||
} |
Oops, something went wrong.