gritano 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +24 -24
- data/README.rdoc +7 -7
- data/TODO +1 -1
- data/VERSION +1 -1
- data/features/data/remote_help.txt +13 -0
- data/features/step_definitions/install_step.rb +2 -2
- data/gritano.gemspec +12 -5
- data/lib/gritano/console/base.rb +5 -1
- data/lib/gritano/console/gritano.rb +1 -1
- data/lib/gritano/console/installer.rb +21 -5
- data/lib/gritano/console/remote.rb +21 -11
- data/spec/cli_spec.rb +21 -0
- data/spec/console_base_spec.rb +61 -0
- data/spec/console_executor_spec.rb +168 -0
- data/spec/console_gritano_spec.rb +121 -0
- data/spec/console_installer_spec.rb +28 -0
- data/spec/console_remote_spec.rb +70 -0
- data/spec/console_spec.rb +23 -0
- data/spec/data/help_command_name.txt +7 -0
- data/spec/model_key_spec.rb +35 -15
- data/spec/model_permission_spec.rb +72 -0
- data/spec/model_repository_spec.rb +52 -19
- data/spec/model_user_spec.rb +93 -65
- metadata +13 -6
- data/spec/executor_spec.rb +0 -100
- data/spec/gritano_spec.rb +0 -20
- data/spec/installer_spec.rb +0 -23
data/spec/model_user_spec.rb
CHANGED
@@ -1,68 +1,96 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module Gritano
|
4
|
+
describe User do
|
5
|
+
before(:each) do
|
6
|
+
Repository.any_instance.stub(:create_bare_repo).and_return(:create_bare_repo)
|
7
|
+
Repository.any_instance.stub(:destroy_bare_repo).and_return(:destroy_bare_repo)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a login" do
|
11
|
+
user = User.new()
|
12
|
+
user.should be_invalid
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have an unique login" do
|
16
|
+
User.create(login: 'user')
|
17
|
+
user = User.new(login: 'user')
|
18
|
+
user.should be_invalid
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can have many repositories" do
|
22
|
+
user = User.create(login: 'user')
|
23
|
+
user.repositories.count.should == 0
|
24
|
+
user.repositories.create(name:'myrepo', path: 'path')
|
25
|
+
user.repositories.count.should == 1
|
26
|
+
user.repositories.create(name:'myrepo2', path: 'path2')
|
27
|
+
user.repositories.count.should == 2
|
28
|
+
user.repositories.create(name:'myrepo3', path: 'path3')
|
29
|
+
user.repositories.count.should == 3
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can have many keys" do
|
33
|
+
user = User.create(login: 'user')
|
34
|
+
user.keys.count.should == 0
|
35
|
+
user.keys.create(name: "mykey", key: "sshkey")
|
36
|
+
user.keys.count.should == 1
|
37
|
+
user.keys.create(name: "mykey2", key: "sshkey2")
|
38
|
+
user.keys.count.should == 2
|
39
|
+
user.keys.create(name: "mykey3", key: "sshkey3")
|
40
|
+
user.keys.count.should == 3
|
41
|
+
end
|
42
|
+
|
43
|
+
it "can be admin" do
|
44
|
+
user = User.create(login: 'user', admin: true)
|
45
|
+
user.should be_admin
|
46
|
+
user = User.create(login: 'user')
|
47
|
+
user.should_not be_admin
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should add READ access to a reporitory" do
|
51
|
+
user = User.create(login: 'user')
|
52
|
+
repo = Repository.create(name:'myrepo', path: 'path')
|
53
|
+
user.add_access(repo, :read).should be_true
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should add WRTIE access to a reporitory" do
|
57
|
+
user = User.create(login: 'user')
|
58
|
+
repo = Repository.create(name:'myrepo', path: 'path')
|
59
|
+
user.add_access(repo, :write).should be_true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not add an UNKNOWN access to a repository" do
|
63
|
+
user = User.create(login: 'user')
|
64
|
+
repo = Repository.create(name:'myrepo', path: 'path')
|
65
|
+
user.add_access(repo, :wrong).should be_false
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should remove READ access to a reporitory" do
|
69
|
+
user = User.create(login: 'user')
|
70
|
+
repo = Repository.create(name:'myrepo', path: 'path')
|
71
|
+
user.remove_access(repo, :read).should be_true
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should remove WRTIE access to a reporitory" do
|
75
|
+
user = User.create(login: 'user')
|
76
|
+
repo = Repository.create(name:'myrepo', path: 'path')
|
77
|
+
user.remove_access(repo, :write).should be_true
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should check READ access" do
|
81
|
+
user = User.create(login: 'user')
|
82
|
+
repo = Repository.create(name:'myrepo', path: 'path')
|
83
|
+
user.check_access(repo, :read).should be_false
|
84
|
+
user.add_access(repo, :read).should be_true
|
85
|
+
user.check_access(repo, :read).should be_true
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should check WRITE access" do
|
89
|
+
user = User.create(login: 'user')
|
90
|
+
repo = Repository.create(name:'myrepo', path: 'path')
|
91
|
+
user.check_access(repo, :write).should be_false
|
92
|
+
user.add_access(repo, :write).should be_true
|
93
|
+
user.check_access(repo, :write).should be_true
|
94
|
+
end
|
9
95
|
end
|
10
|
-
|
11
|
-
it 'should have a unique login' do
|
12
|
-
user1 = Gritano::User.create(login: 'test')
|
13
|
-
user2 = Gritano::User.new(login: 'test')
|
14
|
-
user2.should be_invalid
|
15
|
-
end
|
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
|
-
|
27
|
-
it 'should add read access to a repository' do
|
28
|
-
user = Gritano::User.create(login: 'test')
|
29
|
-
repo = Gritano::Repository.create(name: 'tmp/repo.git')
|
30
|
-
user.add_access(repo, :read).should be_true
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should add write access to a repository' do
|
34
|
-
user = Gritano::User.create(login: 'test')
|
35
|
-
repo = Gritano::Repository.create(name: 'tmp/repo.git')
|
36
|
-
user.add_access(repo, :read).should be_true
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should not add an wrong type access to a repository' do
|
40
|
-
user = Gritano::User.create(login: 'test')
|
41
|
-
repo = Gritano::Repository.create(name: 'tmp/repo.git')
|
42
|
-
user.add_access(repo, :wrong).should be_false
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should not remove an wrong type access to a repository' do
|
46
|
-
user = Gritano::User.create(login: 'test')
|
47
|
-
repo = Gritano::Repository.create(name: 'tmp/repo.git')
|
48
|
-
user.remove_access(repo, :wrong).should be_false
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should not have read access to a repository' do
|
52
|
-
user = Gritano::User.create(login: 'test')
|
53
|
-
repo = Gritano::Repository.create(name: 'tmp/repo.git')
|
54
|
-
user.check_access(repo, :read).should be_false
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should not have write access to a repository' do
|
58
|
-
user = Gritano::User.create(login: 'test')
|
59
|
-
repo = Gritano::Repository.create(name: 'tmp/repo.git')
|
60
|
-
user.check_access(repo, :write).should be_false
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should not have wrong access to a repository' do
|
64
|
-
user = Gritano::User.create(login: 'test')
|
65
|
-
repo = Gritano::Repository.create(name: 'tmp/repo.git')
|
66
|
-
user.check_access(repo, :wrong).should be_false
|
67
|
-
end
|
68
|
-
end
|
96
|
+
end
|
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.5.
|
4
|
+
version: 0.5.4
|
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: 2013-01-
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -350,6 +350,7 @@ files:
|
|
350
350
|
- features/data/remote_commands/repo_list_jessicaeto.txt
|
351
351
|
- features/data/remote_commands/version_igorbonadio.txt
|
352
352
|
- features/data/remote_commands/version_jessicaeto.txt
|
353
|
+
- features/data/remote_help.txt
|
353
354
|
- features/install.feature
|
354
355
|
- features/local.feature
|
355
356
|
- features/remote.feature
|
@@ -373,10 +374,16 @@ files:
|
|
373
374
|
- lib/gritano/models/permission.rb
|
374
375
|
- lib/gritano/models/repository.rb
|
375
376
|
- lib/gritano/models/user.rb
|
376
|
-
- spec/
|
377
|
-
- spec/
|
378
|
-
- spec/
|
377
|
+
- spec/cli_spec.rb
|
378
|
+
- spec/console_base_spec.rb
|
379
|
+
- spec/console_executor_spec.rb
|
380
|
+
- spec/console_gritano_spec.rb
|
381
|
+
- spec/console_installer_spec.rb
|
382
|
+
- spec/console_remote_spec.rb
|
383
|
+
- spec/console_spec.rb
|
384
|
+
- spec/data/help_command_name.txt
|
379
385
|
- spec/model_key_spec.rb
|
386
|
+
- spec/model_permission_spec.rb
|
380
387
|
- spec/model_repository_spec.rb
|
381
388
|
- spec/model_user_spec.rb
|
382
389
|
- spec/spec_helper.rb
|
@@ -396,7 +403,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
396
403
|
version: '0'
|
397
404
|
segments:
|
398
405
|
- 0
|
399
|
-
hash:
|
406
|
+
hash: 2897713572517477431
|
400
407
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
401
408
|
none: false
|
402
409
|
requirements:
|
data/spec/executor_spec.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Gritano::Console::Executor do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
stdin = double()
|
7
|
-
stdin.stub(:read).and_return("Your SSHKEY here...")
|
8
|
-
@console = Gritano::Console::Executor.new(stdin)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should respond to gritano user:add igorbonadio" do
|
12
|
-
@console.should_receive(:user_add)
|
13
|
-
@console.execute_without_filters("user:add igorbonadio".split(' '))
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should respond to gritano user:rm igorbonadio" do
|
17
|
-
@console.should_receive(:user_rm)
|
18
|
-
@console.execute_without_filters("user:rm igorbonadio".split(' '))
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should respond to gritano user:key:add username keyname < key.pub" do
|
22
|
-
@console.should_receive(:user_key_add)
|
23
|
-
@console.execute_without_filters("user:key:add igorbonadio keyname".split(' '))
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should respond to gritano user:key:rm username keyname" do
|
27
|
-
@console.should_receive(:user_key_rm)
|
28
|
-
@console.execute_without_filters("user:key:rm username keyname".split(' '))
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should respond to gritano user:list" do
|
32
|
-
@console.should_receive(:user_list)
|
33
|
-
@console.execute_without_filters("user:list".split(' '))
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should respond to gritano user:key:list username" do
|
37
|
-
@console.should_receive(:user_key_list)
|
38
|
-
@console.execute_without_filters("user:key:list username".split(' '))
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should respond to gritano user:repo:list username" do
|
42
|
-
@console.should_receive(:user_repo_list)
|
43
|
-
@console.execute_without_filters("user:repo:list username".split(' '))
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should respond to gritano repo:user:list reponame.git" do
|
47
|
-
@console.should_receive(:repo_user_list)
|
48
|
-
@console.execute_without_filters("repo:user:list reponame.git".split(' '))
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should respond to gritano user:admin:add igorbonadio" do
|
52
|
-
@console.should_receive(:user_admin_add)
|
53
|
-
@console.execute_without_filters("user:admin:add igorbonadio".split(' '))
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should respond to gritano user:admin:rm igorbonadio" do
|
57
|
-
@console.should_receive(:user_admin_rm)
|
58
|
-
@console.execute_without_filters("user:admin:rm igorbonadio".split(' '))
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should respond to gritano repo:add tmp/reponame.git" do
|
62
|
-
@console.should_receive(:repo_add)
|
63
|
-
@console.execute_without_filters("repo:add tmp/reponame.git".split(' '))
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should respond to gritano repo:rm tmp/reponame.git" do
|
67
|
-
@console.should_receive(:repo_rm)
|
68
|
-
@console.execute_without_filters("repo:rm tmp/reponame.git".split(' '))
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should respond to gritano repo:read:add igorbonadio tmp/reponame.git" do
|
72
|
-
@console.should_receive(:repo_read_add)
|
73
|
-
@console.execute_without_filters("repo:read:add igorbonadio tmp/reponame.git".split(' '))
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should respond to gritano repo:write:add igorbonadio tmp/reponame.git" do
|
77
|
-
@console.should_receive(:repo_write_add)
|
78
|
-
@console.execute_without_filters("repo:write:add igorbonadio tmp/reponame.git".split(' '))
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should respond to gritano repo:read:rm igorbonadio tmp/reponame.git" do
|
82
|
-
@console.should_receive(:repo_read_rm)
|
83
|
-
@console.execute_without_filters("repo:read:rm igorbonadio tmp/reponame.git".split(' '))
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should respond to gritano repo:write:rm igorbonadio tmp/reponame.git" do
|
87
|
-
@console.should_receive(:repo_write_rm)
|
88
|
-
@console.execute_without_filters("repo:write:rm igorbonadio tmp/reponame.git".split(' '))
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should respond to gritano repo:list" do
|
92
|
-
@console.should_receive(:repo_list)
|
93
|
-
@console.execute_without_filters("repo:list".split(' '))
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should respond to gritano help" do
|
97
|
-
@console.should_receive(:help)
|
98
|
-
@console.execute_without_filters("help".split(' '))
|
99
|
-
end
|
100
|
-
end
|
data/spec/gritano_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Gritano::Console::Gritano do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
stdin = double()
|
7
|
-
stdin.stub(:read).and_return("Your SSHKEY here...")
|
8
|
-
@console = Gritano::Console::Gritano.new(stdin)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should respond to gritano version" do
|
12
|
-
@console.should_receive(:version)
|
13
|
-
@console.execute("version".split(' '))
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should respond to gritano help" do
|
17
|
-
@console.should_receive(:help)
|
18
|
-
@console.execute("help".split(' '))
|
19
|
-
end
|
20
|
-
end
|
data/spec/installer_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Gritano::Console::Installer do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@console = Gritano::Console::Installer.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should respond to gritano setup:prepare" do
|
10
|
-
@console.should_receive(:setup_prepare)
|
11
|
-
@console.execute("setup:prepare".split(' '))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should respond to gritano setup:install" do
|
15
|
-
@console.should_receive(:setup_install)
|
16
|
-
@console.execute("setup:install".split(' '))
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should respond to gritano help" do
|
20
|
-
@console.should_receive(:help)
|
21
|
-
@console.execute("help".split(' '))
|
22
|
-
end
|
23
|
-
end
|