Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library Refactor for DotNet 8 and Signature Version 5 #37

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 7 additions & 30 deletions .github/workflows/net-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,24 @@ jobs:
# Build and test on .NET Core
dotnet-core-ci:
name: .NET Core - test
runs-on: windows-2022
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up .NET
uses: actions/setup-dotnet@v1.7.2
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
dotnet-version: '8.0.x'

- name: Install dependencies
run: nuget restore
run: dotnet restore

- name: Build solution
run: dotnet build
run: dotnet build --configuration Release --no-restore

- name: Run tests
run: dotnet test
run: dotnet test --no-restore --verbosity normal --logger:"trx;LogFileName=TestResults.xml"

# - name: Run linter
# run: dotnet format --verify-no-changes

# Build and test on .NET Framework
dotnet-framework-ci:
name: .NET Framework - test
runs-on: windows-2022

steps:
- uses: actions/checkout@v2

- name: Set up MSBuild
uses: microsoft/setup-msbuild@v1

- name: Set up VSTest
uses: darenm/Setup-VSTest@v1

- name: Install dependencies
run: nuget restore

- name: Build DuoApiTest solution
run: msbuild.exe duo_api_csharp.sln

- name: Run Tests dll
run: vstest.console.exe .\test\bin\Debug\DuoApiTest.dll
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ packages/

*.ncrunchsolution
_NCrunch_*/
.idea
.DS_Store
9 changes: 0 additions & 9 deletions Makefile

This file was deleted.

16 changes: 0 additions & 16 deletions build.cmd

This file was deleted.

57 changes: 57 additions & 0 deletions duo_api_csharp.Examples/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2022-2024 Cisco Systems, Inc. and/or its affiliates
* All rights reserved
* https://github.com/duosecurity/duo_api_csharp
*/

using duo_api_csharp;
using duo_api_csharp.Classes;

namespace Examples
{
public class Program
{
private static async Task<int> Main(string[] args)
{
// Setup the connection
if( args.Length < 3 )
{
Console.WriteLine("Usage: <integration key> <secret key> <integration host>");
return 1;
}

var ikey = args[0];
var skey = args[1];
var host = args[2];
var client = new DuoAPI(ikey, skey, host);

// Request the first 100 users
try
{
var userResult = await client.Admin_v1.Users.GetUsers();
if( userResult.Response == null )
{
Console.WriteLine("Unable to retrieve users from Duo: ");
Console.WriteLine($"Error: ({userResult.ErrorCode}) {userResult.ErrorMessage}");
if( !string.IsNullOrEmpty(userResult.ErrorMessageDetail) ) Console.WriteLine($"Detailed Error: {userResult.ErrorMessageDetail}");
return 1;
}

// List first 100 of the available users
Console.WriteLine($"Retrieved {userResult.Response.Count()} Users");
foreach( var user in userResult.Response )
{
Console.WriteLine($"User retrieved: {user.Username} (ID: {user.UserID})");
}
}
catch( DuoException Ex )
{
Console.WriteLine("Unable to retrieve users from Duo: ");
Console.WriteLine($"Exception: {Ex.Message}, Status Code: {Ex.StatusCode}, Request Success: {Ex.RequestSuccess}");
if( Ex.InnerException != null ) Console.WriteLine($"Inner Exception: {Ex.InnerException.Message}");
}

return 0;
}
}
}
29 changes: 29 additions & 0 deletions duo_api_csharp.Examples/duo_api_csharp.Examples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latestmajor</LangVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>

<PropertyGroup>
<RootNamespace>Examples</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>

<ItemGroup>
<None Remove=".gitignore" />
</ItemGroup>

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

</Project>
Loading