gritano 0.4.1 → 0.5.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.
@@ -0,0 +1,27 @@
1
+ gritano [command]
2
+
3
+ Examples:
4
+ gritano help
5
+ gritano version
6
+ gritano setup:prepare
7
+ gritano setup:install
8
+ gritano user:list
9
+ gritano user:key:list username
10
+ gritano user:repo:list username
11
+ gritano user:add username
12
+ gritano user:rm username
13
+ gritano user:key:add username keyname < key.pub
14
+ gritano user:key:rm username keyname
15
+ gritano user:admin:add username
16
+ gritano user:admin:rm username
17
+ gritano repo:list
18
+ gritano repo:add reponame.git [username1 username2 ...]*
19
+ gritano repo:user:list reponame.git
20
+ gritano repo:rm reponame.git
21
+ gritano repo:read:add reponame.git username
22
+ gritano repo:write:add reponame.git username
23
+ gritano repo:read:rm reponame.git username
24
+ gritano repo:write:rm reponame.git username
25
+
26
+ --
27
+ v0.4.1
@@ -0,0 +1,9 @@
1
+ Feature: Console operations
2
+ In order to kwon how to use gritano
3
+ As a user
4
+ I want to see the help
5
+
6
+ Scenario: Get help
7
+ When I set bin_name to test
8
+ Then gritano should show help-test
9
+
@@ -0,0 +1,150 @@
1
+ Feature: SSH operations
2
+ In order to use gritano via ssh
3
+ As a user
4
+ I want to execute some commands
5
+
6
+ Background:
7
+ Given the following users exist:
8
+ | login | admin |
9
+ | igorbonadio | true |
10
+ | jessicaeto | false |
11
+
12
+ And the following keys exist:
13
+ | login | key |
14
+ | igorbonadio | eva |
15
+ | jessicaeto | hal |
16
+
17
+ And the following repositories exist:
18
+ | name |
19
+ | tmp/gritano.git |
20
+ | tmp/jeka.git |
21
+
22
+ And the following permissions exist:
23
+ | user | repo | access |
24
+ | igorbonadio | tmp/gritano.git | read |
25
+ | igorbonadio | tmp/gritano.git | write |
26
+ | igorbonadio | tmp/jeka.git | read |
27
+ | jessicaeto | tmp/jeka.git | read |
28
+ | jessicaeto | tmp/jeka.git | write |
29
+
30
+ Scenario: Git read access
31
+ Given I start the gritano-check console with "igorbonadio"
32
+ When I try to get tmp/gritano.git
33
+ Then I should get it
34
+
35
+ Scenario: Git write access
36
+ Given I start the gritano-check console with "igorbonadio"
37
+ When I try to send data to tmp/gritano.git
38
+ Then I should send it
39
+
40
+ Scenario: Error
41
+ Given I start the gritano-check console with "igorbonadio"
42
+ When I try to send an invalid command
43
+ Then I should see an exception
44
+
45
+ Scenario Outline: Admin via ssh
46
+ Given I start the gritano-check console with "igorbonadio"
47
+ When I execute "<command>" via ssh
48
+ Then I should see a <result> message
49
+ Examples:
50
+ | command | result |
51
+ | version | success |
52
+ | help | success |
53
+ | repo:list | success |
54
+ | key:list | success |
55
+ | key:add keyname | success |
56
+ | key:rm eva | success |
57
+ | admin:help | success |
58
+ | key:rm keyname | error |
59
+ | admin:user:add jose | success |
60
+ | admin:user:key:add igorbonadio marvin | success |
61
+ | admin:user:key:rm igorbonadio eva | success |
62
+ | admin:user:rm igorbonadio | success |
63
+ | admin:user:list | success |
64
+ | admin:user:key:list igorbonadio | success |
65
+ | admin:user:repo:list igorbonadio | success |
66
+ | admin:user:admin:add igorbonadio | success |
67
+ | admin:user:admin:rm igorbonadio | success |
68
+ | admin:repo:add tmp/p-lang.git | success |
69
+ | admin:repo:add tmp/p-lang.git igorbonadio | success |
70
+ | admin:repo:add tmp/p-lang.git igorbonadio jessicaeto | success |
71
+ | admin:repo:rm tmp/jeka.git | success |
72
+ | admin:repo:read:add tmp/gritano.git jessicaeto | success |
73
+ | admin:repo:write:add tmp/gritano.git jessicaeto | success |
74
+ | admin:repo:read:rm tmp/jeka.git igorbonadio | success |
75
+ | admin:repo:write:rm tmp/gritano.git igorbonadio | success |
76
+ | admin:repo:list | success |
77
+ | admin:repo:user:list tmp/jeka.git | success |
78
+ | admin:user:add igorbonadio | error |
79
+ | admin:user:rm jose | error |
80
+ | admin:user:key:add userrr marvino | error |
81
+ | admin:user:key:rm igorbonadio marvino | error |
82
+ | admin:user:key:list arybonadio | error |
83
+ | admin:user:repo:list arybonadio | error |
84
+ | admin:user:admin:add arybonadio | error |
85
+ | admin:user:admin:rm arybonadio | error |
86
+ | admin:repo:add tmp/jeka.git | error |
87
+ | admin:repo:rm tmp/p-lang.git | error |
88
+ | admin:repo:read:add tmp/gritano.git arybonadio | error |
89
+ | admin:repo:read:add tmp/p-lang.git jessicaeto | error |
90
+ | admin:repo:write:add tmp/gritano.git arybonadio | error |
91
+ | admin:repo:write:add tmp/p-lang.git jessicaeto | error |
92
+ | admin:repo:read:rm tmp/jeka.git aribonadio | error |
93
+ | admin:repo:read:rm tmp/p-lang.git igorbonadio | error |
94
+ | admin:repo:write:rm tmp/gritano.git arybonadio | error |
95
+ | admin:repo:write:rm tmp/p-lang.git igorbonadio | error |
96
+ | admin:repo:user:list tmp/ruby.git | error |
97
+
98
+ Scenario Outline: Normal user via ssh
99
+ Given I start the gritano-check console with "jessicaeto"
100
+ When I execute "<command>" via ssh
101
+ Then I should see a <result> message
102
+ Examples:
103
+ | command | result |
104
+ | version | success |
105
+ | help | success |
106
+ | repo:list | success |
107
+ | key:list | success |
108
+ | key:add keyname | success |
109
+ | key:rm hal | success |
110
+ | admin:help | success |
111
+ | key:rm keyname | error |
112
+ | admin:user:add jose | error |
113
+ | admin:user:key:add igorbonadio marvin | error |
114
+ | admin:user:key:rm igorbonadio eva | error |
115
+ | admin:user:rm igorbonadio | error |
116
+ | admin:user:list | error |
117
+ | admin:user:key:list igorbonadio | error |
118
+ | admin:user:repo:list igorbonadio | error |
119
+ | admin:user:admin:add igorbonadio | error |
120
+ | admin:user:admin:rm igorbonadio | error |
121
+ | admin:repo:add tmp/p-lang.git | error |
122
+ | admin:repo:add tmp/p-lang.git igorbonadio | error |
123
+ | admin:repo:add tmp/p-lang.git igorbonadio jessicaeto | error |
124
+ | admin:repo:rm tmp/jeka.git | error |
125
+ | admin:repo:read:add tmp/gritano.git jessicaeto | error |
126
+ | admin:repo:write:add tmp/gritano.git jessicaeto | error |
127
+ | admin:repo:read:rm tmp/jeka.git igorbonadio | error |
128
+ | admin:repo:write:rm tmp/gritano.git igorbonadio | error |
129
+ | admin:repo:list | error |
130
+ | admin:repo:user:list tmp/jeka.git | error |
131
+ | admin:user:add igorbonadio | error |
132
+ | admin:user:rm jose | error |
133
+ | admin:user:key:add userrr marvino | error |
134
+ | admin:user:key:rm igorbonadio marvino | error |
135
+ | admin:user:key:list arybonadio | error |
136
+ | admin:user:repo:list arybonadio | error |
137
+ | admin:user:admin:add arybonadio | error |
138
+ | admin:user:admin:rm arybonadio | error |
139
+ | admin:repo:add tmp/jeka.git | error |
140
+ | admin:repo:rm tmp/p-lang.git | error |
141
+ | admin:repo:read:add tmp/gritano.git arybonadio | error |
142
+ | admin:repo:read:add tmp/p-lang.git jessicaeto | error |
143
+ | admin:repo:write:add tmp/gritano.git arybonadio | error |
144
+ | admin:repo:write:add tmp/p-lang.git jessicaeto | error |
145
+ | admin:repo:read:rm tmp/jeka.git aribonadio | error |
146
+ | admin:repo:read:rm tmp/p-lang.git igorbonadio | error |
147
+ | admin:repo:write:rm tmp/gritano.git arybonadio | error |
148
+ | admin:repo:write:rm tmp/p-lang.git igorbonadio | error |
149
+ | admin:repo:user:list tmp/ruby.git | error |
150
+
@@ -0,0 +1,71 @@
1
+ Given /^I start the CLI$/ do
2
+ @cli = Gritano::CLI
3
+ @home_dir = '.'
4
+ @repo_dir = 'tmp'
5
+ @stdin = double()
6
+ @stdin.stub(:read).and_return("Your SSHKEY here...")
7
+ end
8
+
9
+ When /^I send "(.*?)" to the CLI\.execute$/ do |cmd|
10
+ @output = @cli.execute(cmd.split(' '), @stdin, @home_dir, @repo_dir)
11
+ end
12
+
13
+ When /^I send "(.*?)" to the CLI\.check$/ do |cmd|
14
+ @output = @cli.check(cmd.split(' '), @login, @stdin, @home_dir, @repo_dir)
15
+ end
16
+
17
+
18
+ Then /^CLI should return the help$/ do
19
+ help = File.open("features/data/help.txt").readlines.join[0..-2]
20
+ @output.should be == help
21
+ end
22
+
23
+ Then /^CLI should return the help\-check$/ do
24
+ help = File.open("features/data/help-check.txt").readlines.join[0..-2]
25
+ @output.should be == help
26
+ end
27
+
28
+ Given /^I start the CLI but gritano is not installed$/ do
29
+ @cli = Gritano::CLI
30
+ @home_dir = 'tmp'
31
+ @repo_dir = 'tmp'
32
+ @stdin = double()
33
+ @stdin.stub(:read).and_return("Your SSHKEY here...")
34
+ end
35
+
36
+ Given /^I start the CLI with "(.*?)"$/ do |login|
37
+ @cli = Gritano::CLI
38
+ @home_dir = '.'
39
+ @repo_dir = 'tmp'
40
+ @stdin = double()
41
+ @stdin.stub(:read).and_return("Your SSHKEY here...")
42
+ @login = login
43
+ end
44
+
45
+ Then /^CLI should exit$/ do
46
+ lambda {@cli.execute(@cmd, @stdin, @home_dir, @repo_dir)}.should raise_error SystemExit
47
+ end
48
+
49
+ When /^I send a command to the CLI\.execute$/ do
50
+ @cmd = ["user:list"]
51
+ end
52
+
53
+ Then /^CLI should return "(.*?)"$/ do |msg|
54
+ @output.should be == msg
55
+ end
56
+
57
+ When /^I try to get tmp\/gritano\.git from CLI\.check$/ do
58
+ Kernel.should_receive(:exec)
59
+ @cli.check(['git-receive-pack', 'tmp/gritano.git'], @login, @stdin, @home_dir, @repo_dir)
60
+ end
61
+
62
+ When /^I try to send data to tmp\/gritano\.git from CLI\.check$/ do
63
+ Kernel.should_receive(:exec)
64
+ @cli.check(['git-upload-pack', 'tmp/gritano.git'], @login, @stdin, @home_dir, @repo_dir)
65
+ end
66
+
67
+ When /^I try to send an invalid command to CLI\.check$/ do
68
+ @output = @cli.check(['error:error'], @login, @stdin, @home_dir, @repo_dir)
69
+ end
70
+
71
+
@@ -1,8 +1,7 @@
1
1
  Given /^I start the gritano console$/ do
