Exemple #1
0
        public void TestICredential_LongTokenShouldWork()
        {
            // Tokens can be rather large. 1040: a size that can be stored.
            const int tokenLength = 1040;

            Assert.IsTrue(tokenLength < Credential.MaxCredentialBlobSize, "This test is supposed to verify a valid length.");

            string      test = "longPasswordTest";
            var         net  = new NetworkCredential(test, new String('1', tokenLength), test);
            ICredential cred = net.ToICredential();

            cred.TargetName = "TestSystem_LongPassword";
            Assert.IsNotNull(cred.SaveCredential(), "SaveCredential should handle passwords of token size");

            var cred1 = CredentialManager.GetCredentials("TestSystem_LongPassword");

            Assert.IsTrue(cred1.Password == net.Password, "Saved and retrieved password doesn't match");
        }