metasploit-credential 1.0.0.pre.rails.pre.4.0c → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +20 -41
  3. data/app/models/metasploit/credential/core.rb +1 -1
  4. data/app/models/metasploit/credential/login.rb +1 -1
  5. data/app/models/metasploit/credential/postgres_md5.rb +4 -0
  6. data/app/models/metasploit/credential/search/operator/type.rb +2 -2
  7. data/lib/metasploit/credential/creation.rb +1 -1
  8. data/lib/metasploit/credential/exporter/core.rb +5 -5
  9. data/lib/metasploit/credential/exporter/pwdump.rb +2 -2
  10. data/lib/metasploit/credential/importer/pwdump.rb +6 -5
  11. data/lib/metasploit/credential/migrator.rb +1 -1
  12. data/lib/metasploit/credential/version.rb +32 -7
  13. data/spec/lib/metasploit/credential/creation_spec.rb +6 -8
  14. data/spec/lib/metasploit/credential/exporter/core_spec.rb +99 -84
  15. data/spec/lib/metasploit/credential/exporter/pwdump_spec.rb +14 -16
  16. data/spec/lib/metasploit/credential/importer/core_spec.rb +10 -12
  17. data/spec/lib/metasploit/credential/importer/multi_spec.rb +4 -6
  18. data/spec/lib/metasploit/credential/importer/pwdump_spec.rb +11 -13
  19. data/spec/lib/metasploit/credential/importer/zip_spec.rb +5 -7
  20. data/spec/lib/metasploit/credential/migrator_spec.rb +8 -9
  21. data/spec/lib/metasploit/credential/version_spec.rb +3 -139
  22. data/spec/lib/metasploit/credential_spec.rb +4 -15
  23. data/spec/models/mdm/service_spec.rb +3 -5
  24. data/spec/models/mdm/session_spec.rb +2 -4
  25. data/spec/models/mdm/task_spec.rb +4 -6
  26. data/spec/models/mdm/user_spec.rb +2 -4
  27. data/spec/models/mdm/workspace_spec.rb +2 -4
  28. data/spec/models/metasploit/credential/blank_username_spec.rb +4 -7
  29. data/spec/models/metasploit/credential/core_spec.rb +43 -45
  30. data/spec/models/metasploit/credential/login/status_spec.rb +19 -21
  31. data/spec/models/metasploit/credential/login_spec.rb +33 -35
  32. data/spec/models/metasploit/credential/nonreplayable_hash_spec.rb +3 -5
  33. data/spec/models/metasploit/credential/ntlm_hash_spec.rb +13 -15
  34. data/spec/models/metasploit/credential/origin/cracked_password_spec.rb +5 -7
  35. data/spec/models/metasploit/credential/origin/import_spec.rb +7 -10
  36. data/spec/models/metasploit/credential/origin/manual_spec.rb +7 -9
  37. data/spec/models/metasploit/credential/origin/service_spec.rb +9 -11
  38. data/spec/models/metasploit/credential/origin/session_spec.rb +10 -12
  39. data/spec/models/metasploit/credential/password_hash_spec.rb +4 -6
  40. data/spec/models/metasploit/credential/password_spec.rb +3 -5
  41. data/spec/models/metasploit/credential/postgres_md5_spec.rb +4 -6
  42. data/spec/models/metasploit/credential/private_spec.rb +7 -9
  43. data/spec/models/metasploit/credential/public_spec.rb +4 -6
  44. data/spec/models/metasploit/credential/realm_spec.rb +12 -14
  45. data/spec/models/metasploit/credential/replayable_hash_spec.rb +3 -5
  46. data/spec/models/metasploit/credential/ssh_key_spec.rb +15 -17
  47. data/spec/models/metasploit/credential/username_spec.rb +5 -9
  48. data/spec/models/metasploit_data_models/search/visitor/relation_spec.rb +1 -3
  49. data/spec/spec_helper.rb +95 -25
  50. data/spec/support/shared/contexts/mdm/workspace.rb +1 -1
  51. data/spec/support/shared/examples/core_validations.rb +117 -42
  52. data/spec/support/shared/examples/single_table_inheritance_database_columns.rb +2 -2
  53. data/spec/support/shared/examples/timestamp_database_column.rb +2 -2
  54. metadata +30 -16
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Credential::Exporter::Pwdump do
1
+ RSpec.describe Metasploit::Credential::Exporter::Pwdump do
4
2
  include_context 'Mdm::Workspace'
