gritano 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Gritano v0.2.2
1
+ = Gritano v0.3.0
2
2
 
3
3
  Gritano is the simplest way to configure a git server over ssh. You can create repositories and manage user access using this practical tool.
4
4
 
@@ -11,6 +11,14 @@ Gritano is the simplest way to configure a git server over ssh. You can create r
11
11
 
12
12
  $ gem install gritano
13
13
 
14
+ == Update
15
+
16
+ If you are using a previous version, you should update your instalation:
17
+
18
+ $ gem install gritano
19
+
20
+ $ gritano update
21
+
14
22
  == Usage
15
23
 
16
24
  First of all you should create a git user who will be responsible for store and manipulate repositories. Lets suppose we are logged as this user.
@@ -22,6 +30,10 @@ All you need to do to set up Gritano is
22
30
  After that you can add users:
23
31
 
24
32
  $ gritano user add igorbonadio
33
+
34
+ add administrator rights to this user:
35
+
36
+ $ gritano user addadmin igorbonadio
25
37
 
26
38
  add user's public keys:
27
39
 
@@ -35,9 +47,13 @@ and control access:
35
47
 
36
48
  $ gritano repo addread proj.git igorbonadio
37
49
 
50
+ For more information, execute
51
+
52
+ $ gritano help
53
+
38
54
  == User Access
39
55
 
40
- Gritano 0.2.0 introduced a new feature that enables users to execute some simple commands:
56
+ Gritano 0.2.0 introduced a new feature that enables users to execute some simple commands via ssh:
41
57
 
42
58
  $ ssh git@host.com repos
43
59
 
@@ -46,6 +62,32 @@ Gritano 0.2.0 introduced a new feature that enables users to execute some simple
46
62
  $ ssh git@host.com addkey mykey < id_rsa.pub
47
63
 
48
64
  $ ssh git@host.com rmkey mykey
65
+
66
+ For more information, execute
67
+
68
+ $ ssh git@host.com help
69
+
70
+ == Admin Access
71
+
72
+ Starting from Gritano 0.3.0, administrators can execute commands via ssh:
73
+
74
+ $ ssh git@hot.com user add username
75
+
76
+ $ ssh git@hot.com user rm username
77
+
78
+ $ ssh git@hot.com user addkey username keyname < key.pub
79
+
80
+ $ ssh git@hot.com user rmkey username keyname
81
+
82
+ $ ssh git@hot.com repo add reponame.git
83
+
84
+ $ ssh git@hot.com repo rm reponame.git
85
+
86
+ $ ssh git@hot.com repo list
87
+
88
+ For more information, execute
89
+
90
+ $ ssh git@host.com admin help
49
91
 
50
92
  == Contributing to Gritano
51
93
 
data/TODO CHANGED
@@ -1,19 +1,6 @@
1
- v0.2.2
2
- - uniformizar o uso de add e rm
3
-
4
- v0.3.0
5
- - acesso administrativo via ssh
6
- ssh git@host.com user add username
7
- ssh git@host.com user rm username
8
- ssh git@host.com user addkey username keyname < key.pub
9
- ssh git@host.com user rmkey username keyname
10
- ssh git@host.com repo add reponame.git
11
- ssh git@host.com repo rm reponame.git
12
- ssh git@host.com repo addread reponame.git username
13
- ssh git@host.com repo addwrite reponame.git username
14
- ssh git@host.com repo rmread reponame.git username
15
- ssh git@host.com repo rmwrite reponame.git username
16
-
17
- v0.4.0
1
+ Outros
18
2
  - usuário pode (ou não) criar repositorios via ssh
19
- ssh git@host.com repo add reponame.git
3
+ ssh git@host.com newrepo reponame.git
4
+ ssh git@host.com rmrepo reponame.git
5
+ - Stream de mensagens via ssh
6
+ - Melhorar specs e features
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
data/bin/gritano CHANGED
@@ -12,10 +12,13 @@ def help
12
12
 
13
13
  Examples:
14
14
  gritano install
15
+ gritano update
15
16
  gritano user add username
16
17
  gritano user rm username
17
18
  gritano user addkey username keyname < key.pub
18
19
  gritano user rmkey username keyname
20
+ gritano user addadmin username
21
+ gritano user rmadmin username
19
22
  gritano user list
20
23
  gritano user keys username
21
24
  gritano user repos username
@@ -32,6 +35,11 @@ def help
32
35
  v#{File.open(File.join(File.dirname(__FILE__), '..', 'VERSION')).readlines.join}"
33
36
  end
34
37
 
