예제 #1
0
        public void Test_GenerateAndReadLicense_Normal_Succeeds()
        {
            using var parameters = new LicenseSigningParameters();

            var license = LicenseKeyManager.Create(new SimpleTestLicense())
                          .CreateAndSignLicense(parameters);

            var validationResults = LicenseKeyManager.Load <SimpleTestLicense>(license)
                                    .Validate();

            Assert.False(validationResults.HasErrors);
        }
예제 #2
0
        public void Test_GenerateAndReadLicense_BadSigningParameters_Fails()
        {
            using var originalParameters = new LicenseSigningParameters();

            var license = LicenseKeyManager.Create(new SimpleTestLicense())
                          .CreateAndSignLicense(originalParameters);

            using var newParameters = new LicenseSigningParameters();
            license = new SignedLicense(license.LicenseData, newParameters.PublicKey);

            Assert.Throws <InvalidOperationException>(
                () => LicenseKeyManager.Load <SimpleTestLicense>(license)
                .Validate());
        }
예제 #3
0
        public void Test_GenerateAndReadLicense_ExportAndImport_Succeeds()
        {
            try
            {
                using var parameters = new LicenseSigningParameters();

                parameters.Export("lic.dat");
                using var importedParameters = LicenseSigningParameters.Import("lic.dat");

                var license = LicenseKeyManager.Create(new SimpleTestLicense())
                              .CreateAndSignLicense(importedParameters);

                var results = LicenseKeyManager.Load <SimpleTestLicense>(license)
                              .Validate();

                Assert.False(results.HasErrors);
            }
            finally
            {
                File.Delete("lic.dat");
            }
        }
예제 #4
0
        public void CreateAndSignLicense_ReturnsValidSignature()
        {
            using var signingParameters = new LicenseSigningParameters();

            Assert.NotNull(_licenseFactory.CreateAndSignLicense(signingParameters));
        }
예제 #5
0
 public SignedLicense CreateAndSignLicense(LicenseSigningParameters parameters)
 => _licenseKey.Sign(parameters);
예제 #6
0
 internal JwtTokenManager(LicenseSigningParameters signingParameters)
 {
     _signingParameters = signingParameters;
 }