2
2
  stdin = double()
3
3
  stdin.stub(:read).and_return("Your SSHKEY here...")
4
- @console = Gritano::Console.new(stdin)
5
- @console.ssh_path = 'tmp'
4
+ @console = Gritano::Console::Gritano.new(stdin, '.', 'tmp')
6
5
  end
7
6
 
8
7
  When /^I execute "(.*?)"$/ do |command|
@@ -13,4 +12,30 @@ Then /^I should see a (success|error) message$/ do |result|
13
12
  expected_output = true if result == 'success'
14
13
  expected_output = false if result == 'error'
15
14
  @output[0].should be == expected_output
16
- end
15
+ end
16
+
17
+ Then /^I should see the help$/ do
18
+ help = File.open("features/data/help.txt").readlines.join[0..-2]
19
+ @output[1].should be == help
20
+ end
21
+
22
+ Given /^I start the gritano console but gritano is not installed$/ do
23
+ stdin = double()
24
+ stdin.stub(:read).and_return("Your SSHKEY here...")
25
+ FileUtils.rm_rf('tmp\.gritano')
26
+ @console = Gritano::Console::Gritano.new(stdin, 'tmp', 'tmp')
27
+ end
28
+
29
+ When /^I execute a command$/ do
30
+ @command = ['user:list']
31
+ end
32
+
33
+ Then /^I should see an error$/ do
34
+ lambda {@console.execute(@command)}.should raise_error SystemExit
35
+ end
36
+
37
+ When /^I install it$/ do
38
+ @console.execute(['setup:prepare'])
39
+ @output = @console.execute(['setup:install'])
40
+ end
41
+
@@ -0,0 +1,9 @@
1
+ When /^I set bin_name to test$/ do
2
+ Gritano::Console::Gritano.bin_name = "test "
3
+ end
4
+
5
+ Then /^gritano should show help\-test$/ do
6
+ help = File.open("features/data/help-test.txt").readlines.join[0..-2]
7
+ Gritano::Console::Gritano.help.should be == help
8
+ end
9
+
@@ -0,0 +1,35 @@
1
+ Given /^I start the gritano\-check console with "(.*?)"$/ do |login|
2
+ stdin = double()
3
+ stdin.stub(:read).and_return("Your SSHKEY here...")
4
+ @console = Gritano::Console::Check.new(stdin, '.', 'tmp')
5
+ @login = login
6
+ end
7
+
8
+ When /^I execute "(.*?)" via ssh$/ do |command|
9
+ @output = @console.execute(command.split(' ') + [@login])
10
+ end
11
+
12
+ When /^I try to get tmp\/gritano\.git$/ do
13
+ Kernel.should_receive(:exec)
14
+ @console.execute(['git-receive-pack', 'tmp/gritano.git'] + [@login])
15
+ end
16
+
17
+ Then /^I should get it$/ do
18
+ end
19
+
20
+ When /^I try to send data to tmp\/gritano\.git$/ do
21
+ Kernel.should_receive(:exec)
22
+ @console.execute(['git-upload-pack', 'tmp/gritano.git'] + [@login])
23
+ end
24
+
25
+ Then /^I should send it$/ do
26
+ end
27
+
28
+ When /^I try to send an invalid command$/ do
29
+ @command = ['invalid:command']
30
+ end
31
+
32
+ Then /^I should see an exception$/ do
33
+ lambda {@console.execute(@command + [@login])}.should raise_error NoMethodError
34
+ end
35
+
@@ -2,6 +2,7 @@ require 'simplecov'
2
2
  SimpleCov.start do