5
3
 
6
4
  subject(:exporter){ Metasploit::Credential::Exporter::Pwdump.new}
@@ -13,7 +11,7 @@ describe Metasploit::Credential::Exporter::Pwdump do
13
11
  describe "associated Mdm::Service objects" do
14
12
  it 'should properly format the service information' do
15
13
  service = login.service
16
- exporter.format_service_for_login(login).should == "#{service.host.address.to_s}:#{service.port}/#{service.proto} (#{service.name})"
14
+ expect(exporter.format_service_for_login(login)).to eq "#{service.host.address.to_s}:#{service.port}/#{service.proto} (#{service.name})"
17
15
  end
18
16
  end
19
17
 
@@ -25,17 +23,17 @@ describe Metasploit::Credential::Exporter::Pwdump do
25
23
  end
26
24
 
27
25
  it 'should have the proper formatting with extant data' do
28
- exporter.format_password(login).should == "#{login.core.public.username} #{login.core.private.data}"
26
+ expect(exporter.format_password(login)).to eq("#{login.core.public.username} #{login.core.private.data}")
29
27
  end
30
28
 
31
29
  it 'should have the proper formatting with a missing public' do
32
30
  login.core.public.username = ""
33
- exporter.format_password(login).should == "#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING} #{login.core.private.data}"
31
+ expect(exporter.format_password(login)).to eq("#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING} #{login.core.private.data}")
34
32
  end
35
33
 
36
34
  it 'should have the proper formatting with a missing private' do
37
35
  login.core.private.data = ""
38
- exporter.format_password(login).should == "#{login.core.public.username} #{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}"
36
+ expect(exporter.format_password(login)).to eq("#{login.core.public.username} #{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}")
39
37
  end
40
38
  end
41
39
 
@@ -47,17 +45,17 @@ describe Metasploit::Credential::Exporter::Pwdump do
47
45
  end
48
46
 
49
47
  it 'should have the proper formatting with extant data' do
50
- exporter.format_nonreplayable_hash(login).should == "#{login.core.public.username}:#{login.core.private.data}:::"
48
+ expect(exporter.format_nonreplayable_hash(login)).to eq("#{login.core.public.username}:#{login.core.private.data}:::")
51
49
  end
52
50
 
53
51
  it 'should have the proper formatting with a missing public' do
54
52
  login.core.public.username = ""
55
- exporter.format_nonreplayable_hash(login).should == "#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:#{login.core.private.data}:::"
53
+ expect(exporter.format_nonreplayable_hash(login)).to eq("#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:#{login.core.private.data}:::")
56
54
  end
57
55
 
58
56
  it 'should have the proper formatting with a missing private' do
59
57
  login.core.private.data = ""
60
- exporter.format_nonreplayable_hash(login).should == "#{login.core.public.username}:#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:::"
58
+ expect(exporter.format_nonreplayable_hash(login)).to eq("#{login.core.public.username}:#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:::")
61
59
  end
62
60
  end
63
61
 
@@ -69,17 +67,17 @@ describe Metasploit::Credential::Exporter::Pwdump do
69
67
  end
70
68
 
71
69
  it 'should have the proper formatting with extant data' do
72
- exporter.format_ntlm_hash(login).should == "#{login.core.public.username}:#{login.id}:#{login.core.private.data}:::"
70
+ expect(exporter.format_ntlm_hash(login)).to eq("#{login.core.public.username}:#{login.id}:#{login.core.private.data}:::")
73
71
  end
74
72
 
75
73
  it 'should have the proper formatting with a missing public' do
76
74
  login.core.public.username = ""
77
- exporter.format_ntlm_hash(login).should == "#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:#{login.id}:#{login.core.private.data}:::"
75
+ expect(exporter.format_ntlm_hash(login)).to eq("#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:#{login.id}:#{login.core.private.data}:::")
78
76
  end
79
77
 
80
78
  it 'should have the proper formatting with a missing private' do
81
79
  login.core.private.data = ""
82
- exporter.format_ntlm_hash(login).should == "#{login.core.public.username}:#{login.id}:#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:::"
80
+ expect(exporter.format_ntlm_hash(login)).to eq("#{login.core.public.username}:#{login.id}:#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:::")
83
81
  end
84
82
  end
85
83
 
@@ -91,17 +89,17 @@ describe Metasploit::Credential::Exporter::Pwdump do
91
89
  end
92
90
 
93
91
  it 'should have the proper formatting with extant data' do
94
- exporter.format_postgres_md5(login).should == "#{login.core.public.username}:#{login.core.private.data}"
92
+ expect(exporter.format_postgres_md5(login)).to eq("#{login.core.public.username}:#{login.core.private.data}")
95
93
  end
96
94
 
97
95
  it 'should have the proper formatting with a missing public' do
98
96
  login.core.public.username = ""
99
- exporter.format_postgres_md5(login).should == "#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:#{login.core.private.data}"
97
+ expect(exporter.format_postgres_md5(login)).to eq("#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}:#{login.core.private.data}")
100
98
  end
101
99
 
102
100
  it 'should have the proper formatting with a missing private' do
103
101
  login.core.private.data = ""
104
- exporter.format_postgres_md5(login).should == "#{login.core.public.username}:#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}"
102
+ expect(exporter.format_postgres_md5(login)).to eq("#{login.core.public.username}:#{Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING}")
105
103
  end
106
104
 
107
105
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Credential::Importer::Core do
1
+ RSpec.describe Metasploit::Credential::Importer::Core do
4
2
  include_context 'Mdm::Workspace'
5
3
  let(:workspace){FactoryGirl.create(:mdm_workspace)}
6
4
 
@@ -19,7 +17,7 @@ describe Metasploit::Credential::Importer::Core do
19
17
  core_csv_importer.private_credential_type = "Metasploit::Credential::Password"
20
18
  end
21
19
 
22
- it { should be_valid }
20
+ it { is_expected.to be_valid }
23
21
  end
24
22
 
25
23
  describe "with a non-supported credential type" do
@@ -36,7 +34,7 @@ describe Metasploit::Credential::Importer::Core do
36
34
 
37
35
  it 'should report the error being invalid private type' do
38
36
  core_csv_importer.valid?
39
- core_csv_importer.errors[:private_credential_type].should include error
37
+ expect(core_csv_importer.errors[:private_credential_type]).to include error
40
38
  end
41
39
  end
42
40
 
@@ -54,7 +52,7 @@ describe Metasploit::Credential::Importer::Core do
54
52
 
55
53
  it 'should report the error being invalid headers' do
56
54
  core_csv_importer.valid?
57
- core_csv_importer.errors[:input].should include error
55
+ expect(core_csv_importer.errors[:input]).to include error
58
56
  end
59
57
  end
60
58
  end
@@ -62,7 +60,7 @@ describe Metasploit::Credential::Importer::Core do
62
60
  describe "long-form imports" do
63
61
  describe "with well-formed CSV data" do
64
62
  describe "with a compliant header" do
65
- it { should be_valid }
63
+ it { is_expected.to be_valid }
66
64
  end
67
65
 
68
66
  describe "with data that includes a missing Public (username)" do
@@ -127,7 +125,7 @@ describe Metasploit::Credential::Importer::Core do
127
125
 
128
126
  it 'should report the error being incorrect headers' do
129
127
  core_csv_importer.valid?
130
- core_csv_importer.errors[:input].should include error
128
+ expect(core_csv_importer.errors[:input]).to include error
131
129
  end
132
130
  end
133
131
 
@@ -140,11 +138,11 @@ describe Metasploit::Credential::Importer::Core do
140
138
  core_csv_importer.input = FactoryGirl.generate(:malformed_csv)
141
139
  end
142
140
 
143
- it { should be_invalid }
141
+ it { is_expected.to be_invalid }
144
142
 
145
143
  it 'should report the error being malformed CSV' do
