metasploit-credential 0.7.17-java → 0.8.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/metasploit/credential/core.rb +18 -0
- data/db/migrate/20140728191933_unique_metasploit_credential_cores.rb +24 -0
- data/lib/metasploit/credential/version.rb +2 -2
- data/spec/dummy/db/structure.sql +23 -0
- data/spec/dummy/log/development.log +149 -0
- data/spec/dummy/log/test.log +47861 -0
- data/spec/models/metasploit/credential/core_spec.rb +193 -3
- metadata +2 -1
@@ -43,6 +43,98 @@ describe Metasploit::Credential::Core do
|
|
43
43
|
it { should have_db_index(:public_id) }
|
44
44
|
it { should have_db_index(:realm_id) }
|
45
45
|
it { should have_db_index(:workspace_id) }
|
46
|
+
|
47
|
+
context 'partial' do
|
48
|
+
#
|
49
|
+
# lets
|
50
|
+
#
|
51
|
+
|
52
|
+
let(:metasploit_credential_origin) {
|
53
|
+
FactoryGirl.create(:metasploit_credential_origin_manual)
|
54
|
+
}
|
55
|
+
|
56
|
+
let(:workspace) {
|
57
|
+
FactoryGirl.create(:mdm_workspace)
|
58
|
+
}
|
59
|
+
|
60
|
+
let(:second_metasploit_credential_core) {
|
61
|
+
FactoryGirl.build(
|
62
|
+
:metasploit_credential_core,
|
63
|
+
origin: metasploit_credential_origin,
|
64
|
+
private: private,
|
65
|
+
public: public,
|
66
|
+
workspace: workspace
|
67
|
+
)
|
68
|
+
}
|
69
|
+
|
70
|
+
#
|
71
|
+
# let!s
|
72
|
+
#
|
73
|
+
|
74
|
+
let!(:first_metasploit_credential_core) {
|
75
|
+
FactoryGirl.create(
|
76
|
+
:metasploit_credential_core,
|
77
|
+
origin: metasploit_credential_origin,
|
78
|
+
private: private,
|
79
|
+
public: public,
|
80
|
+
workspace: workspace
|
81
|
+
)
|
82
|
+
}
|
83
|
+
|
84
|
+
context '#private_id' do
|
85
|
+
context 'with nil' do
|
86
|
+
let(:private) {
|
87
|
+
nil
|
88
|
+
}
|
89
|
+
|
90
|
+
context '#public_id' do
|
91
|
+
context 'without nil' do
|
92
|
+
let(:public) {
|
93
|
+
FactoryGirl.create(:metasploit_credential_public)
|
94
|
+
}
|
95
|
+
|
96
|
+
it 'does not allow duplicates' do
|
97
|
+
expect {
|
98
|
+
second_metasploit_credential_core.save(validate: false)
|
99
|
+
}.to raise_error(ActiveRecord::RecordNotUnique)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'without nil' do
|
106
|
+
let(:private) do
|
107
|
+
FactoryGirl.create(:metasploit_credential_password)
|
108
|
+
end
|
109
|
+
|
110
|
+
context '#public_id' do
|
111
|
+
context 'with nil' do
|
112
|
+
let(:public) {
|
113
|
+
nil
|
114
|
+
}
|
115
|
+
|
116
|
+
it 'does not allow duplicates' do
|
117
|
+
expect {
|
118
|
+
second_metasploit_credential_core.save(validate: false)
|
119
|
+
}.to raise_error(ActiveRecord::RecordNotUnique)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'without nil' do
|
124
|
+
let(:public) {
|
125
|
+
FactoryGirl.create(:metasploit_credential_public)
|
126
|
+
}
|
127
|
+
|
128
|
+
it 'does not allow duplicates' do
|
129
|
+
expect {
|
130
|
+
second_metasploit_credential_core.save(validate: false)
|
131
|
+
}.to raise_error(ActiveRecord::RecordNotUnique)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
46
138
|
end
|
47
139
|
end
|
48
140
|
end
|
@@ -388,6 +480,104 @@ describe Metasploit::Credential::Core do
|
|
388
480
|
it { should validate_presence_of :origin }
|
389
481
|
it { should validate_presence_of :workspace }
|
390
482
|
|
483
|
+
context 'of uniqueness' do
|
484
|
+
#
|
485
|
+
# lets
|
486
|
+
#
|
487
|
+
|
488
|
+
let(:metasploit_credential_origin) {
|
489
|
+
FactoryGirl.create(:metasploit_credential_origin_manual)
|
490
|
+
}
|
491
|
+
|
492
|
+
let(:workspace) {
|
493
|
+
FactoryGirl.create(:mdm_workspace)
|
494
|
+
}
|
495
|
+
|
496
|
+
let(:second_metasploit_credential_core) {
|
497
|
+
FactoryGirl.build(
|
498
|
+
:metasploit_credential_core,
|
499
|
+
origin: metasploit_credential_origin,
|
500
|
+
private: private,
|
501
|
+
public: public,
|
502
|
+
workspace: workspace
|
503
|
+
)
|
504
|
+
}
|
505
|
+
|
506
|
+
let(:taken_error) {
|
507
|
+
I18n.translate!('activerecord.errors.messages.taken')
|
508
|
+
}
|
509
|
+
|
510
|
+
#
|
511
|
+
# let!s
|
512
|
+
#
|
513
|
+
|
514
|
+
let!(:first_metasploit_credential_core) {
|
515
|
+
FactoryGirl.create(
|
516
|
+
:metasploit_credential_core,
|
517
|
+
origin: metasploit_credential_origin,
|
518
|
+
private: private,
|
519
|
+
public: public,
|
520
|
+
workspace: workspace
|
521
|
+
)
|
522
|
+
}
|
523
|
+
|
524
|
+
#
|
525
|
+
# Callbacks
|
526
|
+
#
|
527
|
+
|
528
|
+
before(:each) do
|
529
|
+
second_metasploit_credential_core.valid?
|
530
|
+
end
|
531
|
+
|
532
|
+
context '#private_id' do
|
533
|
+
context 'with nil' do
|
534
|
+
let(:private) {
|
535
|
+
nil
|
536
|
+
}
|
537
|
+
|
538
|
+
context '#public_id' do
|
539
|
+
context 'without nil' do
|
540
|
+
let(:public) {
|
541
|
+
FactoryGirl.create(:metasploit_credential_public)
|
542
|
+
}
|
543
|
+
|
544
|
+
it 'does not allow duplicates on #public_id' do
|
545
|
+
expect(second_metasploit_credential_core.errors[:public_id]).to include(taken_error)
|
546
|
+
end
|
547
|
+
end
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
context 'without nil' do
|
552
|
+
let(:private) do
|
553
|
+
FactoryGirl.create(:metasploit_credential_password)
|
554
|
+
end
|
555
|
+
|
556
|
+
context '#public_id' do
|
557
|
+
context 'with nil' do
|
558
|
+
let(:public) {
|
559
|
+
nil
|
560
|
+
}
|
561
|
+
|
562
|
+
it 'does not allow duplicates on #private_id' do
|
563
|
+
expect(second_metasploit_credential_core.errors[:private_id]).to include(taken_error)
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
567
|
+
context 'without nil' do
|
568
|
+
let(:public) {
|
569
|
+
FactoryGirl.create(:metasploit_credential_public)
|
570
|
+
}
|
571
|
+
|
572
|
+
it 'does not allow duplicates on #private_id' do
|
573
|
+
expect(second_metasploit_credential_core.errors[:private_id]).to include(taken_error)
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
577
|
+
end
|
578
|
+
end
|
579
|
+
end
|
580
|
+
|
391
581
|
context '#consistent_workspaces' do
|
392
582
|
subject(:workspace_errors) do
|
393
583
|
core.errors[:workspace]
|
@@ -777,9 +967,9 @@ describe Metasploit::Credential::Core do
|
|
777
967
|
|
778
968
|
let(:core) do
|
779
969
|
FactoryGirl.build(
|
780
|
-
|
781
|
-
|
782
|
-
|
970
|
+
:metasploit_credential_core,
|
971
|
+
private: FactoryGirl.build(:metasploit_credential_ssh_key),
|
972
|
+
public: FactoryGirl.build(:metasploit_credential_public)
|
783
973
|
)
|
784
974
|
end
|
785
975
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metasploit-credential
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Luke Imhoff
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- db/migrate/20140702184622_create_credential_cores_tasks_join_table.rb
|
167
167
|
- db/migrate/20140703144541_create_credential_logins_tasks_join_table.rb
|
168
168
|
- db/migrate/20140722174919_old_creds_to_new_creds.rb
|
169
|
+
- db/migrate/20140728191933_unique_metasploit_credential_cores.rb
|
169
170
|
- lib/metasploit/credential.rb
|
170
171
|
- lib/metasploit/credential/creation.rb
|
171
172
|
- lib/metasploit/credential/engine.rb
|