3
3
  add_filter "/features/"
4
4
  add_filter "/spec/"
5
+ add_filter "/db/"
5
6
  end
6
7
 
7
8
  require 'bundler'
@@ -22,5 +23,6 @@ require 'cucumber/rspec/doubles'
22
23
  require 'active_record'
23
24
 
24
25
  Before do
25
- ActiveRecord::Base.establish_connection(YAML::load(File.open('db/database.yml')))
26
- end
26
+ ActiveRecord::Base.establish_connection(YAML::load(File.open('.gritano/database.yml')))
27
+ Gritano::Console.remote_console(false)
28
+ end
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.4.1"
8
+ s.version = "0.5.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-12-14"
12
+ s.date = "2012-12-22"
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"]
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
+ ".gritano/database.yml",
23
24
  ".rspec",
25
+ ".ssh/.gitignore",
24
26
  "Gemfile",
25
27
  "Gemfile.lock",
26
28
  "LICENSE.txt",
@@ -29,43 +31,54 @@ Gem::Specification.new do |s|
29
31
  "VERSION",
30
32
  "bin/gritano",
31
33
  "bin/gritano-check",
32
- "db/database.yml",
33
34
  "db/migrate/001_create_users.rb",
34
35
  "db/migrate/002_create_repositories.rb",