146
144
  core_csv_importer.valid?
147
- core_csv_importer.errors[:input].should include error
145
+ expect(core_csv_importer.errors[:input]).to include error
148
146
  end
149
147
  end
150
148
 
@@ -157,11 +155,11 @@ describe Metasploit::Credential::Importer::Core do
157
155
  core_csv_importer.input = FactoryGirl.generate(:empty_core_csv)
158
156
  end
159
157
 
160
- it { should be_invalid }
158
+ it { is_expected.to be_invalid }
161
159
 
162
160
  it 'should show the proper error message' do
163
161
  core_csv_importer.valid?
164
- core_csv_importer.errors[:input].should include error
162
+ expect(core_csv_importer.errors[:input]).to include error
165
163
  end
166
164
  end
167
165
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Credential::Importer::Multi do
1
+ RSpec.describe Metasploit::Credential::Importer::Multi do
4
2
  include_context 'Mdm::Workspace'
5
3
  include_context 'metasploit_credential_importer_zip_file'
6
4
 
@@ -31,7 +29,7 @@ describe Metasploit::Credential::Importer::Multi do
31
29
  context "when given zip file" do
32
30
  subject(:multi_importer){ Metasploit::Credential::Importer::Multi.new(input: File.open(supported_file), origin: import_origin)}
33
31
 
34
- it { should be_valid }
32
+ it { is_expected.to be_valid }
35
33
  end
36
34
 
37
35
  describe "#csv?" do
@@ -39,7 +37,7 @@ describe Metasploit::Credential::Importer::Multi do
39
37
  subject(:multi_importer){ Metasploit::Credential::Importer::Multi.new(input: File.open(valid_csv_file), origin: import_origin)}
40
38
 
41
39
  it 'should return true' do
42
- multi_importer.csv?.should be_true
40
+ expect(multi_importer.csv?).to eq(true)
43
41
  end
44
42
  end
45
43
 
@@ -47,7 +45,7 @@ describe Metasploit::Credential::Importer::Multi do
47
45
  subject(:multi_importer){ Metasploit::Credential::Importer::Multi.new(input: File.open(unsupported_file), origin: import_origin)}
48
46
 
49
47
  it 'should return true' do
50
- multi_importer.csv?.should be_false
48
+ expect(multi_importer.csv?).to eq(false)
51
49
  end
52
50
  end
53
51
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Credential::Importer::Pwdump do
1
+ RSpec.describe Metasploit::Credential::Importer::Pwdump do
4
2
  include_context 'Mdm::Workspace'
5
3
 
6
4
  let(:workspace) {FactoryGirl.create(:mdm_workspace)}
@@ -11,12 +9,12 @@ describe Metasploit::Credential::Importer::Pwdump do
11
9
  origin: origin)}
12
10
 
13
11
  describe "validation" do
14
- it { should be_valid }
12
+ it { is_expected.to be_valid }
15
13
 
16
14
  describe "without a filename" do
17
15
  it 'should not be valid' do
18
16
  pwdump_importer.filename = nil
19
- pwdump_importer.should_not be_valid
17
+ expect(pwdump_importer).not_to be_valid
20
18
  end
21
19
  end
22
20
  end
@@ -24,32 +22,32 @@ describe Metasploit::Credential::Importer::Pwdump do
24
22
  describe "#blank_or_string" do
25
23
  context "with a blank string" do
26
24
  it 'should return empty string' do
27
- pwdump_importer.blank_or_string("").should == ""
25
+ expect(pwdump_importer.blank_or_string("")).to eq("")
28
26
  end
29
27
  end
30
28
  context "with a BLANK_CRED_STRING" do
31
29
  it 'should return empty string' do
32
- pwdump_importer.blank_or_string(Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING).should == ""
30
+ expect(pwdump_importer.blank_or_string(Metasploit::Credential::Exporter::Pwdump::BLANK_CRED_STRING)).to eq("")
33
31
  end
34
32
  end
35
33
 
36
34
  context "with a JTR_NO_PASSWORD_STRING" do
37
35
  it 'should return empty string' do
38
- pwdump_importer.blank_or_string(Metasploit::Credential::Importer::Pwdump::JTR_NO_PASSWORD_STRING).should == ""
36
+ expect(pwdump_importer.blank_or_string(Metasploit::Credential::Importer::Pwdump::JTR_NO_PASSWORD_STRING)).to eq("")
39
37
  end
40
38
  end
41
39
 
42
40
  context "with a present string" do
43
41
  it 'should return the string' do
44
42
  string = "mah-hard-passwerd"
45
- pwdump_importer.blank_or_string(string).should == string
43
+ expect(pwdump_importer.blank_or_string(string)).to eq(string)
46
44
  end
47
45
  end
48
46
 
49
47
  context "with the dehex flag" do
50
48
  it 'should dehex the string with the Metasploit::Credential::Text#dehex method' do
51
49
  string = "mah-hard-passwerd"
52
- Metasploit::Credential::Text.should_receive(:dehex).with string
50
+ expect(Metasploit::Credential::Text).to receive(:dehex).with string
53
51
  pwdump_importer.blank_or_string(string, true)
54
52
  end
55
53
  end
@@ -64,8 +62,8 @@ describe Metasploit::Credential::Importer::Pwdump do
64
62
  it 'should create Cores with the same Origin' do
65
63
  pwdump_importer.import!
66
64
  origins = Metasploit::Credential::Core.all.collect(&:origin).uniq
67
- origins.size.should be(1)
68
- origins.first.id.should be(origin.id)
65
+ expect(origins.size).to be(1)
66
+ expect(origins.first.id).to be(origin.id)
69
67
  end
70
68
 
71
69
  it 'should create the proper number of Logins' do
@@ -96,7 +94,7 @@ describe Metasploit::Credential::Importer::Pwdump do
96
94
  # Legacy files may have these lines when missing SSH key files
97
95
  it 'should not create a Private from a "Warning" line' do
98
96
  pwdump_importer.import!
99
- Metasploit::Credential::Private.where(data:'missing').should be_blank
97
+ expect(Metasploit::Credential::Private.where(data:'missing')).to be_blank
100
98
  end
101
99
  end
102
100
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Credential::Importer::Zip do
1
+ RSpec.describe Metasploit::Credential::Importer::Zip do
4
2
  include_context 'Mdm::Workspace'
5
3
  include_context 'metasploit_credential_importer_zip_file'
6
4
 
@@ -11,7 +9,7 @@ describe Metasploit::Credential::Importer::Zip do
11
9
  DUMMY_ZIP_PATH = "/tmp/import-test-dummy.zip"
12
10
 
13
11
  context "when the zip file contains a keys directory and a manifest CSV" do
14
- it { should be_valid }
12
+ it { is_expected.to be_valid }
15
13
  end
16
14
 
17
15
  context "when the zip file is not actually an archive" do
@@ -32,7 +30,7 @@ describe Metasploit::Credential::Importer::Zip do
32
30
 
33
31
  it 'should show the proper error message' do
34
32
  zip_importer.valid?
35
- zip_importer.errors[:input].should include error
33
+ expect(zip_importer.errors[:input]).to include error
36
34
  end
37
35
  end
38
36
 
@@ -49,7 +47,7 @@ describe Metasploit::Credential::Importer::Zip do
49
47
 
50
48
  it 'should show the proper error message' do
51
49
  zip_importer.valid?
52
- zip_importer.errors[:input].should include error
50
+ expect(zip_importer.errors[:input]).to include error
53
51
  end
54
52
  end
55
53
 
@@ -63,7 +61,7 @@ describe Metasploit::Credential::Importer::Zip do
63
61
 
64
62
  describe "zip constants" do
65
63
  it 'should have ZIP_HEADER_IDENTIFIER whose length corresponds to ZIP_HEADER_BYTE_LENGTH' do
66
- Metasploit::Credential::Importer::Zip::ZIP_HEADER_IDENTIFIER.size.should == Metasploit::Credential::Importer::Zip::ZIP_HEADER_BYTE_LENGTH
64
+ expect(Metasploit::Credential::Importer::Zip::ZIP_HEADER_IDENTIFIER.size).to eq(Metasploit::Credential::Importer::Zip::ZIP_HEADER_BYTE_LENGTH)
67
65
  end
68
66
  end
69
67
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'tempfile'
3
3
 
4
- describe Metasploit::Credential::Migrator do
4
+ RSpec.describe Metasploit::Credential::Migrator do
5
5
  include_context 'Mdm::Workspace'
6
6
 
7
7
  let(:workspace){ FactoryGirl.create(:mdm_workspace) }
@@ -62,7 +62,6 @@ describe Metasploit::Credential::Migrator do
62
62
  it "should be created for each Mdm::Cred" do
63
63
  expect(Metasploit::Credential::Public.pluck(:username)).to match_array([cred1.user, cred2.user, cred3.user])
64
64
  end
65
-
66
65
  end
67
66
 
68
67
  describe "new Privates" do
@@ -71,7 +70,7 @@ describe Metasploit::Credential::Migrator do
71
70
  end
72
71
 
73
72
  it "should be created for each Mdm::Cred" do
74
- expect(Metasploit::Credential::Password.pluck(:data)).to match_array([cred1.pass, cred2.pass, cred3.pass])
73
+ expect(Metasploit::Credential::Password.pluck(:data)).to match_array([cred1.pass, cred2.pass, cred3.pass])
75
74
  end
76
75
  end
77
76
  end
@@ -91,7 +90,7 @@ describe Metasploit::Credential::Migrator do
91
90
  end
92
91
 
93
92
  it 'should create a new NTLMHash in the database' do
94
- Metasploit::Credential::NTLMHash.where(data: cred.pass).should_not be_blank
93
+ expect(Metasploit::Credential::NTLMHash.where(data: cred.pass)).not_to be_blank
95
94
  end
96
95
  end
97
96
 
@@ -120,7 +119,7 @@ describe Metasploit::Credential::Migrator do
120
119
  end
121
120
 
122
121
  it 'should create a new SSHKey in the database' do
123
- Metasploit::Credential::SSHKey.where(data: ssh_key_content).should_not be_blank
122
+ expect(Metasploit::Credential::SSHKey.where(data: ssh_key_content)).not_to be_blank
124
123
  end
125
124
  end
126
125
 
@@ -138,7 +137,7 @@ describe Metasploit::Credential::Migrator do
138
137
  end
139
138
 
140
139
  it 'should create a new SSHKey in the database' do
141
- Metasploit::Credential::SSHKey.where(data: ssh_key_content).should_not be_blank
140
+ expect(Metasploit::Credential::SSHKey.where(data: ssh_key_content)).not_to be_blank
142
141
  end
143
142
  end
144
143
 
@@ -156,7 +155,7 @@ describe Metasploit::Credential::Migrator do
156
155
  end
157
156
 
158
157
  it 'should not create a new SSHKey in the database' do
159
- Metasploit::Credential::SSHKey.count.should be_zero
158
+ expect(Metasploit::Credential::SSHKey.count).to be_zero
160
159
  end
161
160
  end
162
161
 
@@ -176,7 +175,7 @@ describe Metasploit::Credential::Migrator do
176
175
  end
177
176
 
178
177
  it 'should create a new Password in the database' do
179
- Metasploit::Credential::Password.where(data: cred.pass).should_not be_blank
178
+ expect(Metasploit::Credential::Password.where(data: cred.pass)).not_to be_blank
180
179
  end
181
180
  end
182
181
 
@@ -194,7 +193,7 @@ describe Metasploit::Credential::Migrator do
194
193
  end
195
194
 
196
195
  it 'should create a new NonreplayableHash in the database' do
197
- Metasploit::Credential::NonreplayableHash.where(data: cred.pass).should_not be_blank
196
+ expect(Metasploit::Credential::NonreplayableHash.where(data: cred.pass)).not_to be_blank
198
197
  end
199
198
  end
200
199
  end
@@ -1,139 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Credential::Version do
4
- context 'CONSTANTS' do
5
- context 'MAJOR' do
6
- subject(:major) do
7
- described_class::MAJOR
8
- end
9
-
10
- it { should be_a Integer }
11
- end
12
-
13
- context 'MINOR' do
14
- subject(:minor) do
15
- described_class::MINOR
16
- end
17
-
18
- it { should be_a Integer }
19
- end
20
-
21
- context 'PATCH' do
22
- subject(:patch) do
23
- described_class::PATCH
24
- end
25
-
26
- it { should be_a Integer }
27
- end
28
-
29
- pull_request = ENV['TRAVIS_PULL_REQUEST']
30
-
31
- # a pull request cannot check PRERELEASE because it will be tested in the target branch, but the source itself
32
- # is from the source branch and so has the source branch PRERELEASE.
33
- #
34
- # PRERELEASE can only be set appropriately for a merge by merging to the target branch and then updating PRERELEASE
35
- # on the target branch before committing and/or pushing to github and travis-ci.
36
- if pull_request.nil? || pull_request == 'false'
37
- context 'PREPRELEASE' do
38
- subject(:prerelease) do
39
- described_class::PRERELEASE
40
- end
41
-
42
- branch = ENV['TRAVIS_BRANCH']
43
-
44
- if branch.blank?
45
- branch = `git rev-parse --abbrev-ref HEAD`.strip
46
- end
47
-
48
- if branch == 'master'
49
- it 'does not have a PRERELEASE' do
50
- expect(defined? described_class::PRERELEASE).to be_nil
51
- end
52
- else
53
- branch_regex = %r{\A(?:refs/remotes/)?(?<type>bug|chore|feature|staging)(/(?<story>[^/]+))?/(?<prerelease>[^\/]+)\z}
54
- match = branch.match(branch_regex)
55
-
56
- if match
57
- it 'matches the branch relative name' do
58
- expect(prerelease).to eq(match[:prerelease])
59
- end
60
- else
61
- tag_regex = /\Av(?<major>\d+).(?<minor>\d+).(?<patch>\d+)(\.pre\.(?<prerelease>.*))?\z/
62
- # travis-ci sets TRAVIS_BRANCH to the tag name for tag builds
63
- match = branch.match(tag_regex)
64
-
65
- if match
66
- tag_prerelease = match[:prerelease]
67
-
68
- if tag_prerelease
69
- it 'matches the tag prerelease converted from a gem version to a VERSION' do
70
- expect(prerelease).to eq(tag_prerelease.gsub('.pre.', '-'))
71
- end
72
- else
73
- it 'does not have a PRERELEASE' do
74
- expect(defined? described_class::PRERELEASE).to be_nil
75
- end
76
- end
77
- else
78
- it 'has a abbreviated reference that can be parsed for prerelease' do
79
- fail "Do not know how to parse #{branch.inspect} for PRERELEASE"
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end
86
- end
87
-
88
- context 'full' do
89
- subject(:full) do
90
- described_class.full
91
- end
92
-
93
- #
94
- # lets
95
- #
96
-
97
- let(:major) do
98
- 1
99
- end
100
-
101
- let(:minor) do
102
- 2
103
- end
104
-
105
- let(:patch) do
106
- 3
107
- end
108
-
109
- before(:each) do
110
- stub_const("#{described_class}::MAJOR", major)
111
- stub_const("#{described_class}::MINOR", minor)
112
- stub_const("#{described_class}::PATCH", patch)
113
- end
114
-
115
- context 'with PRERELEASE' do
116
- let(:prerelease) do
117
- 'prerelease'
118
- end
119
-
120
- before(:each) do
121
- stub_const("#{described_class}::PRERELEASE", prerelease)
122
- end
123
-
124
- it 'is <major>.<minor>.<patch>-<prerelease>' do
125
- expect(full).to eq("#{major}.#{minor}.#{patch}-#{prerelease}")
126
- end
127
- end
128
-
129
- context 'without PRERELEASE' do
130
- before(:each) do
131
- hide_const("#{described_class}::PRERELEASE")
132
- end
133
-
134
- it 'is <major>.<minor>.<patch>' do
135
- expect(full).to eq("#{major}.#{minor}.#{patch}")
136
- end
137
- end
138
- end
139
- end
1
+ RSpec.describe Metasploit::Credential::Version do
2
+ it_should_behave_like 'Metasploit::Version Version Module'
3
+ end