From 486c8842deb0c302d2718dc25f873b13884bfcc5 Mon Sep 17 00:00:00 2001 From: Alexey Averikhin Date: Fri, 11 Sep 2020 06:14:33 +0200 Subject: [PATCH] Conditional tests execution --- .../NetLicensingClient-demo.cs | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/NetLicensingClient-demo/NetLicensingClient-demo.cs b/NetLicensingClient-demo/NetLicensingClient-demo.cs index 60e5660..2078a41 100644 --- a/NetLicensingClient-demo/NetLicensingClient-demo.cs +++ b/NetLicensingClient-demo/NetLicensingClient-demo.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using NetLicensingClient.Entities; namespace NetLicensingClient @@ -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