public void MachineKey_UnProtect_WithNullPurpose_ThrowsArgumentNullException() { var sut = new MachineKeyProtector(); sut.Invoking(protector => sut.Unprotect("good", null)) .ShouldThrow <ArgumentNullException>("because we passed invalid input"); }
public void MachineKey_Protect_ThenUnprotect_WithDifferentPurpose_ReturnsNull() { string clearText = "hello world"; var sut = new MachineKeyProtector(); string cipherText = sut.Protect(clearText, Purposes.ConnString); string decrypted = sut.Unprotect(cipherText, Purposes.AuthToken); decrypted.Should().BeNull("because we did not pass the expected purpose to decrypt"); }
public void MachineKey_Protect_ThenUnprotect_WithSamePurpose_Succeeds() { string clearText = "hello world"; var sut = new MachineKeyProtector(); string cipherText = sut.Protect(clearText, Purposes.ConnString); string decryptedText = sut.Unprotect(cipherText, Purposes.ConnString); decryptedText.Should() .Be(clearText, "because we expect the decrypted text to be same as the original clear text"); }