You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following unit tests show AssertValidLicense method throwing exceptions when invalid public keys are given. Types of exceptions change depending on the given public key string.
I can add tests to the project to ensure the method does not throw when given unexpected parameters, if it fits the goals.
Exceptions are commented in the code:
[Fact]publicvoidShouldNotThrow(){varpassPhrase="TopSecret";vargenerator= KeyGenerator.Create();varpair= generator.GenerateKeyPair();varprivateKey= pair.ToEncryptedPrivateKeyString(passPhrase);varpublicKey= pair.ToPublicKeyString();varlicense= License.New().CreateAndSignWithPrivateKey(privateKey, passPhrase);varerrors= license.Validate().Signature("invalidKey").AssertValidLicense();
Assert.True(!errors.Any());//ShouldNotThrow' failed: System.FormatException : Invalid length for a Base-64 char array or string.// at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)// at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)// at System.Convert.FromBase64String(String s)// at Portable.Licensing.License.VerifySignature(String publicKey)// at Portable.Licensing.Validation.LicenseValidationExtensions.<>c__DisplayClassd.<Signature>b__c(License license)// at Portable.Licensing.Validation.ValidationChainBuilder.<AssertValidLicense>d__1.MoveNext()// at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)// LicenseClientTests.cs(96,0): at Biltera.Licensing.Client.Tests.LicenseClientTests.ShouldNotThrow()//0 passed, 1 failed, 0 skipped, took 1,11 seconds (xUnit.net 2.0.0 build 2929).}[Fact]publicvoidShouldNotThrow2(){varpassPhrase="TopSecret";vargenerator= KeyGenerator.Create();varpair= generator.GenerateKeyPair();varprivateKey= pair.ToEncryptedPrivateKeyString(passPhrase);varpublicKey= pair.ToPublicKeyString();varlicense= License.New().CreateAndSignWithPrivateKey(privateKey, passPhrase);varerrors= license.Validate().Signature("invalidPublicKey").AssertValidLicense();
Assert.True(!errors.Any());// ShouldNotThrow2' failed: System.IO.EndOfStreamException : DEF length 123 object truncated by 113// at Org.BouncyCastle.Asn1.DefiniteLengthInputStream.ToArray()// at Org.BouncyCastle.Asn1.Asn1StreamParser.ReadTaggedObject(Boolean constructed, Int32 tag)// at Org.BouncyCastle.Asn1.Asn1InputStream.BuildObject(Int32 tag, Int32 tagNo, Int32 length)// at Org.BouncyCastle.Asn1.Asn1InputStream.ReadObject()// at Org.BouncyCastle.Asn1.Asn1Object.FromByteArray(Byte[] data)// at Org.BouncyCastle.Security.PublicKeyFactory.CreateKey(Byte[] keyInfoData)// at Portable.Licensing.License.VerifySignature(String publicKey)// at Portable.Licensing.Validation.LicenseValidationExtensions.<>c__DisplayClassd.<Signature>b__c(License license)// at Portable.Licensing.Validation.ValidationChainBuilder.<AssertValidLicense>d__1.MoveNext()// at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)// LicenseClientTests.cs(122,0): at Biltera.Licensing.Client.Tests.LicenseClientTests.ShouldNotThrow2()//0 passed, 1 failed, 0 skipped, took 1,16 seconds (xUnit.net 2.0.0 build 2929).}
The text was updated successfully, but these errors were encountered:
Following unit tests show AssertValidLicense method throwing exceptions when invalid public keys are given. Types of exceptions change depending on the given public key string.
I can add tests to the project to ensure the method does not throw when given unexpected parameters, if it fits the goals.
Exceptions are commented in the code:
The text was updated successfully, but these errors were encountered: