Skip to content

Commit

Permalink
Conditional tests execution
Browse files Browse the repository at this point in the history
  • Loading branch information
r-brown committed Sep 11, 2020
1 parent 43ffc4a commit 486c884
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions NetLicensingClient-demo/NetLicensingClient-demo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using NetLicensingClient.Entities;

namespace NetLicensingClient
Expand Down Expand Up @@ -321,22 +322,26 @@ static int Main(string[] args)
validationResult = LicenseeService.validate(context, demoLicenseeNumber, validationParameters);
ConsoleWriter.WriteEntity("Validation result (APIKey):", validationResult);

// Validate using APIKey signed
context.securityMode = SecurityMode.APIKEY_IDENTIFICATION;
context.publicKey = publicKey;
validationResult = LicenseeService.validate(context, demoLicenseeNumber, validationParameters);
ConsoleWriter.WriteEntity("Validation result (APIKey / signed):", validationResult);

// Validate using APIKey wrongly signed
context.securityMode = SecurityMode.APIKEY_IDENTIFICATION;
context.publicKey = publicKey_wrong;
try
// Verify signature on Linux or OSX only
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// Validate using APIKey signed
context.securityMode = SecurityMode.APIKEY_IDENTIFICATION;
context.publicKey = publicKey;
validationResult = LicenseeService.validate(context, demoLicenseeNumber, validationParameters);
}
catch (NetLicensingException e)
{
Console.WriteLine("Validation result exception (APIKey / wrongly signed): {0}", e);
ConsoleWriter.WriteEntity("Validation result (APIKey / signed):", validationResult);

// Validate using APIKey wrongly signed
context.securityMode = SecurityMode.APIKEY_IDENTIFICATION;
context.publicKey = publicKey_wrong;
try
{
validationResult = LicenseeService.validate(context, demoLicenseeNumber, validationParameters);
}
catch (NetLicensingException e)
{
Console.WriteLine("Validation result exception (APIKey / wrongly signed): {0}", e);
}
}

// Reset context for futher use
Expand Down

0 comments on commit 486c884

Please sign in to comment.