Esempio n. 1
0
        public void TestVerify_OneMatchingParts()
        {
            var hardwareID = HardwareIdentifier.ForCurrentComputer();
            var splitted   = hardwareID.Split('-');
            var otherID    = string.Format("1234567890-0987654321-3010203045-" + splitted[3] + "-DummycheckSum");

            Assert.IsFalse(HardwareIdentifier.IsValidForCurrentComputer(otherID));
        }
Esempio n. 2
0
        public void TestVerify_ThreeMatchingParts()
        {
            var hardwareID = HardwareIdentifier.ForCurrentComputer();

            var splitted = hardwareID.Split('-');
            var otherID  = string.Format("12345678-" + splitted[1] + "-" + splitted[2] + "-" + splitted[3] + "-DummycheckSum");

            Assert.IsTrue(HardwareIdentifier.IsValidForCurrentComputer(otherID));
        }
Esempio n. 3
0
        public void Test_hardware_identifier_structure()
        {
            var hardwareID = HardwareIdentifier.ForCurrentComputer();
            var split      = hardwareID.Split('-');

            Assert.AreEqual(5, split.Length);
            Assert.AreEqual(8, split[0].Length);
            Assert.AreEqual(8, split[1].Length);
            Assert.AreEqual(8, split[2].Length);
            Assert.AreEqual(8, split[3].Length);
            Assert.AreEqual(4, split[4].Length);
        }
Esempio n. 4
0
        SignedLicense IVerifier_VerifyLoad.LoadAndVerify(string licenseString)
        {
            var license = SignedLicense.Deserialize(licenseString);

            // verify signature
            license.Verify(mySigner);
            // verify application code
            if (!SerialNumber.IsApplicationCodeValid(license.SerialNumber, myApplicationCode))
            {
                throw new SignedLicenseException($"Application Code '{myApplicationCode}' is not valid for the license.");
            }
            // verify hardware identifier
            if (!HardwareIdentifier.IsValidForCurrentComputer(license.HardwareIdentifier))
            {
                throw new SignedLicenseException($"License has been activated for another computer.");
            }
            // verify expiration date
            if (license.ExpirationDate < DateTime.UtcNow)
            {
                throw new SignedLicenseException($"License has been expired since '{license.ExpirationDate}'.");
            }
            return(license);
        }
 public void TestArePartialEqual_Empty() => Assert.IsFalse(HardwareIdentifier.ArePartialEqual("", ""));
 public void TestArePartialEqual_FiveFalse2() => Assert.IsFalse(HardwareIdentifier.ArePartialEqual("ABC-DEF-GHI-JKL-MNO-123", "AAA-DDD-GGG-JJJ-MMM-123"));
 public void TestArePartialEqual_DifferentLength() => Assert.IsFalse(HardwareIdentifier.ArePartialEqual("ABC-DEF-GHI-JKL-123", "ABC-DEF-GHI-JKL"));
 public void TestArePartialEqual_FourFalse1() => Assert.IsFalse(HardwareIdentifier.ArePartialEqual("ABC-DEF-GHI-JKL-123", "ABC-DDD-GGG-JJJ-345"));
 public void TestArePartialEqual_FiveTrue2() => Assert.IsTrue(HardwareIdentifier.ArePartialEqual("ABC-DEF-GHI-JKL-MNO-123", "ABC-DEF-GHI-JJJ-MMM-123"));
Esempio n. 10
0
 public void Test_verify_crap_string() => Assert.IsFalse(HardwareIdentifier.IsValidForCurrentComputer("dsfdsaf<df"));
 public void TestArePartialEqual_FourTrue1() => Assert.IsTrue(HardwareIdentifier.ArePartialEqual("ABC-DEF-GHI-JKL-123", "ABC-DEF-GHI-JKL-123"));
Esempio n. 12
0
 public void Test_verify_null() => TestHelper.AssertException <ArgumentNullException>(() => HardwareIdentifier.IsValidForCurrentComputer(null));
 public void TestArePartialEqual_ThreeTrue2() => Assert.IsTrue(HardwareIdentifier.ArePartialEqual("ABC-DEF-GHI-123", "ABC-DEF-GGG-345"));
 public void TestArePartialEqual_OneFalse() => Assert.IsFalse(HardwareIdentifier.ArePartialEqual("ABC-123", "DDD-345"));
 public void TestArePartialEqual_TwoTrue2() => Assert.IsTrue(HardwareIdentifier.ArePartialEqual("ABC-DEF-123", "ABC-DEF-123"));
 public void TestArePartialEqual_OneTrue() => Assert.IsTrue(HardwareIdentifier.ArePartialEqual("ABC-123", "ABC-345"));
Esempio n. 17
0
 public void TestVerify_ZeroMatchingParts() => Assert.IsFalse(HardwareIdentifier.IsValidForCurrentComputer("12345678-09876543-09876543-12345678-0987"));
Esempio n. 18
0
 public void Test_verify_empty_string()
 {
     Assert.IsFalse(HardwareIdentifier.IsValidForCurrentComputer(""));
 }
 public void Test_hardware_identifier_structure()
 {
     var hardwareID = HardwareIdentifier.ForCurrentComputer();
 }
 public void TestArePartialEqual_ThreeFalse2() => Assert.IsFalse(HardwareIdentifier.ArePartialEqual("ABC-DEF-GHI-123", "AAA-DDD-GGG-345"));
 public void TestArePartialEqual_TwoFalse() => Assert.IsFalse(HardwareIdentifier.ArePartialEqual("ABC-DEF-123", "CCC-DDD-345"));
Esempio n. 22
0
        public void Test_verify()
        {
            var hardwareID = HardwareIdentifier.ForCurrentComputer();

            Assert.IsTrue(HardwareIdentifier.IsValidForCurrentComputer(hardwareID));
        }