35
36
  "db/migrate/003_create_permissions.rb",
36
37
  "db/migrate/004_create_keys.rb",
37
38
  "db/migrate/005_add_admin_to_users.rb",
38
- "features/command.feature",
39
+ "features/cli.feature",
39
40
  "features/console.feature",
41
+ "features/data/help-check.txt",
42
+ "features/data/help-test.txt",
43
+ "features/data/help.txt",
40
44
  "features/data/keys/full_authorized_keys",
41
45
  "features/data/keys/igorbonadio.pub",
42
46
  "features/data/keys/igorbonadio_authorized_keys",
43
47
  "features/data/keys/jessicaeto.pub",
44
48
  "features/data/keys/jessicaeto_authorized_keys",
49
+ "features/help.feature",
45
50
  "features/keys.feature",
46
51
  "features/polices.feature",
47
- "features/step_definitions/command_step.rb",
52
+ "features/ssh.feature",
53
+ "features/step_definitions/cli_steps.rb",
48
54
  "features/step_definitions/console_step.rb",
55
+ "features/step_definitions/help.rb",
49
56
  "features/step_definitions/keys_steps.rb",
50
57
  "features/step_definitions/polices_steps.rb",
58
+ "features/step_definitions/ssh_steps.rb",
51
59
  "features/support/database_cleaner.rb",
