Skip to content

Commit

Permalink
Adding integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
irenepsmith committed Sep 15, 2022
1 parent 4240a61 commit 7208315
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 10 deletions.
10 changes: 5 additions & 5 deletions dotnetv3/Cognito/scenarios/Cognito_Basics/Cognito_MVP.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cognito_MVP", "Cognito_MVP\Cognito_MVP.csproj", "{3F6C5730-4A94-4515-B38A-E34389BC0243}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cognito_MVPTests", "Cognito_MVPTests\Cognito_MVPTests.csproj", "{B468BE3E-929E-4A1C-A724-9DCE6AA50FE3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cognito_MVPTests", "Cognito_MVPTests\Cognito_MVPTests.csproj", "{A3764938-2129-465B-8945-6C04B90E2E30}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,10 +17,10 @@ Global
{3F6C5730-4A94-4515-B38A-E34389BC0243}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F6C5730-4A94-4515-B38A-E34389BC0243}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F6C5730-4A94-4515-B38A-E34389BC0243}.Release|Any CPU.Build.0 = Release|Any CPU
{B468BE3E-929E-4A1C-A724-9DCE6AA50FE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B468BE3E-929E-4A1C-A724-9DCE6AA50FE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B468BE3E-929E-4A1C-A724-9DCE6AA50FE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B468BE3E-929E-4A1C-A724-9DCE6AA50FE3}.Release|Any CPU.Build.0 = Release|Any CPU
{A3764938-2129-465B-8945-6C04B90E2E30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3764938-2129-465B-8945-6C04B90E2E30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3764938-2129-465B-8945-6C04B90E2E30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3764938-2129-465B-8945-6C04B90E2E30}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@

await CognitoMethods.SignUp(identityProviderClient, clientId, userName, password, email);

Console.WriteLine($"*** Getting {userName} in the user pool");
Console.WriteLine($"Getting {userName} status from the user pool");
await CognitoMethods.GetAdminUser(identityProviderClient, userName, poolId);

Console.WriteLine($"*** Conformation code sent to { userName}. Would you like to send a new code? (Yes/No)");
var ans = Console.ReadLine();

if (ans.ToUpper() == "YES")
{
await CognitoMethods.resendConfirmationCode(identityProviderClient, clientId, userName);
await CognitoMethods.ResendConfirmationCode(identityProviderClient, clientId, userName);
Console.WriteLine("*** Sending a new confirmation code");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static async Task<bool> ConfirmSignUp(AmazonCognitoIdentityProviderClient
/// with the user pool.</param>
/// <param name="userName">The user name to be confirmed.</param>
/// <returns></returns>
public static async Task resendConfirmationCode(AmazonCognitoIdentityProviderClient identityProviderClient, string clientId, string userName)
public static async Task ResendConfirmationCode(AmazonCognitoIdentityProviderClient identityProviderClient, string clientId, string userName)
{
var codeRequest = new ResendConfirmationCodeRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.CognitoIdentityProvider" Version="3.7.4.12" />
<PackageReference Include="AWSSDK.Core" Version="3.7.12.7" />
<PackageReference Include="AWSSDK.CognitoIdentityProvider" Version="3.7.6.4" />
<PackageReference Include="AWSSDK.Core" Version="3.7.13.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

namespace Cognito_MVP.Tests
{
public class CognitoMethodsTests
{
private static AmazonCognitoIdentityProviderClient _Client = new AmazonCognitoIdentityProviderClient();
private static readonly _UserName = "test-user";

[Fact]
[Order(1)]
public static async Task AdminRespondToAuthChallengeTest()
{
var userName = "test-user";
var clientId = "some-client-id";
var mfaCode = "abcdefg-etc";
var session = "not a session";
var success = await CognitoMethods.AdminRespondToAuthChallenge(_Client, userName, clientId, mfaCode, session);
Assert.True(success, "Challenge failed to authenticate user.");
}

[Fact]
[Order(1)]
public static async Task AdminRespondToAuthChallengeTest_WithNonsense_ShouldFail()
{
var userName = "test-user";
var clientId = "some-client-id";
var mfaCode = "abcdefg-etc";
var session = "not a session";
var success = await CognitoMethods.AdminRespondToAuthChallenge(_Client, userName, clientId, mfaCode, session);
Assert.False(success, "Challenge should fail with bad information.");
}

[Fact]
[Order(7)]
public static async Task VerifyTOTPTest()
{
var session = "";
var code = "";
var success = await CognitoMethods.VerifyTOTP(_Client, session, code);
Assert.True(success, "Could not verify the one-time password.");
}

[Fact]
[Order(6)]
public static async Task GetSecretForAppMFATest()
{

}

[Fact]
[Order(5)]
public void InitiateAuthTest()
{
Assert.True(false, "This test needs an implementation");
}

[Fact]
[Order(4)]
public void ConfirmSignUpTest()
{
Assert.True(false, "This test needs an implementation");
}

[Fact]
[Order(3)]
public void ResendConfirmationCodeTest()
{
Assert.True(false, "This test needs an implementation");
}

[Fact]
[Order(2)]
public void GetAdminUserTest()
{
Assert.True(false, "This test needs an implementation");
}

[Fact]
[Order(1)]
public void SignUpTest()
{
Assert.True(false, "This test needs an implementation");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.CognitoIdentity" Version="3.7.0.204" />
<PackageReference Include="AWSSDK.Core" Version="3.7.13.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Xunit.Extensions.Ordering" Version="1.4.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Cognito_MVP\Cognito_MVP.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
global using Amazon;
global using Amazon.CognitoIdentityProvider;
global using Amazon.CognitoIdentityProvider.Model;
global using Cognito_MVP;
global using Xunit;
global using Xunit.Extensions.Ordering;

// Optional.
[assembly: CollectionBehavior(DisableTestParallelization = true)]
// Optional.
[assembly: TestCaseOrderer("Xunit.Extensions.Ordering.TestCaseOrderer", "Xunit.Extensions.Ordering")]
// Optional.
[assembly: TestCollectionOrderer("Xunit.Extensions.Ordering.CollectionOrderer", "Xunit.Extensions.Ordering")]

0 comments on commit 7208315

Please sign in to comment.