public virtual void TestEmptyArgList() { CredentialShell shell = new CredentialShell(); shell.SetConf(new Configuration()); Assert.Equal(1, shell.Init(new string[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")); }
public virtual void TestCommandHelpExitsNormally() { foreach (string cmd in Arrays.AsList("create", "list", "delete")) { CredentialShell shell = new CredentialShell(); shell.SetConf(new Configuration()); Assert.Equal("Expected help argument on " + cmd + " to return 0" , 0, shell.Init(new string[] { cmd, "-help" })); } }
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.")); }
public virtual void TestEmptyArgForCommands() { CredentialShell shell = new CredentialShell(); string[] command = new string[] { "list", "-provider" }; Assert.Equal("Expected empty argument on " + command + " to return 1" , 1, shell.Init(command)); foreach (string cmd in Arrays.AsList("create", "delete")) { shell.SetConf(new Configuration()); Assert.Equal("Expected empty argument on " + cmd + " to return 1" , 1, shell.Init(new string[] { cmd })); } }
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.")); }
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" )); }
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.")); }
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.")); }