Ejemplo n.º 1
0
        public virtual void TestCredentialSuccessfulLifecycle()
        {
            outContent.Reset();
            string[] args1 = new string[] { "create", "credential1", "-value", "p@ssw0rd", "-provider"
                                            , jceksProvider };
            int             rc = 0;
            CredentialShell cs = new CredentialShell();

            cs.SetConf(new Configuration());
            rc = cs.Run(args1);
            Assert.Equal(outContent.ToString(), 0, rc);
            Assert.True(outContent.ToString().Contains("credential1 has been successfully "
                                                       + "created."));
            outContent.Reset();
            string[] args2 = new string[] { "list", "-provider", jceksProvider };
            rc = cs.Run(args2);
            Assert.Equal(0, rc);
            Assert.True(outContent.ToString().Contains("credential1"));
            outContent.Reset();
            string[] args4 = new string[] { "delete", "credential1", "-f", "-provider", jceksProvider };
            rc = cs.Run(args4);
            Assert.Equal(0, rc);
            Assert.True(outContent.ToString().Contains("credential1 has been successfully "
                                                       + "deleted."));
            outContent.Reset();
            string[] args5 = new string[] { "list", "-provider", jceksProvider };
            rc = cs.Run(args5);
            Assert.Equal(0, rc);
            NUnit.Framework.Assert.IsFalse(outContent.ToString(), outContent.ToString().Contains
                                               ("credential1"));
        }
Ejemplo n.º 2
0
        public virtual void TestTransientProviderWarning()
        {
            string[] args1 = new string[] { "create", "credential1", "-value", "p@ssw0rd", "-provider"
                                            , "user:///" };
            int             rc = 0;
            CredentialShell cs = new CredentialShell();

            cs.SetConf(new Configuration());
            rc = cs.Run(args1);
            Assert.Equal(outContent.ToString(), 0, rc);
            Assert.True(outContent.ToString().Contains("WARNING: you are modifying a "
                                                       + "transient provider."));
            string[] args2 = new string[] { "delete", "credential1", "-f", "-provider", "user:///" };
            rc = cs.Run(args2);
            Assert.Equal(outContent.ToString(), 0, rc);
            Assert.True(outContent.ToString().Contains("credential1 has been successfully "
                                                       + "deleted."));
        }
Ejemplo n.º 3
0
        public virtual void TestInvalidProvider()
        {
            string[] args1 = new string[] { "create", "credential1", "-value", "p@ssw0rd", "-provider"
                                            , "sdff://file/tmp/credstore.jceks" };
            int             rc = 0;
            CredentialShell cs = new CredentialShell();

            cs.SetConf(new Configuration());
            rc = cs.Run(args1);
            Assert.Equal(1, rc);
            Assert.True(outContent.ToString().Contains("There are no valid "
                                                       + "CredentialProviders configured."));
        }
Ejemplo n.º 4
0
        public virtual void TestPromptForCredential()
        {
            string[]       args1     = new string[] { "create", "credential1", "-provider", jceksProvider };
            AList <string> passwords = new AList <string>();

            passwords.AddItem("p@ssw0rd");
            passwords.AddItem("p@ssw0rd");
            int             rc    = 0;
            CredentialShell shell = new CredentialShell();

            shell.SetConf(new Configuration());
            shell.SetPasswordReader(new TestCredShell.MockPasswordReader(this, passwords));
            rc = shell.Run(args1);
            Assert.Equal(0, rc);
            Assert.True(outContent.ToString().Contains("credential1 has been successfully "
                                                       + "created."));
            string[] args2 = new string[] { "delete", "credential1", "-f", "-provider", jceksProvider };
            rc = shell.Run(args2);
            Assert.Equal(0, rc);
            Assert.True(outContent.ToString().Contains("credential1 has been successfully "
                                                       + "deleted."));
        }
Ejemplo n.º 5
0
        public virtual void TestTransientProviderOnlyConfig()
        {
            string[]        args1  = new string[] { "create", "credential1" };
            int             rc     = 0;
            CredentialShell cs     = new CredentialShell();
            Configuration   config = new Configuration();

            config.Set(CredentialProviderFactory.CredentialProviderPath, "user:///");
            cs.SetConf(config);
            rc = cs.Run(args1);
            Assert.Equal(1, rc);
            Assert.True(outContent.ToString().Contains("There are no valid "
                                                       + "CredentialProviders configured."));
        }
Ejemplo n.º 6
0
        public virtual void TestPromptForCredentialWithEmptyPasswd()
        {
            string[]       args1     = new string[] { "create", "credential1", "-provider", jceksProvider };
            AList <string> passwords = new AList <string>();

            passwords.AddItem(null);
            passwords.AddItem("p@ssw0rd");
            int             rc    = 0;
            CredentialShell shell = new CredentialShell();

            shell.SetConf(new Configuration());
            shell.SetPasswordReader(new TestCredShell.MockPasswordReader(this, passwords));
            rc = shell.Run(args1);
            Assert.Equal(outContent.ToString(), 1, rc);
            Assert.True(outContent.ToString().Contains("Passwords don't match"
                                                       ));
        }