|
65 | 65 | it { is_expected.to respond_to :set_rhosts_from_addrs }
|
66 | 66 |
|
67 | 67 | describe "#cmd_creds" do
|
| 68 | + |
| 69 | + describe "-u" do |
| 70 | + let(:username) { "thisuser" } |
| 71 | + let(:password) { "thispass" } |
| 72 | + let(:nomatch_username) { "thatuser" } |
| 73 | + let(:nomatch_password) { "thatpass" } |
| 74 | + let(:blank_username) { "" } |
| 75 | + let(:blank_password) { "" } |
| 76 | + let(:nonblank_username) { "nonblank_user" } |
| 77 | + let(:nonblank_password) { "nonblank_pass" } |
| 78 | + before(:each) do |
| 79 | + priv = FactoryGirl.create(:metasploit_credential_password, data: password) |
| 80 | + pub = FactoryGirl.create(:metasploit_credential_username, username: username) |
| 81 | + core = FactoryGirl.create(:metasploit_credential_core, |
| 82 | + origin: FactoryGirl.create(:metasploit_credential_origin_import), |
| 83 | + private: priv, |
| 84 | + public: pub, |
| 85 | + realm: nil, |
| 86 | + workspace: framework.db.workspace) |
| 87 | + nonblank_priv = FactoryGirl.create(:metasploit_credential_password, data: nonblank_password) |
| 88 | + blank_pub = FactoryGirl.create(:metasploit_credential_blank_username) |
| 89 | + core = FactoryGirl.create(:metasploit_credential_core, |
| 90 | + origin: FactoryGirl.create(:metasploit_credential_origin_import), |
| 91 | + private: nonblank_priv, |
| 92 | + public: blank_pub, |
| 93 | + realm: nil, |
| 94 | + workspace: framework.db.workspace) |
| 95 | + nonblank_pub = FactoryGirl.create(:metasploit_credential_username, username: nonblank_username) |
| 96 | + blank_priv = FactoryGirl.create(:metasploit_credential_password, data: blank_password) |
| 97 | + core = FactoryGirl.create(:metasploit_credential_core, |
| 98 | + origin: FactoryGirl.create(:metasploit_credential_origin_import), |
| 99 | + private: blank_priv, |
| 100 | + public: nonblank_pub, |
| 101 | + realm: nil, |
| 102 | + workspace: framework.db.workspace) |
| 103 | + end |
| 104 | + context "when the credential is present" do |
| 105 | + it "should show a user that matches the given expression" do |
| 106 | + db.cmd_creds("-u", username) |
| 107 | + @output.should =~ [ |
| 108 | + "Credentials", |
| 109 | + "===========", |
| 110 | + "", |
| 111 | + "host service public private realm private_type", |
| 112 | + "---- ------- ------ ------- ----- ------------", |
| 113 | + " thisuser thispass Password", |
| 114 | + ] |
| 115 | + end |
| 116 | + context "and when the username is blank" do |
| 117 | + it "should show a user that matches the given expression" do |
| 118 | + db.cmd_creds("-u", blank_username ) |
| 119 | + @output.should =~ [ |
| 120 | + "Credentials", |
| 121 | + "===========", |
| 122 | + "", |
| 123 | + "host service public private realm private_type", |
| 124 | + "---- ------- ------ ------- ----- ------------", |
| 125 | + " nonblank_pass Password" |
| 126 | + ] |
| 127 | + end |
| 128 | + end |
| 129 | + context "and when the password is blank" do |
| 130 | + it "should show a user that matches the given expression" do |
| 131 | + db.cmd_creds("-P", blank_password ) |
| 132 | + @output.should =~ [ |
| 133 | + "Credentials", |
| 134 | + "===========", |
| 135 | + "", |
| 136 | + "host service public private realm private_type", |
| 137 | + "---- ------- ------ ------- ----- ------------", |
| 138 | + " nonblank_user Password" |
| 139 | + ] |
| 140 | + end |
| 141 | + end |
| 142 | + end |
| 143 | + context "when the credential is absent" do |
| 144 | + context "due to a nonmatching username" do |
| 145 | + it "should return a blank set" do |
| 146 | + db.cmd_creds("-u", nomatch_username) |
| 147 | + @output.should =~ [ |
| 148 | + "===========", |
| 149 | + "Credentials", |
| 150 | + "", |
| 151 | + "---- ------- ------ ------- ----- ------------", |
| 152 | + "host service public private realm private_type" |
| 153 | + ] |
| 154 | + end |
| 155 | + end |
| 156 | + context "due to a nonmatching password" do |
| 157 | + it "should return a blank set" do |
| 158 | + db.cmd_creds("-P", nomatch_password) |
| 159 | + @output.should =~ [ |
| 160 | + "===========", |
| 161 | + "Credentials", |
| 162 | + "", |
| 163 | + "---- ------- ------ ------- ----- ------------", |
| 164 | + "host service public private realm private_type" |
| 165 | + ] |
| 166 | + end |
| 167 | + end |
| 168 | + end |
| 169 | + end |
| 170 | + |
68 | 171 | describe "add-password" do
|
69 | 172 | let(:username) { "username" }
|
70 | 173 | let(:password) { "password" }
|
|
0 commit comments