Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
Standalone .NET SDK - initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwilemski committed Aug 16, 2011
0 parents commit 254cbab
Show file tree
Hide file tree
Showing 12 changed files with 7,590 additions and 0 deletions.
100 changes: 100 additions & 0 deletions DuoTest/DuoTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* DuoTest.cs
*
* Copyright (c) 2011 Duo Security
* All rights reserved, all wrongs reversed.
*
* Simple test exercising the Duo Web SDK
*/

using System;
using System.Collections;
using System.Linq;
using System.Text;

using Duo;

namespace DuoTest
{
class DuoTest
{
/* Dummy IKEY and SKEY values */
const string IKEY = "DIXXXXXXXXXXXXXXXXXX";
const string SKEY = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
const string AKEY = "useacustomerprovidedapplicationsecretkey";

/* Dummy username */
const string USER = "testuser";

/* Dummy response signatures */
const string INVALID_RESPONSE = "AUTH|INVALID|SIG";
const string EXPIRED_RESPONSE = "AUTH|dGVzdHVzZXJ8RElYWFhYWFhYWFhYWFhYWFhYWFh8MTMwMDE1Nzg3NA==|cb8f4d60ec7c261394cd5ee5a17e46ca7440d702";
const string FUTURE_RESPONSE = "AUTH|dGVzdHVzZXJ8RElYWFhYWFhYWFhYWFhYWFhYWFh8MTYxNTcyNzI0Mw==|d20ad0d1e62d84b00a3e74ec201a5917e77b6aef";

static void Main(string[] args)
{
string request_sig;

request_sig = Duo.Web.SignRequest(IKEY, SKEY, AKEY, USER);
if (request_sig == null) {
Console.WriteLine("did not generate signed request.");
}

request_sig = Duo.Web.SignRequest(IKEY, SKEY, AKEY, "");
if (request_sig != Duo.Web.ERR_USER) {
Console.WriteLine("did not catch username error.");
}

request_sig = Duo.Web.SignRequest("invalid", SKEY, AKEY, USER);
if (request_sig != Duo.Web.ERR_IKEY) {
Console.WriteLine("did not catch ikey error.");
}

request_sig = Duo.Web.SignRequest(IKEY, "invalid", AKEY, USER);
if (request_sig != Duo.Web.ERR_SKEY) {
Console.WriteLine("did not catch skey error.");
}

request_sig = Duo.Web.SignRequest(IKEY, SKEY, "invalid", USER);
if (request_sig != Duo.Web.ERR_AKEY) {
Console.WriteLine("did not catch akey error.");
}

/*******************************************************************/

string[] sigs;
string valid_app_sig, invalid_app_sig;
string invalid_user, expired_user, future_user;

request_sig = Duo.Web.SignRequest(IKEY, SKEY, AKEY, USER);
sigs = request_sig.Split(':');
valid_app_sig = sigs[1];

request_sig = Duo.Web.SignRequest(IKEY, SKEY, "invalidinvalidinvalidinvalidinvalidinvalid", USER);
sigs = request_sig.Split(':');
invalid_app_sig = sigs[1];

invalid_user = Duo.Web.VerifyResponse(IKEY, SKEY, AKEY, INVALID_RESPONSE + ":" + valid_app_sig);
if (invalid_user != null) {
Console.WriteLine("failed invalid user verify test.");
}

expired_user = Duo.Web.VerifyResponse(IKEY, SKEY, AKEY, EXPIRED_RESPONSE + ":" + valid_app_sig);
if (expired_user != null) {
Console.WriteLine("failed expired user verify test.");
}

future_user = Duo.Web.VerifyResponse(IKEY, SKEY, AKEY, FUTURE_RESPONSE + ":" + invalid_app_sig);
if (future_user != null) {
Console.WriteLine("failed future user invalid app sig test.");
}

future_user = Duo.Web.VerifyResponse(IKEY, SKEY, AKEY, FUTURE_RESPONSE + ":" + valid_app_sig);
if (future_user != USER) {
Console.WriteLine("failed future user valid app sig test.");
}

Console.WriteLine("test cases completed.");
}
}
}
66 changes: 66 additions & 0 deletions DuoTest/DuoTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{602AABC6-62E4-478B-AEE3-C036F402FE40}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DuoTest</RootNamespace>
<AssemblyName>DuoTest</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<StartupObject>DuoTest.DuoTest</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DuoTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DuoWeb\DuoWeb.csproj">
<Project>{902B2D72-B6F6-4CAB-92CF-9BF0BA79DEE9}</Project>
<Name>DuoWeb</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
36 changes: 36 additions & 0 deletions DuoTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DuoTest")]
[assembly: AssemblyDescription("Duo Web SDK Test")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Duo Security, Inc")]
[assembly: AssemblyProduct("DuoTest")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b8b12c19-4eab-49ae-8834-692ccde8ee61")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
26 changes: 26 additions & 0 deletions DuoWeb.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DuoWeb", "DuoWeb\DuoWeb.csproj", "{902B2D72-B6F6-4CAB-92CF-9BF0BA79DEE9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DuoTest", "DuoTest\DuoTest.csproj", "{602AABC6-62E4-478B-AEE3-C036F402FE40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{902B2D72-B6F6-4CAB-92CF-9BF0BA79DEE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{902B2D72-B6F6-4CAB-92CF-9BF0BA79DEE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{902B2D72-B6F6-4CAB-92CF-9BF0BA79DEE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{902B2D72-B6F6-4CAB-92CF-9BF0BA79DEE9}.Release|Any CPU.Build.0 = Release|Any CPU
{602AABC6-62E4-478B-AEE3-C036F402FE40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{602AABC6-62E4-478B-AEE3-C036F402FE40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{602AABC6-62E4-478B-AEE3-C036F402FE40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{602AABC6-62E4-478B-AEE3-C036F402FE40}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading

0 comments on commit 254cbab

Please sign in to comment.