gitolite 0.0.1.alpha → 0.0.2.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitolite (0.1.0)
4
+ gitolite (0.0.1.alpha)
5
5
  grit (~> 2.4.1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.1.2)
11
+ forgery (0.3.6)
11
12
  grit (2.4.1)
12
13
  diff-lcs (~> 1.1)
13
14
  mime-types (~> 1.15)
@@ -26,5 +27,6 @@ PLATFORMS
26
27
  x86-mingw32
27
28
 
28
29
  DEPENDENCIES
30
+ forgery (~> 0.3.6)
29
31
  gitolite!
30
32
  rspec (~> 2.4.0)
data/README.rdoc CHANGED
@@ -1,7 +1,13 @@
1
- = gitolite - Coming soon
1
+ = gitolite - In alpha
2
2
 
3
3
  This gem is designed to provide a Ruby interface to the {gitolite}[https://github.com/sitaramc/gitolite] git backend system. I am aiming to provide all management functionality that is available via the gitolite-admin repository (like SSH keys, repository permissions, etc)
4
4
 
5
+ This gem is still under very active development. There are a number of issues with it still. It is not ready for production use.
6
+
7
+ == Features
8
+ * Allows for the creation and management of repos within gitolite
9
+ * Allows for the creation and deletion of SSH keys within gitolite
10
+
5
11
  == Requirements
6
12
  * Ruby 1.9.2 or higher
7
13
  * a working {gitolite}[https://github.com/sitaramc/gitolite] installation
@@ -9,14 +15,66 @@ This gem is designed to provide a Ruby interface to the {gitolite}[https://githu
9
15
 
10
16
  == Installation
11
17
 
12
- gem install gitolite
18
+ gem install gitolite --pre
13
19
 
14
20
  == Usage
15
21
 
22
+ === Load a gitolite-admin repo
23
+
24
+ require 'gitolite'
25
+ ga_repo = Gitolite::GitoliteAdmin.new("/path/to/gitolite/admin/repo")
26
+
27
+ For now, this method can only be called on an existing gitolite-admin repo. Support for bootstrapping a gitolite-repo will be added in the future (but will never be recommended).
28
+
29
+ === Repo management
30
+
31
+ repo = Config::Repo.new("AwesomeRepo")
32
+
33
+ #For a list of permissions, see https://github.com/sitaramc/gitolite/blob/pu/doc/gitolite.conf.mkd
34
+ repo.add_permission("RW+", "", "bob", "joe", "susan")
35
+
36
+ #Add repo
37
+ ga_repo.add_repo(repo)
38
+
39
+ #Delete repo
40
+ ga_repo.rm_repo(repo)
41
+
42
+ === SSH Key Management
43
+
44
+ #Two ways to create keys: manually or from an existing key
45
+ key = Gitolite::SSHKey.new("ssh-rsa", "big-public-key-blob", "email")
46
+ key2 = Gitolite::SSHKey.from_file("/path/to/ssh/key.pub")
47
+
48
+ #Add the keys
49
+ ga_repo.add_key(key)
50
+ ga_repo.add_key(key2)
51
+
52
+ #Remove key2
53
+ ga_repo.rm_key(key2)
54
+
55
+ === Save changes
56
+
57
+ ga_repo.save
58
+
59
+ When this method is called, all changes get written to the file system and staged in git. For the time being, gitolite assumes full control of the gitolite-admin repository. This means that any keys in the keydir that are not being tracked will be removed and any human changes to gitolite.conf will be erased.
60
+
61
+ === Apply changes
62
+ ga_repo.apply
63
+
64
+ This method will commit all changes with a generic message (will be improved upon later) and push to <tt>origin master</tt>.
65
+
66
+ === Save and apply
67
+ ga_repo.save_and_apply
68
+
16
69
  == Caveats
17
70
  === 1.8.x compatibility
18
- This gem should work properly on Ruby 1.8.x with the exception of deny rules. In order to fully support Ruby < 1.9.x, an ordered Hash is required, such as the one implemented by ActiveSupport. Support will be added if there appears to be a demand for it.
71
+ This gem should work properly on Ruby 1.8.x with the exception of deny rules. In order to fully support Ruby < 1.9.x, an ordered Hash is required. The one implemented by ActiveSupport could probably be used. Support will be added if there appears to be a demand for it.
19
72
 
20
73
  == Documentation
74
+ * Rdoc is coming soon
21
75
 
22
76
  == Future
77
+ * support folders in the keydir
78
+ * support includes tags
79
+ * support bootstrapping a gitolite-admin repo
80
+ * cleanup methods to make adding and removing easier (like add_key should accept an array of keys)
data/gitolite.gemspec CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "gitolite"
16
16
 
17
17
  s.add_development_dependency "rspec", "~> 2.4.0"
18
+ s.add_development_dependency "forgery", "~> 0.3.6"
18
19
  s.add_dependency "grit", "~> 2.4.1"
19
20
 
20
21
  s.files = `git ls-files`.split("\n")
@@ -1,10 +1,11 @@
1
1
  module Gitolite
2
2
  class Config
3
- attr_accessor :repos, :groups
3
+ attr_accessor :repos, :groups, :filename
4
4
 
5
5
  def initialize(config)
6
6
  @repos = {}
7
7
  @groups = Hash.new { |k,v| k[v] = [] }
8
+ @filename = File.basename(config)
8
9
  process_config(config)
9
10
  end
10
11
 
@@ -21,7 +22,7 @@ module Gitolite
21
22
  @config = {}
22
23
  end
23
24
 
24
- def add_permission(perm, refex, users)
25
+ def add_permission(perm, refex, *users)
25
26
  if ALLOWED_PERMISSIONS.include? perm
26
27
  @permissions[perm][refex].concat users
27
28
  else
@@ -38,7 +39,15 @@ module Gitolite
38
39
  end
39
40
 
40
41
  def to_s
41
- @name
42
+ repo = "repo #{@name}\n"
43
+
44
+ @permissions.each do |perm, list|
45
+ list.each do |refex, users|
46
+ repo += " " + perm.ljust(6) + refex.ljust(20) + "= " + users.join(' ') + "\n"
47
+ end
48
+ end
49
+
50
+ repo
42
51
  end
43
52
 
44
53
  #Gets raised if a permission that isn't in the allowed
@@ -47,6 +56,33 @@ module Gitolite
47
56
  end
48
57
  end
49
58
 
59
+ #TODO: merge repo unless overwrite = true
60
+ def add_repo(repo, overwrite = false)
61
+ raise "Repo must be of type Gitolite::Config::Repo!" unless repo.instance_of? Gitolite::Config::Repo
62
+ @repos[repo.name] = repo
63
+ end
64
+
65
+ def rm_repo(repo)
66
+ raise "Repo must be of type Gitolite::Config::Repo!" unless repo.instance_of? Gitolite::Config::Repo
67
+ @repos.delete repo.name
68
+ end
69
+
70
+ def to_file(path)
71
+ new_conf = File.join(path, @filename)
72
+ File.open(new_conf, "w") do |f|
73
+ @groups.each do |k,v|
74
+ members = v.join(' ')
75
+ f.write "#{k.ljust(20)}= #{members}\n"
76
+ end
77
+
78
+ @repos.each do |k, v|
79
+ f.write v.to_s
80
+ end
81
+ end
82
+
83
+ new_conf
84
+ end
85
+
50
86
  private
51
87
  #Based on
52
88
  #https://github.com/sitaramc/gitolite/blob/pu/src/gl-compile-conf#cleanup_conf_line
@@ -116,8 +152,6 @@ module Gitolite
116
152
  puts "'#{line}'"
117
153
  end
118
154
  end
119
-
120
-
121
155
  end
122
156
  end
123
- end
157
+ end
@@ -2,39 +2,42 @@ module Gitolite
2
2
  class GitoliteAdmin
3
3
  attr_accessor :gl_admin, :ssh_keys, :config
4
4
 
5
- CONF = "/conf/gitolite.conf"
6
- KEYDIR = "/keydir"
5
+ CONF = "gitolite.conf"
6
+ CONFDIR = "conf"
7
+ KEYDIR = "keydir"
7
8
 
8
9
  #Intialize with the path to
9
10
  #the gitolite-admin repository
10
11
  def initialize(path, options = {})
11
12
  @gl_admin = Grit::Repo.new(path)
12
13
 
13
- @path = path
14
14
  @conf = options[:conf] || CONF
15
+ @confdir = options[:confdir] || CONFDIR
15
16
  @keydir = options[:keydir] || KEYDIR
16
17
 
17
- @ssh_keys = load_keys(File.join(@path, @keydir))
18
- @config = Config.new(File.join(@path, @conf))
18
+ @ssh_keys = load_keys(File.join(path, @keydir))
19
+ @config = Config.new(File.join(path, @confdir, @conf))
19
20
  end
20
21
 
21
22
  #Writes all aspects out to the file system
22
23
  #will also stage all changes
23
24
  def save
25
+ Dir.chdir(@gl_admin.working_dir)
26
+
24
27
  #Process config file
28
+ new_conf = @config.to_file(@confdir)
29
+ @gl_admin.add(new_conf)
25
30
 
26
31
  #Process ssh keys
27
- files = list_keys(File.join(@path, @keydir)).map{|f| File.basename f}
32
+ files = list_keys(@keydir).map{|f| File.basename f}
28
33
  keys = @ssh_keys.values.map{|f| f.map {|t| t.filename}}.flatten
29
-
30
- #Remove all keys we don't have a record for
34
+
31
35
  to_remove = (files - keys).map { |f| File.join(@keydir, f)}
32
- @gl_admin.remove(to_remove) unless to_remove.empty?
33
-
34
- #Write all keys to files, overwriting existing keys
35
- keys.each do |key|
36
- File.open(key, "w") do |f|
37
- f.write key.to_s
36
+ @gl_admin.remove(to_remove)
37
+
38
+ @ssh_keys.each_value do |key|
39
+ key.each do |k|
40
+ @gl_admin.add(k.to_file(@keydir))
38
41
  end
39
42
  end
40
43
  end
@@ -42,18 +45,22 @@ module Gitolite
42
45
  #commits all staged changes and pushes back
43
46
  #to origin
44
47
  def apply
45
- status = @gl_admin.status
48
+ #TODO: generate a better commit message
49
+ @gl_admin.commit_index("Commit by gitolite gem")
50
+ @gl_admin.git.push({}, "origin", "master")
46
51
  end
47
52
 
48
53
  #Calls save and apply in order
49
54
  def save_and_apply
55
+ self.save
56
+ self.apply
50
57
  end
51
-
58
+
52
59
  def add_key(key)
53
60
  raise "Key must be of type Gitolite::SSHKey!" unless key.instance_of? Gitolite::SSHKey
54
61
  @ssh_keys[key.owner] << key
55
62
  end
56
-
63
+
57
64
  def rm_key(key)
58
65
  @ssh_keys[key.owner].delete key
59
66
  end
@@ -73,10 +80,13 @@ module Gitolite
73
80
 
74
81
  keys
75
82
  end
76
-
83
+
77
84
  def list_keys(path)
85
+ old_path = Dir.pwd
78
86
  Dir.chdir(path)
79
- Dir.glob("**/*.pub")
87
+ keys = Dir.glob("**/*.pub")
88
+ Dir.chdir(old_path)
89
+ keys
80
90
  end
81
91
  end
82
92
  end
@@ -15,7 +15,7 @@ module Gitolite
15
15
  @type = type
16
16
  @blob = blob
17
17
  @email = email
18
-
18
+
19
19
  @owner = owner || email
20
20
  @location = location
21
21
  end
@@ -36,26 +36,28 @@ module Gitolite
36
36
  if email.nil?
37
37
  email = owner
38
38
  end
39
-
39
+
40
40
  self.new(type, blob, email, owner, location)
41
41
  end
42
42
 
43
43
  def to_s
44
44
  [@type, @blob, @email].join(' ')
45
45
  end
46
-
47
- def to_file(filename)
48
- File.open(filename, "w") do |f|
46
+
47
+ def to_file(path)
48
+ key_file = File.join(path, self.filename)
49
+ File.open(key_file, "w") do |f|
49
50
  f.write (self.to_s)
50
51
  end
52
+ key_file
51
53
  end
52
-
54
+
53
55
  def filename
54
56
  file = @owner
55
57
  file += "@#{@location}" unless @location.empty?
56
58
  file += ".pub"
57
59
  end
58
-
60
+
59
61
  def ==(key)
60
62
  @type == key.type &&
61
63
  @blob == key.blob &&
@@ -65,4 +67,3 @@ module Gitolite
65
67
  end
66
68
  end
67
69
  end
68
-
@@ -1,3 +1,3 @@
1
1
  module Gitolite
2
- VERSION = "0.0.1.alpha"
2
+ VERSION = "0.0.2.alpha"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -0,0 +1,2 @@
1
+ require 'Forgery'
2
+ require 'tmpdir'
data/spec/ssh_key_spec.rb CHANGED
@@ -1,111 +1,114 @@
1
+ require 'spec_helper'
1
2
  require 'gitolite/ssh_key'
2
3
  include Gitolite
3
4
 
4
5
  describe Gitolite::SSHKey do
6
+ key_dir = File.join(File.dirname(__FILE__),'keys')
7
+
5
8
  describe '#owner' do
6
9
  it 'owner should be bob for bob.pub' do
7
- key = File.join(File.dirname(__FILE__),'keys', 'bob.pub')
8
- s = SSHKey.new(key)
10
+ key = File.join(key_dir, 'bob.pub')
11
+ s = SSHKey.from_file(key)
9
12
  s.owner.should == 'bob'
10
13
  end
11
14
 
12
15
  it 'owner should be bob for bob@desktop.pub' do
13
- key = File.join(File.dirname(__FILE__),'keys', 'bob@desktop.pub')
14
- s = SSHKey.new(key)
16
+ key = File.join(key_dir, 'bob@desktop.pub')
17
+ s = SSHKey.from_file(key)
15
18
  s.owner.should == 'bob'
16
19
  end
17
20
 
18
21
  it 'owner should be bob@zilla.com for bob@zilla.com.pub' do
19
- key = File.join(File.dirname(__FILE__),'keys', 'bob@zilla.com.pub')
20
- s = SSHKey.new(key)
22
+ key = File.join(key_dir, 'bob@zilla.com.pub')
23
+ s = SSHKey.from_file(key)
21
24
  s.owner.should == 'bob@zilla.com'
22
25
  end
23
26
 
24
27
  it 'owner should be bob@zilla.com for bob@zilla.com@desktop.pub' do
25
- key = File.join(File.dirname(__FILE__),'keys', 'bob@zilla.com@desktop.pub')
26
- s = SSHKey.new(key)
28
+ key = File.join(key_dir, 'bob@zilla.com@desktop.pub')
29
+ s = SSHKey.from_file(key)
27
30
  s.owner.should == 'bob@zilla.com'
28
31
  end
29
32
 
30
33
  it 'owner should be jakub123 for jakub123.pub' do
31
- key = File.join(File.dirname(__FILE__),'keys', 'jakub123.pub')
32
- s = SSHKey.new(key)
34
+ key = File.join(key_dir, 'jakub123.pub')
35
+ s = SSHKey.from_file(key)
33
36
  s.owner.should == 'jakub123'
34
37
  end
35
38
 
36
39
  it 'owner should be jakub123@foo.net for jakub123@foo.net.pub' do
37
- key = File.join(File.dirname(__FILE__),'keys', 'jakub123@foo.net.pub')
38
- s = SSHKey.new(key)
40
+ key = File.join(key_dir, 'jakub123@foo.net.pub')
41
+ s = SSHKey.from_file(key)
39
42
  s.owner.should == 'jakub123@foo.net'
40
43
  end
41
44
 
42
45
  it 'owner should be joe@sch.ool.edu for joe@sch.ool.edu' do
43
- key = File.join(File.dirname(__FILE__),'keys', 'joe@sch.ool.edu.pub')
44
- s = SSHKey.new(key)
46
+ key = File.join(key_dir, 'joe@sch.ool.edu.pub')
47
+ s = SSHKey.from_file(key)
45
48
  s.owner.should == 'joe@sch.ool.edu'
46
49
  end
47
50
 
48
51
  it 'owner should be joe@sch.ool.edu for joe@sch.ool.edu@desktop.pub' do
49
- key = File.join(File.dirname(__FILE__),'keys', 'joe@sch.ool.edu@desktop.pub')
50
- s = SSHKey.new(key)
52
+ key = File.join(key_dir, 'joe@sch.ool.edu@desktop.pub')
53
+ s = SSHKey.from_file(key)
51
54
  s.owner.should == 'joe@sch.ool.edu'
52
55
  end
53
56
  end
54
57
 
55
58
  describe '#location' do
56
59
  it 'location should be "" for bob.pub' do
57
- key = File.join(File.dirname(__FILE__),'keys', 'bob.pub')
58
- s = SSHKey.new(key)
60
+ key = File.join(key_dir, 'bob.pub')
61
+ s = SSHKey.from_file(key)
59
62
  s.location.should == ''
60
63
  end
61
64
 
62
65
  it 'location should be "desktop" for bob@desktop.pub' do
63
- key = File.join(File.dirname(__FILE__),'keys', 'bob@desktop.pub')
64
- s = SSHKey.new(key)
66
+ key = File.join(key_dir, 'bob@desktop.pub')
67
+ s = SSHKey.from_file(key)
65
68
  s.location.should == 'desktop'
66
69
  end
67
70
 
68
71
  it 'location should be "" for bob@zilla.com.pub' do
69
- key = File.join(File.dirname(__FILE__),'keys', 'bob@zilla.com.pub')
70
- s = SSHKey.new(key)
72
+ key = File.join(key_dir, 'bob@zilla.com.pub')
73
+ s = SSHKey.from_file(key)
71
74
  s.location.should == ''
72
75
  end
73
76
 
74
77
  it 'location should be "desktop" for bob@zilla.com@desktop.pub' do
75
- key = File.join(File.dirname(__FILE__),'keys', 'bob@zilla.com@desktop.pub')
76
- s = SSHKey.new(key)
78
+ key = File.join(key_dir, 'bob@zilla.com@desktop.pub')
79
+ s = SSHKey.from_file(key)
77
80
  s.location.should == 'desktop'
78
81
  end
79
82
 
80
83
  it 'location should be "" for jakub123.pub' do
81
- key = File.join(File.dirname(__FILE__),'keys', 'jakub123.pub')
82
- s = SSHKey.new(key)
84
+ key = File.join(key_dir, 'jakub123.pub')
85
+ s = SSHKey.from_file(key)
83
86
  s.location.should == ''
84
87
  end
85
88
 
86
89
  it 'location should be "" for jakub123@foo.net.pub' do
87
- key = File.join(File.dirname(__FILE__),'keys', 'jakub123@foo.net.pub')
88
- s = SSHKey.new(key)
90
+ key = File.join(key_dir, 'jakub123@foo.net.pub')
91
+ s = SSHKey.from_file(key)
89
92
  s.location.should == ''
90
93
  end
91
94
 
92
95
  it 'location should be "" for joe@sch.ool.edu' do
93
- key = File.join(File.dirname(__FILE__),'keys', 'joe@sch.ool.edu.pub')
94
- s = SSHKey.new(key)
96
+ key = File.join(key_dir, 'joe@sch.ool.edu.pub')
97
+ s = SSHKey.from_file(key)
95
98
  s.location.should == ''
96
99
  end
97
100
 
98
101
  it 'location should be "desktop" for joe@sch.ool.edu@desktop.pub' do
99
- key = File.join(File.dirname(__FILE__),'keys', 'joe@sch.ool.edu@desktop.pub')
100
- s = SSHKey.new(key)
102
+ key = File.join(key_dir, 'joe@sch.ool.edu@desktop.pub')
103
+ s = SSHKey.from_file(key)
101
104
  s.location.should == 'desktop'
102
105
  end
103
106
  end
104
107
 
105
108
  describe '#keys' do
106
109
  it 'should load ssh key properly' do
107
- key = File.join(File.dirname(__FILE__),'keys', 'bob.pub')
108
- s = SSHKey.new(key)
110
+ key = File.join(key_dir, 'bob.pub')
111
+ s = SSHKey.from_file(key)
109
112
  parts = File.read(key).split #should get type, blob, email
110
113
 
111
114
  s.type.should == parts[0]
@@ -116,9 +119,139 @@ describe Gitolite::SSHKey do
116
119
 
117
120
  describe '#email' do
118
121
  it 'should use owner if email is missing' do
119
- key = File.join(File.dirname(__FILE__),'keys', 'jakub123@foo.net.pub')
120
- s = SSHKey.new(key)
122
+ key = File.join(key_dir, 'jakub123@foo.net.pub')
123
+ s = SSHKey.from_file(key)
121
124
  s.owner.should == s.email
122
125
  end
123
126
  end
127
+
128
+ describe '#new' do
129
+ it 'should create a valid ssh key' do
130
+ type = "ssh-rsa"
131
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
132
+ email = Forgery::Internet.email_address
133
+
134
+ s = SSHKey.new(type, blob, email)
135
+
136
+ s.to_s.should == [type, blob, email].join(' ')
137
+ s.owner.should == email
138
+ end
139
+
140
+ it 'should create a valid ssh key while specifying an owner' do
141
+ type = "ssh-rsa"
142
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
143
+ email = Forgery::Internet.email_address
144
+ owner = Forgery::Name.first_name
145
+
146
+ s = SSHKey.new(type, blob, email, owner)
147
+
148
+ s.to_s.should == [type, blob, email].join(' ')
149
+ s.owner.should == owner
150
+ end
151
+
152
+ it 'should create a valid ssh key while specifying an owner and location' do
153
+ type = "ssh-rsa"
154
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
155
+ email = Forgery::Internet.email_address
156
+ owner = Forgery::Name.first_name
157
+ location = Forgery::Name.location
158
+
159
+ s = SSHKey.new(type, blob, email, owner, location)
160
+
161
+ s.to_s.should == [type, blob, email].join(' ')
162
+ s.owner.should == owner
163
+ s.location.should == location
164
+ end
165
+ end
166
+
167
+ describe '#filename' do
168
+ it 'should create a filename that is the <email>.pub' do
169
+ type = "ssh-rsa"
170
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
171
+ email = Forgery::Internet.email_address
172
+
173
+ s = SSHKey.new(type, blob, email)
174
+
175
+ s.filename.should == "#{email}.pub"
176
+ end
177
+
178
+ it 'should create a filename that is the <owner>.pub' do
179
+ type = "ssh-rsa"
180
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
181
+ email = Forgery::Internet.email_address
182
+ owner = Forgery::Name.first_name
183
+
184
+ s = SSHKey.new(type, blob, email, owner)
185
+
186
+ s.filename.should == "#{owner}.pub"
187
+ end
188
+
189
+ it 'should create a filename that is the <email>@<location>.pub' do
190
+ type = "ssh-rsa"
191
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
192
+ email = Forgery::Internet.email_address
193
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
194
+
195
+ s = SSHKey.new(type, blob, email, nil, location)
196
+
197
+ s.filename.should == "#{email}@#{location}.pub"
198
+ end
199
+
200
+ it 'should create a filename that is the <owner>@<location>.pub' do
201
+ type = "ssh-rsa"
202
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
203
+ email = Forgery::Internet.email_address
204
+ owner = Forgery::Name.first_name
205
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
206
+
207
+ s = SSHKey.new(type, blob, email, owner, location)
208
+
209
+ s.filename.should == "#{owner}@#{location}.pub"
210
+ end
211
+ end
212
+
213
+ describe '#to_file' do
214
+ it 'should write a "valid" SSH public key to the file system' do
215
+ type = "ssh-rsa"
216
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
217
+ email = Forgery::Internet.email_address
218
+ owner = Forgery::Name.first_name
219
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
220
+
221
+ s = SSHKey.new(type, blob, email, owner, location)
222
+
223
+ tmpdir = Dir.tmpdir
224
+ s.to_file(tmpdir)
225
+
226
+ s.to_s.should == File.read(File.join(tmpdir, s.filename))
227
+ end
228
+
229
+ it 'should return the filename written' do
230
+ type = "ssh-rsa"
231
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
232
+ email = Forgery::Internet.email_address
233
+ owner = Forgery::Name.first_name
234
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
235
+
236
+ s = SSHKey.new(type, blob, email, owner, location)
237
+
238
+ tmpdir = Dir.tmpdir
239
+
240
+
241
+ s.to_file(tmpdir).should == File.join(tmpdir, s.filename)
242
+ end
243
+ end
244
+
245
+ describe '==' do
246
+ it 'should have two keys equalling one another' do
247
+ type = "ssh-rsa"
248
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
249
+ email = Forgery::Internet.email_address
250
+
251
+ s1 = SSHKey.new(type, blob, email)
252
+ s2 = SSHKey.new(type, blob, email)
253
+
254
+ s1.should == s2
255
+ end
256
+ end
124
257
  end
metadata CHANGED
@@ -1,63 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gitolite
3
- version: !ruby/object:Gem::Version
4
- prerelease: true
5
- segments:
6
- - 0
7
- - 0
8
- - 1
9
- - alpha
10
- version: 0.0.1.alpha
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2.alpha
5
+ prerelease: 6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Stafford Brunk
14
- autorequire:
9
+ autorequire: !!null
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-30 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-02-01 00:00:00.000000000 -05:00
13
+ default_executable: !!null
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &23994300 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
19
+ requirements:
27
20
  - - ~>
28
- - !ruby/object:Gem::Version
29
- segments:
30
- - 2
31
- - 4
32
- - 0
21
+ - !ruby/object:Gem::Version
33
22
  version: 2.4.0
34
23
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: grit
38
24
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *23994300
26
+ - !ruby/object:Gem::Dependency
27
+ name: forgery
28
+ requirement: &23993928 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.6
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *23993928
37
+ - !ruby/object:Gem::Dependency
38
+ name: grit
39
+ requirement: &23993640 !ruby/object:Gem::Requirement
40
40
  none: false
41
- requirements:
41
+ requirements:
42
42
  - - ~>
43
- - !ruby/object:Gem::Version
44
- segments:
45
- - 2
46
- - 4
47
- - 1
43
+ - !ruby/object:Gem::Version
48
44
  version: 2.4.1
49
45
  type: :runtime
50
- version_requirements: *id002
51
- description: This gem is designed to provide a Ruby interface to the gitolite git backend system. This gem aims to provide all management functionality that is available via the gitolite-admin repository (like SSH keys, repository permissions, etc)
52
- email:
46
+ prerelease: false
47
+ version_requirements: *23993640
48
+ description: This gem is designed to provide a Ruby interface to the gitolite git
49
+ backend system. This gem aims to provide all management functionality that is available
50
+ via the gitolite-admin repository (like SSH keys, repository permissions, etc)
51
+ email:
53
52
  - wingrunr21@gmail.com
54
53
  executables: []
55
-
56
54
  extensions: []
57
-
58
55
  extra_rdoc_files: []
59
-
60
- files:
56
+ files:
61
57
  - .gitignore
62
58
  - Gemfile
63
59
  - Gemfile.lock
@@ -86,36 +82,27 @@ files:
86
82
  has_rdoc: true
87
83
  homepage: https://www.github.com/wingrunr21/gitolite
88
84
  licenses: []
89
-
90
- post_install_message:
85
+ post_install_message: !!null
91
86
  rdoc_options: []
92
-
93
- require_paths:
87
+ require_paths:
94
88
  - lib
95
- required_ruby_version: !ruby/object:Gem::Requirement
89
+ required_ruby_version: !ruby/object:Gem::Requirement
96
90
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- segments:
101
- - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
96
  none: false
105
- requirements:
106
- - - ">"
107
- - !ruby/object:Gem::Version
108
- segments:
109
- - 1
110
- - 3
111
- - 1
97
+ requirements:
98
+ - - ! '>'
99
+ - !ruby/object:Gem::Version
112
100
  version: 1.3.1
113
101
  requirements: []
114
-
115
102
  rubyforge_project: gitolite
116
- rubygems_version: 1.3.7
117
- signing_key:
103
+ rubygems_version: 1.5.0
104
+ signing_key: !!null
118
105
  specification_version: 3
119
- summary: A Ruby gem for manipulating the gitolite git backend via the gitolite-admin repository.
106
+ summary: A Ruby gem for manipulating the gitolite git backend via the gitolite-admin
107
+ repository.
120
108
  test_files: []
121
-