38
+ def migrate
39
+ ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(Etc.getpwuid.dir, '.gritano', 'database.yml'))))
40
+ ActiveRecord::Migrator.migrate(File.join(File.dirname(__FILE__),'../db/migrate'), ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
41
+ end
42
+
35
43
  def install
36
44
  Dir.mkdir(File.join(Etc.getpwuid.dir, '.gritano')) unless File.exist?(File.join(Etc.getpwuid.dir, '.gritano'))
37
45
  Dir.mkdir(File.join(Etc.getpwuid.dir, '.ssh')) unless File.exist?(File.join(Etc.getpwuid.dir, '.ssh'))
@@ -39,8 +47,7 @@ def install
39
47
  f.write("adapter: sqlite3\ndatabase: #{File.join(Etc.getpwuid.dir, '.gritano', 'database.db')}\n")
40
48
  end
41
49
  FileUtils.rm(File.join(Etc.getpwuid.dir, '.gritano', 'database.db')) if File.exist?(File.join(Etc.getpwuid.dir, '.gritano', 'database.db'))
42
- ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(Etc.getpwuid.dir, '.gritano', 'database.yml'))))
43
- ActiveRecord::Migrator.migrate(File.join(File.dirname(__FILE__),'../db/migrate'), ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
50
+ migrate
44
51
  end
45
52
 
46
53
  def version
@@ -65,6 +72,8 @@ check_git
65
72
  if ARGV.length == 1
66
73
  if ARGV[0] =='install'
67
74
  install
75
+ elsif ARGV[0] =='update'
76
+ migrate
68
77
  elsif ARGV[0] =='version'
69
78
  version
70
79
  else
data/bin/gritano-check CHANGED
@@ -13,6 +13,7 @@ def help
13
13
  ssh git@host.com keys
14
14
  ssh git@host.com addkey keyname < key.pub
15
15
  ssh git@host.com rmkey keyname
16
+ ssh git@host.com admin help
16
17
 
17
18
  --
18
19
  v#{File.open(File.join(File.dirname(__FILE__), '..', 'VERSION')).readlines.join}"
@@ -42,6 +43,14 @@ begin
42
43
  cmd = cmd + " " + login
43
44
  end
44
45
  exec "gritano user #{cmd}"
46
+ when :admin_cmd
47
+ cmd = command[:command]
48
+ user = Gritano::User.find_by_login(login)
49
+ if user.admin?
50
+ exec "gritano #{cmd}"
51
+ else
52
+ puts "access denied"
53
+ end
45
54
  end
46
55
  rescue
47
56
  puts help
@@ -0,0 +1,10 @@
1
+ class AddAdminToUsers < ActiveRecord::Migration
2
+ def up
3
+ add_column :users, :admin, :boolean, :default => false
4
+ end
5
+
6
+ def down
7
+ remove_column :users, :admin
8
+ end
9
+ end
10
+
@@ -7,10 +7,26 @@ Feature: Command
7
7
  When I receive a "<original_command>" command
8
8
  Then I should see that it is a "<access>": "<command>" "<repo>"
9
9
  Examples:
10
- | original_command | access | command | repo |
11
- | git-receive-pack proj.git | write | git-receive-pack | proj.git |
12
- | git-upload-pack proj.git | read | git-upload-pack | proj.git |
13
- | repos | user_cmd | repos | |
14
- | keys | user_cmd | keys | |
15
- | addkey keyname | user_cmd | addkey keyname | |
16
- | rmkey keyname | user_cmd | rmkey keyname | |
10
+ | original_command | access | command | repo |
11
+ | git-receive-pack proj.git | write | git-receive-pack | proj.git |
12
+ | git-upload-pack proj.git | read | git-upload-pack | proj.git |
13
+ | repos | user_cmd | repos | |
14
+ | keys | user_cmd | keys | |
15
+ | addkey keyname | user_cmd | addkey keyname | |
16
+ | rmkey keyname | user_cmd | rmkey keyname | |
17
+ | user add username | admin_cmd | user add username | |
18
+ | user rm username | admin_cmd | user rm username | |
19
+ | user addkey username keyname | admin_cmd | user addkey username keyname | |
20
+ | user rmkey username keyname | admin_cmd | user rmkey username keyname | |
21
+ | user list | admin_cmd | user list | |
22
+ | user keys username | admin_cmd | user keys username | |
23
+ | user repos username | admin_cmd | user repos username | |
24
+ | repo add reponame.git | admin_cmd | repo add reponame.git | |
25
+ | repo rm reponame.git | admin_cmd | repo rm reponame.git | |
26
+ | repo addread reponame.git username | admin_cmd | repo addread reponame.git username | |
27
+ | repo addwrite reponame.git username | admin_cmd | repo addwrite reponame.git username | |
28
+ | repo rmread reponame.git username | admin_cmd | repo rmread reponame.git username | |
29
+ | repo rmwrite reponame.git username | admin_cmd | repo rmwrite reponame.git username | |
30
+ | repo list | admin_cmd | repo list | |
31
+ | repo users reponame.git | admin_cmd | repo users reponame.git | |
32
+ | admin help | admin_cmd | help | |
@@ -5,9 +5,9 @@ Feature: Console operations
5
5
 
6
6
  Background:
7
7
  Given the following users exist:
8
- | login |
9
- | igorbonadio |
10
- | jessicaeto |
8
+ | login | admin |
9
+ | igorbonadio | true |
10
+ | jessicaeto | false |
11
11
 
12
12
  And the following keys exist:
13
13
  | login | key |
@@ -40,6 +40,8 @@ Feature: Console operations
40
40
  | user list | success |
41
41
  | user keys igorbonadio | success |
42
42
  | user repos igorbonadio | success |
43
+ | user addadmin igorbonadio | success |
44
+ | user rmadmin igorbonadio | success |
43
45
  | repo add tmp/p-lang.git | success |
44
46
  | repo rm tmp/jeka.git | success |
45
47
  | repo addread tmp/gritano.git jessicaeto | success |
@@ -54,6 +56,8 @@ Feature: Console operations
54
56
  | user rmkey igorbonadio marvino | error |
55
57
  | user keys arybonadio | error |
56
58
  | user repos arybonadio | error |
59
+ | user addadmin arybonadio | error |
60
+ | user rmadmin arybonadio | error |
57
61
  | repo add tmp/jeka.git | error |
58
62
  | repo rm tmp/p-lang.git | error |
59
63
  | repo addread tmp/gritano.git arybonadio | error |
data/gritano.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gritano"
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Igor Bonadio"]
12
- s.date = "2012-11-22"
12
+ s.date = "2012-11-24"
13
13
  s.description = "Gritano is the simplest way to configure your git server over ssh. You can create repositories and manage user access."
14
14
  s.email = "igorbonadio@gmail.com"
15
15
  s.executables = ["gritano", "gritano-check"]
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  "db/migrate/002_create_repositories.rb",
35
35
  "db/migrate/003_create_permissions.rb",
36
36
  "db/migrate/004_create_keys.rb",
37
+ "db/migrate/005_add_admin_to_users.rb",
37
38
  "features/command.feature",
38
39
  "features/console.feature",
39
40
  "features/data/keys/full_authorized_keys",
@@ -8,6 +8,10 @@ module Gritano
8
8
  return {access: :read, command: "git-upload-pack", repo: self.repo(cmd)}
9
9
  when /^repos/, /^keys/, /^addkey/, /^rmkey/ then
10
10
  return {access: :user_cmd, command: cmd}
11
+ when /^user/, /^repo/ then
12
+ return {access: :admin_cmd, command: cmd}
13
+ when /^admin help/ then
14
+ return {access: :admin_cmd, command: 'help'}
11
15
  end
12
16
  end
13
17
 
@@ -186,5 +186,29 @@ module Gritano
186
186
  end
187
187
  return [false, "Key could not be removed."]
188
188
  end
189
+
190
+ def user_addadmin(argv)
191
+ login, = argv
192
+ user = User.find_by_login(login)
193
+ if user
194
+ user.admin = true
195
+ if user.save
196
+ return [true, "Now, user #{login} is an administrator"]
197
+ end
198
+ end
199
+ return [false, "User #{login} could not be modified"]
200
+ end
201
+
202
+ def user_rmadmin(argv)
203
+ login, = argv
204
+ user = User.find_by_login(login)
205
+ if user
206
+ user.admin = false
207
+ if user.save
208
+ return [true, "Now, user #{login} is not an administrator"]
209
+ end
210
+ end
211
+ return [false, "User #{login} could not be modified"]
212
+ end
189
213
  end
190
214
  end
data/spec/console_spec.rb CHANGED
@@ -82,4 +82,14 @@ describe Gritano::Console do
82
82
  @console.should_receive(:repo_users)
83
83
  @console.execute("repo users reponame.git".split(' '))
84
84
  end
85
+
86
+ it "should respond to gritano user addadmin igorbonadio" do
87
+ @console.should_receive(:user_addadmin)
88
+ @console.execute("user addadmin igorbonadio".split(' '))
89
+ end
90
+
91
+ it "should respond to gritano user rmadmin igorbonadio" do
92
+ @console.should_receive(:user_rmadmin)
93
+ @console.execute("user rmadmin igorbonadio".split(' '))
94
+ end
85
95
  end
@@ -14,6 +14,16 @@ describe Gritano::User do
14
14
  user2.should be_invalid
15
15
  end
16
16
 
17
+ it 'can be a administrator' do
18
+ user = Gritano::User.new(login: 'login', admin: true)
19
+ user.should be_admin
20
+ end
21
+
22
+ it 'can not be a administrator' do
23
+ user = Gritano::User.new(login: 'login', admin: false)
24
+ user.should_not be_admin
25
+ end
26
+
17
27
  it 'should add read access to a repository' do
18
28
  user = Gritano::User.create(login: 'test')
19
29
  repo = Gritano::Repository.create(name: 'tmp/repo.git')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gritano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-22 00:00:00.000000000 Z
12
+ date: 2012-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -198,6 +198,7 @@ files:
198
198
  - db/migrate/002_create_repositories.rb
199
199
  - db/migrate/003_create_permissions.rb
200
200
  - db/migrate/004_create_keys.rb
201
+ - db/migrate/005_add_admin_to_users.rb
201
202
  - features/command.feature
202
203
  - features/console.feature
203
204
  - features/data/keys/full_authorized_keys
@@ -245,7 +246,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
246
  version: '0'
246
247
  segments:
247
248
  - 0
248
- hash: 1441150842107261050
249
+ hash: -3218000762772631933
249
250
  required_rubygems_version: !ruby/object:Gem::Requirement
250
251
  none: false
251
252
  requirements: