jbox-gitolite 1.2.2 → 1.2.3
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/gitolite.gemspec +11 -14
- data/lib/gitolite/gitolite_admin.rb +14 -10
- data/lib/gitolite/version.rb +1 -1
- data/spec/config_spec.rb +85 -85
- data/spec/dirty_proxy_spec.rb +8 -8
- data/spec/gitolite_admin_spec.rb +3 -3
- data/spec/group_spec.rb +26 -24
- data/spec/repo_spec.rb +23 -23
- data/spec/ssh_key_spec.rb +54 -54
- metadata +101 -49
data/spec/dirty_proxy_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Gitolite::DirtyProxy do
|
4
4
|
|
5
5
|
it "should create a new instance given valid attributes" do
|
6
|
-
Gitolite::DirtyProxy.new([]).
|
6
|
+
expect(Gitolite::DirtyProxy.new([])).to_not be_nil
|
7
7
|
end
|
8
8
|
|
9
9
|
|
@@ -13,11 +13,11 @@ describe Gitolite::DirtyProxy do
|
|
13
13
|
|
14
14
|
describe 'delegating to the target object' do
|
15
15
|
it 'should act as instance of the target' do
|
16
|
-
proxy.
|
16
|
+
expect(proxy).to be_instance_of target.class
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should respond to all methods of the target' do
|
20
|
-
proxy.
|
20
|
+
expect(proxy).to respond_to(*target.methods)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should equal the target' do
|
@@ -28,27 +28,27 @@ describe Gitolite::DirtyProxy do
|
|
28
28
|
|
29
29
|
describe 'dirty checking methods' do
|
30
30
|
it 'should respond to clean_up!' do
|
31
|
-
proxy.respond_to?(:clean_up!).
|
31
|
+
expect(proxy.respond_to?(:clean_up!)).to be true
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should respond to dirty?' do
|
35
|
-
proxy.respond_to?(:dirty?).
|
35
|
+
expect(proxy.respond_to?(:dirty?)).to be true
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'when just initialized' do
|
39
39
|
it 'should be clean' do
|
40
|
-
proxy.dirty
|
40
|
+
expect(proxy.dirty?).to be false
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
shared_examples 'dirty? clean_up!' do
|
45
45
|
it 'should be dirty' do
|
46
|
-
proxy.dirty
|
46
|
+
expect(proxy.dirty?).to be true
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should be clean again after clean_up!' do
|
50
50
|
proxy.clean_up!
|
51
|
-
proxy.dirty
|
51
|
+
expect(proxy.dirty?).to be false
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
data/spec/gitolite_admin_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Gitolite::GitoliteAdmin do
|
|
8
8
|
|
9
9
|
describe '#bootstrap' do
|
10
10
|
it 'should bootstrap a gitolite-admin repository' do
|
11
|
-
test_dir = File.join(output_dir, 'gitolite-admin-
|
11
|
+
test_dir = File.join(output_dir, 'gitolite-admin-test1')
|
12
12
|
opts = { :overwrite => false }
|
13
13
|
gl_admin = GitoliteAdmin.bootstrap(test_dir, opts)
|
14
14
|
|
@@ -17,7 +17,7 @@ describe Gitolite::GitoliteAdmin do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should bootstrap (overwrite) a gitolite-admin repository' do
|
20
|
-
test_dir = File.join(output_dir, 'gitolite-admin-
|
20
|
+
test_dir = File.join(output_dir, 'gitolite-admin-test1')
|
21
21
|
opts = { :overwrite => true }
|
22
22
|
gl_admin = GitoliteAdmin.bootstrap(test_dir, opts)
|
23
23
|
|
@@ -35,7 +35,7 @@ describe Gitolite::GitoliteAdmin do
|
|
35
35
|
|
36
36
|
describe '#save' do
|
37
37
|
it 'should commit file to gitolite-admin repository' do
|
38
|
-
test_dir = File.join(output_dir, 'gitolite-admin-
|
38
|
+
test_dir = File.join(output_dir, 'gitolite-admin-test2')
|
39
39
|
opts = { :overwrite => true }
|
40
40
|
gl_admin = GitoliteAdmin.bootstrap(test_dir, opts)
|
41
41
|
|
data/spec/group_spec.rb
CHANGED
@@ -4,14 +4,14 @@ describe Gitolite::Config::Group do
|
|
4
4
|
describe "#new" do
|
5
5
|
it "should create a new group with an empty list of users" do
|
6
6
|
group = Gitolite::Config::Group.new("testgroup")
|
7
|
-
group.users.empty
|
8
|
-
group.name.
|
7
|
+
expect(group.users.empty?).to be true
|
8
|
+
expect(group.name).to eq "testgroup"
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should create a new group with a name containing #{Gitolite::Config::Group::PREPEND_CHAR}" do
|
12
12
|
name = "#{Gitolite::Config::Group::PREPEND_CHAR}testgroup"
|
13
13
|
group = Gitolite::Config::Group.new(name)
|
14
|
-
group.name.
|
14
|
+
expect(group.name).to eq "testgroup"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -23,52 +23,52 @@ describe Gitolite::Config::Group do
|
|
23
23
|
describe "#add_user" do
|
24
24
|
it "should allow adding one user with a string" do
|
25
25
|
@group.add_user("bob")
|
26
|
-
@group.size.
|
27
|
-
@group.users.first.
|
26
|
+
expect(@group.size).to eq 1
|
27
|
+
expect(@group.users.first).to eq "bob"
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should allow adding one user with a symbol" do
|
31
31
|
@group.add_user(:bob)
|
32
|
-
@group.size.
|
33
|
-
@group.users.first.
|
32
|
+
expect(@group.size).to eq 1
|
33
|
+
expect(@group.users.first).to eq "bob"
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should not add the same user twice" do
|
37
37
|
@group.add_user("bob")
|
38
|
-
@group.size.
|
38
|
+
expect(@group.size).to eq 1
|
39
39
|
@group.add_user(:bob)
|
40
|
-
@group.size.
|
41
|
-
@group.users.first.
|
40
|
+
expect(@group.size).to eq 1
|
41
|
+
expect(@group.users.first).to eq "bob"
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should maintain users in sorted order" do
|
45
45
|
@group.add_user("susan")
|
46
46
|
@group.add_user("peyton")
|
47
47
|
@group.add_user("bob")
|
48
|
-
@group.users.first.
|
49
|
-
@group.users.last.
|
48
|
+
expect(@group.users.first).to eq "bob"
|
49
|
+
expect(@group.users.last).to eq "susan"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "#add_users" do
|
54
54
|
it "should allow adding multiple users at once" do
|
55
55
|
@group.add_users("bob", "joe", "sue", "sam", "dan")
|
56
|
-
@group.size.
|
56
|
+
expect(@group.size).to eq 5
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should allow adding multiple users in nested arrays" do
|
60
60
|
@group.add_users(["bob", "joe", ["sam", "sue", "dan"]], "bill")
|
61
|
-
@group.size.
|
61
|
+
expect(@group.size).to eq 6
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should allow adding users of symbols and strings" do
|
65
65
|
@group.add_users("bob", :joe, :sue, "sam")
|
66
|
-
@group.size.
|
66
|
+
expect(@group.size).to eq 4
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should not add the same user twice" do
|
70
70
|
@group.add_users("bob", :bob, "bob", "sam")
|
71
|
-
@group.size.
|
71
|
+
expect(@group.size).to eq 2
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -79,40 +79,40 @@ describe Gitolite::Config::Group do
|
|
79
79
|
|
80
80
|
it "should support removing a user via a String" do
|
81
81
|
@group.rm_user("bob")
|
82
|
-
@group.size.
|
82
|
+
expect(@group.size).to eq 4
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should support removing a user via a Symbol" do
|
86
86
|
@group.rm_user(:bob)
|
87
|
-
@group.size.
|
87
|
+
expect(@group.size).to eq 4
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
describe "#empty!" do
|
92
92
|
it "should clear all users from the group" do
|
93
93
|
@group.add_users("bob", "joe", "sue", "jim")
|
94
|
-
@group.size.
|
94
|
+
expect(@group.size).to eq 4
|
95
95
|
@group.empty!
|
96
|
-
@group.size.
|
96
|
+
expect(@group.size).to eq 0
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
describe "#size" do
|
101
101
|
it "should reflect how many users are in the group" do
|
102
102
|
@group.add_users("bob", "joe", "sue", "jim")
|
103
|
-
@group.users.length.
|
103
|
+
expect(@group.users.length).to eq @group.size
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
describe "#has_user?" do
|
108
108
|
it "should search for a user via a String" do
|
109
109
|
@group.add_user("bob")
|
110
|
-
@group.has_user?("bob").
|
110
|
+
expect(@group.has_user?("bob")).to be true
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should search for a user via a Symbol" do
|
114
114
|
@group.add_user(:bob)
|
115
|
-
@group.has_user?(:bob).
|
115
|
+
expect(@group.has_user?(:bob)).to be true
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -120,6 +120,8 @@ describe Gitolite::Config::Group do
|
|
120
120
|
describe "#to_s" do
|
121
121
|
group = Gitolite::Config::Group.new("testgroup")
|
122
122
|
group.add_users("bob", "joe", "sam", "sue")
|
123
|
-
|
123
|
+
it {
|
124
|
+
expect(group.to_s).to eq "@testgroup = bob joe sam sue\n" #10 spaces after @testgroup
|
125
|
+
}
|
124
126
|
end
|
125
127
|
end
|
data/spec/repo_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Gitolite::Config::Repo do
|
|
7
7
|
|
8
8
|
describe '#new' do
|
9
9
|
it 'should create a repo called "CoolRepo"' do
|
10
|
-
@repo.name.
|
10
|
+
expect(@repo.name).to eq "CoolRepo"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -19,36 +19,36 @@ describe Gitolite::Config::Repo do
|
|
19
19
|
@repo.add_permission("RW", "refs/tags/test[0-9]", "@teachers", "bill", "todd")
|
20
20
|
@repo.add_permission("R", "refs/tags/test[0-9]", "@profs")
|
21
21
|
|
22
|
-
@repo.permissions.length.
|
23
|
-
@repo.permissions[0].size.
|
24
|
-
@repo.permissions[1].size.
|
22
|
+
expect(@repo.permissions.length).to eq 2
|
23
|
+
expect(@repo.permissions[0].size).to eq 2
|
24
|
+
expect(@repo.permissions[1].size).to eq 3
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#add_permission' do
|
29
29
|
it 'should allow adding a permission to the permissions list' do
|
30
30
|
@repo.add_permission("RW+")
|
31
|
-
@repo.permissions.length.
|
32
|
-
@repo.permissions.first.keys.first.
|
31
|
+
expect(@repo.permissions.length).to eq 1
|
32
|
+
expect(@repo.permissions.first.keys.first).to eq "RW+"
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should allow adding a permission while specifying a refex' do
|
36
36
|
@repo.add_permission("RW+", "refs/heads/master")
|
37
|
-
@repo.permissions.length.
|
38
|
-
@repo.permissions.first.keys.first.
|
39
|
-
@repo.permissions.first.values.last.first.first.
|
37
|
+
expect(@repo.permissions.length).to eq 1
|
38
|
+
expect(@repo.permissions.first.keys.first).to eq "RW+"
|
39
|
+
expect(@repo.permissions.first.values.last.first.first).to eq "refs/heads/master"
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should allow specifying users individually' do
|
43
43
|
@repo.add_permission("RW+", "", "bob", "joe", "susan", "sam", "bill")
|
44
|
-
@repo.permissions.first["RW+"][""].
|
44
|
+
expect(@repo.permissions.first["RW+"][""]).to eq %w[bob joe susan sam bill]
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'should allow specifying users as an array' do
|
48
48
|
users = %w[bob joe susan sam bill]
|
49
49
|
|
50
50
|
@repo.add_permission("RW+", "", users)
|
51
|
-
@repo.permissions.first["RW+"][""].
|
51
|
+
expect(@repo.permissions.first["RW+"][""]).to eq users
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should not allow adding an invalid permission via an InvalidPermissionError' do
|
@@ -145,13 +145,13 @@ describe Gitolite::Config::Repo do
|
|
145
145
|
describe 'git config options' do
|
146
146
|
it 'should allow setting a git configuration option' do
|
147
147
|
email = "bob@zilla.com"
|
148
|
-
@repo.set_git_config("email", email).
|
148
|
+
expect(@repo.set_git_config("email", email)).to eq email
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'should allow deletion of an existing git configuration option' do
|
152
152
|
email = "bob@zilla.com"
|
153
153
|
@repo.set_git_config("email", email)
|
154
|
-
@repo.unset_git_config("email").
|
154
|
+
expect(@repo.unset_git_config("email")).to eq email
|
155
155
|
end
|
156
156
|
|
157
157
|
end
|
@@ -160,9 +160,9 @@ describe Gitolite::Config::Repo do
|
|
160
160
|
it 'should allow setting a gitolite option' do
|
161
161
|
master = "kenobi"
|
162
162
|
slaves = "one"
|
163
|
-
@repo.set_gitolite_option("mirror.master", master).
|
164
|
-
@repo.set_gitolite_option("mirror.slaves", slaves).
|
165
|
-
@repo.options.length.
|
163
|
+
expect(@repo.set_gitolite_option("mirror.master", master)).to eq master
|
164
|
+
expect(@repo.set_gitolite_option("mirror.slaves", slaves)).to eq slaves
|
165
|
+
expect(@repo.options.length).to eq 2
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'should allow deletion of an existing gitolite option' do
|
@@ -170,9 +170,9 @@ describe Gitolite::Config::Repo do
|
|
170
170
|
slaves = "one"
|
171
171
|
@repo.set_gitolite_option("mirror.master", master)
|
172
172
|
@repo.set_gitolite_option("mirror.slaves", slaves)
|
173
|
-
@repo.options.length.
|
174
|
-
@repo.unset_gitolite_option("mirror.master").
|
175
|
-
@repo.options.length.
|
173
|
+
expect(@repo.options.length).to eq 2
|
174
|
+
expect(@repo.unset_gitolite_option("mirror.master")).to eq master
|
175
|
+
expect(@repo.options.length).to eq 1
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -183,8 +183,8 @@ describe Gitolite::Config::Repo do
|
|
183
183
|
|
184
184
|
@repo.add_permission("RW+", "", users)
|
185
185
|
@repo.add_permission("RW+", "", more_users)
|
186
|
-
@repo.permissions.first["RW+"][""].
|
187
|
-
@repo.permissions.first["RW+"][""].length.
|
186
|
+
expect(@repo.permissions.first["RW+"][""]).to eq users.concat(more_users)
|
187
|
+
expect(@repo.permissions.first["RW+"][""].length).to eq 9
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'should not list the same users twice for the same permission level' do
|
@@ -195,8 +195,8 @@ describe Gitolite::Config::Repo do
|
|
195
195
|
@repo.add_permission("RW+", "", users)
|
196
196
|
@repo.add_permission("RW+", "", more_users)
|
197
197
|
@repo.add_permission("RW+", "", even_more_users)
|
198
|
-
@repo.permissions.first["RW+"][""].
|
199
|
-
@repo.permissions.first["RW+"][""].length.
|
198
|
+
expect(@repo.permissions.first["RW+"][""]).to eq users.concat(more_users).concat(even_more_users).uniq!
|
199
|
+
expect(@repo.permissions.first["RW+"][""].length).to eq 11
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
data/spec/ssh_key_spec.rb
CHANGED
@@ -12,14 +12,14 @@ describe Gitolite::SSHKey do
|
|
12
12
|
key_string = File.read(key)
|
13
13
|
s = SSHKey.from_string(key_string, "bob")
|
14
14
|
|
15
|
-
s.owner.
|
16
|
-
s.location.
|
17
|
-
s.blob.
|
15
|
+
expect(s.owner).to eq 'bob'
|
16
|
+
expect(s.location).to eq ""
|
17
|
+
expect(s.blob).to eq key_string.split[1]
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should raise an ArgumentError when an owner isnt specified' do
|
21
21
|
key_string = "not_a_real_key"
|
22
|
-
lambda { SSHKey.from_string(key_string) }.
|
22
|
+
expect(lambda { SSHKey.from_string(key_string) }).to raise_error
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should have a location when one is specified' do
|
@@ -27,17 +27,17 @@ describe Gitolite::SSHKey do
|
|
27
27
|
key_string = File.read(key)
|
28
28
|
s = SSHKey.from_string(key_string, "bob", "kansas")
|
29
29
|
|
30
|
-
s.owner.
|
31
|
-
s.location.
|
32
|
-
s.blob.
|
30
|
+
expect(s.owner).to eq 'bob'
|
31
|
+
expect(s.location).to eq "kansas"
|
32
|
+
expect(s.blob).to eq key_string.split[1]
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should raise an ArgumentError when owner is nil' do
|
36
|
-
lambda { SSHKey.from_string("bad_string", nil) }.
|
36
|
+
expect(lambda { SSHKey.from_string("bad_string", nil) }).to raise_error
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should raise an ArgumentError when we get an invalid SSHKey string' do
|
40
|
-
lambda { SSHKey.from_string("bad_string", "bob") }.
|
40
|
+
expect(lambda { SSHKey.from_string("bad_string", "bob") }).to raise_error
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -47,22 +47,22 @@ describe Gitolite::SSHKey do
|
|
47
47
|
s = SSHKey.from_file(key)
|
48
48
|
key_string = File.read(key).split
|
49
49
|
|
50
|
-
s.owner.
|
51
|
-
s.blob.
|
50
|
+
expect(s.owner).to eq "bob"
|
51
|
+
expect(s.blob).to eq key_string[1]
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should load a key with a location from a file' do
|
55
55
|
key = File.join(key_dir, 'bob@desktop.pub')
|
56
56
|
s = SSHKey.from_file(key)
|
57
|
-
s.owner.
|
58
|
-
s.location.
|
57
|
+
expect(s.owner).to eq 'bob'
|
58
|
+
expect(s.location).to eq 'desktop'
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should load a key with owner and location from a file' do
|
62
62
|
key = File.join(key_dir, 'joe-bob@god-zilla.com@desktop.pub')
|
63
63
|
s = SSHKey.from_file(key)
|
64
|
-
s.owner.
|
65
|
-
s.location.
|
64
|
+
expect(s.owner).to eq 'joe-bob@god-zilla.com'
|
65
|
+
expect(s.location).to eq 'desktop'
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -70,67 +70,67 @@ describe Gitolite::SSHKey do
|
|
70
70
|
it 'owner should be bob for bob.pub' do
|
71
71
|
key = File.join(key_dir, 'bob.pub')
|
72
72
|
s = SSHKey.from_file(key)
|
73
|
-
s.owner.
|
73
|
+
expect(s.owner).to eq 'bob'
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'owner should be bob for bob@desktop.pub' do
|
77
77
|
key = File.join(key_dir, 'bob@desktop.pub')
|
78
78
|
s = SSHKey.from_file(key)
|
79
|
-
s.owner.
|
79
|
+
expect(s.owner).to eq 'bob'
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'owner should be bob@zilla.com for bob@zilla.com.pub' do
|
83
83
|
key = File.join(key_dir, 'bob@zilla.com.pub')
|
84
84
|
s = SSHKey.from_file(key)
|
85
|
-
s.owner.
|
85
|
+
expect(s.owner).to eq 'bob@zilla.com'
|
86
86
|
end
|
87
87
|
|
88
88
|
it "owner should be joe-bob@god-zilla.com for joe-bob@god-zilla.com@desktop.pub" do
|
89
89
|
key = File.join(key_dir, 'joe-bob@god-zilla.com@desktop.pub')
|
90
90
|
s = SSHKey.from_file(key)
|
91
|
-
s.owner.
|
91
|
+
expect(s.owner).to eq 'joe-bob@god-zilla.com'
|
92
92
|
end
|
93
93
|
|
94
94
|
it "owner should be bob.joe@test.zilla.com for bob.joe@test.zilla.com@desktop.pub" do
|
95
95
|
key = File.join(key_dir, 'bob.joe@test.zilla.com@desktop.pub')
|
96
96
|
s = SSHKey.from_file(key)
|
97
|
-
s.owner.
|
97
|
+
expect(s.owner).to eq 'bob.joe@test.zilla.com'
|
98
98
|
end
|
99
99
|
|
100
100
|
it "owner should be bob+joe@test.zilla.com for bob+joe@test.zilla.com@desktop.pub" do
|
101
101
|
key = File.join(key_dir, 'bob+joe@test.zilla.com@desktop.pub')
|
102
102
|
s = SSHKey.from_file(key)
|
103
|
-
s.owner.
|
103
|
+
expect(s.owner).to eq 'bob+joe@test.zilla.com'
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'owner should be bob@zilla.com for bob@zilla.com@desktop.pub' do
|
107
107
|
key = File.join(key_dir, 'bob@zilla.com@desktop.pub')
|
108
108
|
s = SSHKey.from_file(key)
|
109
|
-
s.owner.
|
109
|
+
expect(s.owner).to eq 'bob@zilla.com'
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'owner should be jakub123 for jakub123.pub' do
|
113
113
|
key = File.join(key_dir, 'jakub123.pub')
|
114
114
|
s = SSHKey.from_file(key)
|
115
|
-
s.owner.
|
115
|
+
expect(s.owner).to eq 'jakub123'
|
116
116
|
end
|
117
117
|
|
118
118
|
it 'owner should be jakub123@foo.net for jakub123@foo.net.pub' do
|
119
119
|
key = File.join(key_dir, 'jakub123@foo.net.pub')
|
120
120
|
s = SSHKey.from_file(key)
|
121
|
-
s.owner.
|
121
|
+
expect(s.owner).to eq 'jakub123@foo.net'
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'owner should be joe@sch.ool.edu for joe@sch.ool.edu' do
|
125
125
|
key = File.join(key_dir, 'joe@sch.ool.edu.pub')
|
126
126
|
s = SSHKey.from_file(key)
|
127
|
-
s.owner.
|
127
|
+
expect(s.owner).to eq 'joe@sch.ool.edu'
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'owner should be joe@sch.ool.edu for joe@sch.ool.edu@desktop.pub' do
|
131
131
|
key = File.join(key_dir, 'joe@sch.ool.edu@desktop.pub')
|
132
132
|
s = SSHKey.from_file(key)
|
133
|
-
s.owner.
|
133
|
+
expect(s.owner).to eq 'joe@sch.ool.edu'
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -138,55 +138,55 @@ describe Gitolite::SSHKey do
|
|
138
138
|
it 'location should be "" for bob.pub' do
|
139
139
|
key = File.join(key_dir, 'bob.pub')
|
140
140
|
s = SSHKey.from_file(key)
|
141
|
-
s.location.
|
141
|
+
expect(s.location).to eq ''
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'location should be "desktop" for bob@desktop.pub' do
|
145
145
|
key = File.join(key_dir, 'bob@desktop.pub')
|
146
146
|
s = SSHKey.from_file(key)
|
147
|
-
s.location.
|
147
|
+
expect(s.location).to eq 'desktop'
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'location should be "" for bob@zilla.com.pub' do
|
151
151
|
key = File.join(key_dir, 'bob@zilla.com.pub')
|
152
152
|
s = SSHKey.from_file(key)
|
153
|
-
s.location.
|
153
|
+
expect(s.location).to eq ''
|
154
154
|
end
|
155
155
|
|
156
156
|
it 'location should be "desktop" for bob@zilla.com@desktop.pub' do
|
157
157
|
key = File.join(key_dir, 'bob@zilla.com@desktop.pub')
|
158
158
|
s = SSHKey.from_file(key)
|
159
|
-
s.location.
|
159
|
+
expect(s.location).to eq 'desktop'
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'location should be "" for jakub123.pub' do
|
163
163
|
key = File.join(key_dir, 'jakub123.pub')
|
164
164
|
s = SSHKey.from_file(key)
|
165
|
-
s.location.
|
165
|
+
expect(s.location).to eq ''
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'location should be "" for jakub123@foo.net.pub' do
|
169
169
|
key = File.join(key_dir, 'jakub123@foo.net.pub')
|
170
170
|
s = SSHKey.from_file(key)
|
171
|
-
s.location.
|
171
|
+
expect(s.location).to eq ''
|
172
172
|
end
|
173
173
|
|
174
174
|
it 'location should be "" for joe@sch.ool.edu' do
|
175
175
|
key = File.join(key_dir, 'joe@sch.ool.edu.pub')
|
176
176
|
s = SSHKey.from_file(key)
|
177
|
-
s.location.
|
177
|
+
expect(s.location).to eq ''
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'location should be "desktop" for joe@sch.ool.edu@desktop.pub' do
|
181
181
|
key = File.join(key_dir, 'joe@sch.ool.edu@desktop.pub')
|
182
182
|
s = SSHKey.from_file(key)
|
183
|
-
s.location.
|
183
|
+
expect(s.location).to eq 'desktop'
|
184
184
|
end
|
185
185
|
|
186
186
|
it 'location should be "foo-bar" for bob@foo-bar.pub' do
|
187
187
|
key = File.join(key_dir, 'bob@foo-bar.pub')
|
188
188
|
s = SSHKey.from_file(key)
|
189
|
-
s.location.
|
189
|
+
expect(s.location).to eq 'foo-bar'
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
@@ -196,9 +196,9 @@ describe Gitolite::SSHKey do
|
|
196
196
|
s = SSHKey.from_file(key)
|
197
197
|
parts = File.read(key).split #should get type, blob, email
|
198
198
|
|
199
|
-
s.type.
|
200
|
-
s.blob.
|
201
|
-
s.email.
|
199
|
+
expect(s.type).to eq parts[0]
|
200
|
+
expect(s.blob).to eq parts[1]
|
201
|
+
expect(s.email).to eq parts[2]
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -206,7 +206,7 @@ describe Gitolite::SSHKey do
|
|
206
206
|
it 'should use owner if email is missing' do
|
207
207
|
key = File.join(key_dir, 'jakub123@foo.net.pub')
|
208
208
|
s = SSHKey.from_file(key)
|
209
|
-
s.owner.
|
209
|
+
expect(s.owner).to eq s.email
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
@@ -218,8 +218,8 @@ describe Gitolite::SSHKey do
|
|
218
218
|
|
219
219
|
s = SSHKey.new(type, blob, email)
|
220
220
|
|
221
|
-
s.to_s.
|
222
|
-
s.owner.
|
221
|
+
expect(s.to_s).to eq [type, blob, email].join(' ')
|
222
|
+
expect(s.owner).to eq email
|
223
223
|
end
|
224
224
|
|
225
225
|
it 'should create a valid ssh key while specifying an owner' do
|
@@ -230,8 +230,8 @@ describe Gitolite::SSHKey do
|
|
230
230
|
|
231
231
|
s = SSHKey.new(type, blob, email, owner)
|
232
232
|
|
233
|
-
s.to_s.
|
234
|
-
s.owner.
|
233
|
+
expect(s.to_s).to eq [type, blob, email].join(' ')
|
234
|
+
expect(s.owner).to eq owner
|
235
235
|
end
|
236
236
|
|
237
237
|
it 'should create a valid ssh key while specifying an owner and location' do
|
@@ -243,9 +243,9 @@ describe Gitolite::SSHKey do
|
|
243
243
|
|
244
244
|
s = SSHKey.new(type, blob, email, owner, location)
|
245
245
|
|
246
|
-
s.to_s.
|
247
|
-
s.owner.
|
248
|
-
s.location.
|
246
|
+
expect(s.to_s).to eq [type, blob, email].join(' ')
|
247
|
+
expect(s.owner).to eq owner
|
248
|
+
expect(s.location).to eq location
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
@@ -260,7 +260,7 @@ describe Gitolite::SSHKey do
|
|
260
260
|
hash_test = [owner, location, type, blob, email].hash
|
261
261
|
s = SSHKey.new(type, blob, email, owner, location)
|
262
262
|
|
263
|
-
s.hash.
|
263
|
+
expect(s.hash).to eq hash_test
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
@@ -272,7 +272,7 @@ describe Gitolite::SSHKey do
|
|
272
272
|
|
273
273
|
s = SSHKey.new(type, blob, email)
|
274
274
|
|
275
|
-
s.filename.
|
275
|
+
expect(s.filename).to eq "#{email}.pub"
|
276
276
|
end
|
277
277
|
|
278
278
|
it 'should create a filename that is the <owner>.pub' do
|
@@ -283,7 +283,7 @@ describe Gitolite::SSHKey do
|
|
283
283
|
|
284
284
|
s = SSHKey.new(type, blob, email, owner)
|
285
285
|
|
286
|
-
s.filename.
|
286
|
+
expect(s.filename).to eq "#{owner}.pub"
|
287
287
|
end
|
288
288
|
|
289
289
|
it 'should create a filename that is the <email>@<location>.pub' do
|
@@ -294,7 +294,7 @@ describe Gitolite::SSHKey do
|
|
294
294
|
|
295
295
|
s = SSHKey.new(type, blob, email, nil, location)
|
296
296
|
|
297
|
-
s.filename.
|
297
|
+
expect(s.filename).to eq "#{email}@#{location}.pub"
|
298
298
|
end
|
299
299
|
|
300
300
|
it 'should create a filename that is the <owner>@<location>.pub' do
|
@@ -306,7 +306,7 @@ describe Gitolite::SSHKey do
|
|
306
306
|
|
307
307
|
s = SSHKey.new(type, blob, email, owner, location)
|
308
308
|
|
309
|
-
s.filename.
|
309
|
+
expect(s.filename).to eq "#{owner}@#{location}.pub"
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
@@ -324,7 +324,7 @@ describe Gitolite::SSHKey do
|
|
324
324
|
s.to_file(output_dir)
|
325
325
|
|
326
326
|
## compare raw string with written file
|
327
|
-
s.to_s.
|
327
|
+
expect(s.to_s).to eq File.read(File.join(output_dir, s.filename))
|
328
328
|
end
|
329
329
|
|
330
330
|
it 'should return the filename written' do
|
@@ -336,7 +336,7 @@ describe Gitolite::SSHKey do
|
|
336
336
|
|
337
337
|
s = SSHKey.new(type, blob, email, owner, location)
|
338
338
|
|
339
|
-
s.to_file(output_dir).
|
339
|
+
expect(s.to_file(output_dir)).to eq File.join(output_dir, s.filename)
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
@@ -349,7 +349,7 @@ describe Gitolite::SSHKey do
|
|
349
349
|
s1 = SSHKey.new(type, blob, email)
|
350
350
|
s2 = SSHKey.new(type, blob, email)
|
351
351
|
|
352
|
-
s1.
|
352
|
+
expect(s1).to eq s2
|
353
353
|
end
|
354
354
|
end
|
355
355
|
end
|