Example #1
0
 static Mock <ISecureConfig> CreateConfig(bool useSystemPrivateKeyAsServerKey = false)
 {
     if (useSystemPrivateKeyAsServerKey)
     {
         return(CreateConfig(
                    HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultSystemKeyPrivate),
                    HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultSystemKeyPublic)));
     }
     return(CreateConfig(
                HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultServerKey),
                HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultSystemKeyPublic)));
 }
Example #2
0
        public void HostSecurityProvider_SignXmlWithServerID_Expected_ServerIDOverwritten()
        {
            var config = CreateConfig(
                Guid.NewGuid(),
                HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultServerKey),
                HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultSystemKeyPublic));
            var provider = new HostSecurityProviderImpl(config.Object);

            var originalID = Guid.Parse(TestXml.Attribute("ServerID").Value);
            var signedXml  = provider.SignXml(new StringBuilder(TestXml.ToString()));

            var xml      = XElement.Parse(signedXml.ToString());
            var serverID = xml.Attribute("ServerID");

            Assert.IsNotNull(serverID);
            Assert.AreNotEqual(originalID, serverID.Value);
        }
Example #3
0
 public static void ClassInitialize(TestContext testContext)
 {
     _defaultSettings = CreateDefaultConfig();
     _newSettings     = HostSecureConfig.CreateSettings(string.Empty, string.Empty, DefaultSystemKeyPublic);
 }
Example #4
0
 public static NameValueCollection CreateDefaultConfig()
 {
     return(HostSecureConfig.CreateSettings(DefaultServerID.ToString(), DefaultServerKey, DefaultSystemKeyPublic));
 }