I QA’d some acceptance tests yesterday and got the old “doesn’t work on my machine”. Turns out there were some required environment settings, one of which was the machine key. Even though we have a wiki page with this info on, IMHO it’s good practise to get your tests to assert that environment conditions are met.
So here’s my quick test to ensure that the machine key is right. ( :
[Test]
public void CheckMachineKey()
{
string devTeamValidationKey = "xxxx";
string devTeamDecryptionKey= "xxxx";
var machineKeySection = (MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey");
Assert.That(machineKeySection.ValidationKey,
Is.EqualTo(
devTeamValidationKey));
Assert.That(machineKeySection.DecryptionKey, Is.EqualTo(devTeamDecryptionKey));
Assert.That(machineKeySection.Validation, Is.EqualTo(MachineKeyValidation.SHA1));
}
Many thanks to this post here: Encrypt Cookie using machine key