52
60
  "features/support/env.rb",
53
61
  "gritano.gemspec",
54
62
  "lib/gritano.rb",
55
- "lib/gritano/command.rb",
63
+ "lib/gritano/cli.rb",
56
64
  "lib/gritano/console.rb",
65
+ "lib/gritano/console/base.rb",
66
+ "lib/gritano/console/check.rb",
67
+ "lib/gritano/console/executor.rb",
68
+ "lib/gritano/console/gritano.rb",
69
+ "lib/gritano/console/installer.rb",
57
70
  "lib/gritano/models.rb",
58
71
  "lib/gritano/models/key.rb",
59
72
  "lib/gritano/models/permission.rb",
60
73
  "lib/gritano/models/repository.rb",
61
74
  "lib/gritano/models/user.rb",
62
- "spec/command_spec.rb",
63
- "spec/console_spec.rb",
75
+ "spec/executor_spec.rb",
76
+ "spec/gritano_spec.rb",
77
+ "spec/installer_spec.rb",
64
78
  "spec/model_key_spec.rb",
65
79
  "spec/model_repository_spec.rb",
66
80
  "spec/model_user_spec.rb",
67
- "spec/spec_helper.rb",
68
- "tmp/.gitignore"
81
+ "spec/spec_helper.rb"
69
82
  ]
70
83
  s.homepage = "http://github.com/igorbonadio/gritano"
71
84
  s.licenses = ["MIT"]