Skip to content

Commit 92b6b0b

Browse files
skhanskhan
authored andcommitted
Finalizing support for 9.0 API IdM features. Introduced UnitTest project.
1 parent ce708ea commit 92b6b0b

File tree

11 files changed

+573
-3
lines changed

11 files changed

+573
-3
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<appSettings>
4+
<!-- Global Settings -->
5+
<add key="SecureAuthRealmUrl" value=""/>
6+
<add key="ApiID" value=""/>
7+
<add key="ApiKey" value=""/>
8+
9+
<!-- Authentication Service Test Values -->
10+
<add key="AuthSvc.goodUsername" value="jbeam"/>
11+
<add key="AuthSvc.goodPassword" value="CurrentPassword2016"/>
12+
<add key="AuthSvc.badUsername" value="jsmith"/>
13+
<add key="AuthSvc.badPassword" value="BadPassword2016"/>
14+
<add key="AuthSvc.goodStaticPin" value="123456"/>
15+
<add key="AuthSvc.badStaticPin" value="000000"/>
16+
17+
<!-- User Service Test Values -->
18+
<add key="UserSvc.goodUsername" value="jbeam"/>
19+
<add key="UserSvc.badUsername" value="jsmith"/>
20+
<add key="UserSvc.currentPassword" value="CurrentPassword2016"/>
21+
<add key="UserSvc.newPassword1" value="ChangePassword2016"/>
22+
<add key="UserSvc.newPassword2" value="ResetPassword2016"/>
23+
<add key="UserSvc.newFirstName" value="Bob"/>
24+
<add key="UserSvc.newLastName" value="Smith"/>
25+
<add key="UserSvc.newUserId" value="bsmith"/>
26+
<add key="UserSvc.groupName1" value="Group One"/>
27+
<add key="UserSvc.groupName2" value="Group Two"/>
28+
</appSettings>
29+
</configuration>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.Configuration;
3+
4+
namespace SecureAuth.Sdk.UnitTests
5+
{
6+
[TestClass]
7+
public class AuthenticationServiceTests
8+
{
9+
// Globals
10+
static SecureAuthService secAuthSvc;
11+
static string goodUsername;
12+
static string goodPassword;
13+
static string badUsername;
14+
static string badPassword;
15+
static string goodStaticPin;
16+
static string badStaticPin;
17+
18+
[ClassInitialize]
19+
public static void Init(TestContext testContext)
20+
{
21+
// Grab values from app.config
22+
goodUsername = ConfigurationManager.AppSettings["AuthSvc.goodUsername"];
23+
goodPassword = ConfigurationManager.AppSettings["AuthSvc.goodPassword"];
24+
badUsername = ConfigurationManager.AppSettings["AuthSvc.badUsername"];
25+
badPassword = ConfigurationManager.AppSettings["AuthSvc.badPassword"];
26+
goodStaticPin = ConfigurationManager.AppSettings["AuthSvc.goodStaticPin"];
27+
badStaticPin = ConfigurationManager.AppSettings["AuthSvc.badStaticPin"];
28+
29+
string secureAuthRealm = ConfigurationManager.AppSettings["SecureAuthRealmUrl"];
30+
string apiId = ConfigurationManager.AppSettings["ApiID"];
31+
string apiKey = ConfigurationManager.AppSettings["ApiKey"];
32+
33+
// Init the SecureAuthService
34+
Configuration config = new Configuration(secureAuthRealm, apiId, apiKey);
35+
secAuthSvc = new SecureAuthService(config);
36+
}
37+
38+
[TestMethod]
39+
public void ValidateGoodUserIdTest()
40+
{
41+
// Arrange
42+
ValidateUserIdRequest req = new ValidateUserIdRequest(goodUsername);
43+
44+
// Act
45+
BaseResponse res = secAuthSvc.Authenticate.ValidateUserId(req);
46+
47+
// Assert
48+
Assert.AreEqual(Constants.ResponseStatus.Found, res.Status);
49+
}
50+
51+
[TestMethod]
52+
public void ValidateBadUserIdTest()
53+
{
54+
// Arrange
55+
ValidateUserIdRequest req = new ValidateUserIdRequest(badUsername);
56+
57+
// Act
58+
BaseResponse res = secAuthSvc.Authenticate.ValidateUserId(req);
59+
60+
// Assert
61+
Assert.AreNotEqual(Constants.ResponseStatus.Found, res.Status);
62+
}
63+
64+
[TestMethod]
65+
public void ValidateGoodPasswordTest()
66+
{
67+
// Arrange
68+
ValidatePasswordRequest req = new ValidatePasswordRequest(goodUsername, goodPassword);
69+
70+
// Act
71+
BaseResponse res = secAuthSvc.Authenticate.ValidatePassword(req);
72+
73+
// Assert
74+
Assert.AreEqual(Constants.ResponseStatus.Valid, res.Status);
75+
}
76+
77+
[TestMethod]
78+
public void ValidateBadPasswordTest()
79+
{
80+
// Arrange
81+
ValidatePasswordRequest req = new ValidatePasswordRequest(goodUsername, badPassword);
82+
83+
// Act
84+
BaseResponse res = secAuthSvc.Authenticate.ValidatePassword(req);
85+
86+
// Assert
87+
Assert.AreEqual(Constants.ResponseStatus.Invalid, res.Status);
88+
}
89+
90+
[TestMethod]
91+
public void ValidateGoodStaticPinTest()
92+
{
93+
// Arrange
94+
ValidatePinRequest req = new ValidatePinRequest(goodUsername, goodStaticPin);
95+
96+
// Act
97+
BaseResponse res = secAuthSvc.Authenticate.ValidatePin(req);
98+
99+
// Assert
100+
Assert.AreEqual(Constants.ResponseStatus.Valid, res.Status);
101+
}
102+
103+
[TestMethod]
104+
public void ValidateBadStaticPinTest()
105+
{
106+
// Arrange
107+
ValidatePinRequest req = new ValidatePinRequest(goodUsername, badStaticPin);
108+
109+
// Act
110+
BaseResponse res = secAuthSvc.Authenticate.ValidatePin(req);
111+
112+
// Assert
113+
Assert.AreEqual(Constants.ResponseStatus.Invalid, res.Status);
114+
}
115+
}
116+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
namespace SecureAuth.Sdk.UnitTests
2+
{
3+
public static class Constants
4+
{
5+
public static class ResponseStatus
6+
{
7+
public const string Valid = "valid";
8+
public const string Invalid = "invalid";
9+
public const string InvalidGroup = "invalid_group";
10+
public const string Found = "found";
11+
public const string NotFound = "not_found";
12+
public const string Disabled = "disabled";
13+
public const string LockOut = "lock_out";
14+
public const string PasswordExpired = "password_expired";
15+
public const string Verified = "verified";
16+
public const string ServerError = "server_error";
17+
public const string Success = "success";
18+
public const string Failed = "failed";
19+
}
20+
21+
public static class DfpResponseStatus
22+
{
23+
public const string Found = "found";
24+
public const string FoundForUpdate = "found_for_update";
25+
public const string FoundWithIdMismatch = "found_with_id_mismatch";
26+
public const string NotFound = "not_found";
27+
}
28+
29+
public static class FactorIds
30+
{
31+
public const string Email1 = "Email1";
32+
public const string Email2 = "Email2";
33+
public const string Email3 = "Email3";
34+
public const string Email4 = "Email4";
35+
public const string Phone1 = "Phone1";
36+
public const string Phone2 = "Phone2";
37+
public const string Phone3 = "Phone3";
38+
public const string Phone4 = "Phone4";
39+
public const string HelpDesk1 = "HelpDesk1";
40+
public const string HelpDesk2 = "HelpDesk2";
41+
}
42+
43+
public static class SuggestedActions
44+
{
45+
public const string SecondFactorPassword = "2ndfactor_password";
46+
public const string SecondFactorOnly = "2ndfactor";
47+
public const string Password = "password";
48+
public const string Redirect = "redirect";
49+
public const string Stop = "stop";
50+
public const string None = "none";
51+
}
52+
53+
public static class BehaveBioRespons
54+
{
55+
public const string ResetSent = "Reset sent to data store.";
56+
public const string UnabletoParse = "Unable to parse profile.";
57+
public const string ProfileNotUpdated = "Profile was not updated.";
58+
public const string FieldNotFound = "Field was not found in profile.";
59+
}
60+
}
61+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("SecureAuth.Sdk.UnitTests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("SecureAuth.Sdk.UnitTests")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("b5995a75-cb46-408e-85e4-20efd1952cf0")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{B5995A75-CB46-408E-85E4-20EFD1952CF0}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>SecureAuth.Sdk.UnitTests</RootNamespace>
10+
<AssemblyName>SecureAuth.Sdk.UnitTests</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
<Reference Include="System.configuration" />
40+
</ItemGroup>
41+
<Choose>
42+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
43+
<ItemGroup>
44+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
45+
</ItemGroup>
46+
</When>
47+
<Otherwise>
48+
<ItemGroup>
49+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
50+
<Private>False</Private>
51+
</Reference>
52+
</ItemGroup>
53+
</Otherwise>
54+
</Choose>
55+
<ItemGroup>
56+
<Compile Include="Constants.cs" />
57+
<Compile Include="Properties\AssemblyInfo.cs" />
58+
<Compile Include="AuthenticationServiceTests.cs" />
59+
<Compile Include="UserServiceTests.cs" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<ProjectReference Include="..\SecureAuth.Sdk\SecureAuth.Sdk.csproj">
63+
<Project>{2d72d9f4-321f-4720-bcf3-bb254c08cbb7}</Project>
64+
<Name>SecureAuth.Sdk</Name>
65+
</ProjectReference>
66+
</ItemGroup>
67+
<ItemGroup>
68+
<None Include="App.config" />
69+
</ItemGroup>
70+
<Choose>
71+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
72+
<ItemGroup>
73+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
74+
<Private>False</Private>
75+
</Reference>
76+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
77+
<Private>False</Private>
78+
</Reference>
79+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
80+
<Private>False</Private>
81+
</Reference>
82+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
83+
<Private>False</Private>
84+
</Reference>
85+
</ItemGroup>
86+
</When>
87+
</Choose>
88+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
89+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
90+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
91+
Other similar extension points exist, see Microsoft.Common.targets.
92+
<Target Name="BeforeBuild">
93+
</Target>
94+
<Target Name="AfterBuild">
95+
</Target>
96+
-->
97+
</Project>

0 commit comments

Comments
 (0)