gritano 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- = Gritano v0.1.6
1
+ = Gritano v0.1.7
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
 
@@ -25,7 +25,7 @@ After that you can add users:
25
25
 
26
26
  add user's public keys:
27
27
 
28
- $ gritano user +key igorbonadio mykey id_rsa.pub
28
+ $ gritano user +key igorbonadio mykey < id_rsa.pub
29
29
 
30
30
  create bare repositories:
31
31
 
data/TODO CHANGED
@@ -9,7 +9,7 @@ v0.3.0
9
9
  - acesso administrativo via ssh
10
10
  ssh git@host.com user add username
11
11
  ssh git@host.com user rm username
12
- ssh git@host.com user +key username keyname key.pub
12
+ ssh git@host.com user +key username keyname < key.pub
13
13
  ssh git@host.com user -key username keyname
14
14
  ssh git@host.com repo add reponame.git
15
15
  ssh git@host.com repo rm reponame.git
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
@@ -14,7 +14,7 @@ def help
14
14
  gritano install
15
15
  gritano user add username
16
16
  gritano user rm username
17
- gritano user +key username keyname key.pub
17
+ gritano user +key username keyname < key.pub
18
18
  gritano user -key username keyname
19
19
  gritano user list
20
20
  gritano user keys username
@@ -75,7 +75,7 @@ elsif ARGV.length == 0
75
75
  else
76
76
  check_gritano
77
77
  ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(Etc.getpwuid.dir, '.gritano', 'database.yml'))))
78
- console = Gritano::Console.new
78
+ console = Gritano::Console.new(STDIN)
79
79
  console.repo_path = Etc.getpwuid.dir
80
80
  console.ssh_path = File.join(Etc.getpwuid.dir, '.ssh')
81
81
  begin
@@ -34,7 +34,7 @@ Feature: Console operations
34
34
  Examples:
35
35
  | command | message |
36
36
  | user add jose | success |
37
- | user +key igorbonadio marvin features/data/keys/igorbonadio.pub | success |
37
+ | user +key igorbonadio marvin | success |
38
38
  | user -key igorbonadio eva | success |
39
39
  | user rm igorbonadio | success |
40
40
  | user list | success |
@@ -50,7 +50,7 @@ Feature: Console operations
50
50
  | repo users tmp/jeka.git | success |
51
51
  | user add igorbonadio | error |
52
52
  | user rm jose | error |
53
- | user +key igorbonadio marvin features/data/keys/arybonadio.pub | error |
53
+ | user +key userrr marvino | error |
54
54
  | user -key igorbonadio marvino | error |
55
55
  | user keys arybonadio | error |
56
56
  | user repos arybonadio | error |
@@ -1,5 +1,13 @@
1
+ class FakeSTDIN
2
+ def read
3
+ "Your SSHKEY here..."
4
+ end
5
+ end
6
+
1
7
  Given /^I start the gritano console$/ do
2
- @console = Gritano::Console.new
8
+ stdin = double()
9
+ stdin.stub(:read).and_return("Your SSHKEY here...")
10
+ @console = Gritano::Console.new(stdin)
3
11
  @console.ssh_path = 'tmp'
4
12
  end
5
13
 
@@ -17,6 +17,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
17
17
  require 'gritano'
18
18
 
19
19
  require 'rspec/expectations'
20
+ require 'cucumber/rspec/doubles'
20
21
 
21
22
  require 'active_record'
22
23
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gritano"
8
- s.version = "0.1.6"
8
+ s.version = "0.1.7"
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-10-30"
12
+ s.date = "2012-11-02"
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"]
@@ -4,9 +4,10 @@ module Gritano
4
4
  attr_accessor :repo_path
5
5
  attr_accessor :ssh_path
6
6
 
7
- def initialize
7
+ def initialize(stdin)
8
8
  @repo_path = nil
9
9
  @ssh_path = nil
10
+ @stdin = stdin
10
11
  end
11
12
 
12
13
  def execute(argv)
@@ -164,13 +165,11 @@ module Gritano
164
165
  def user_add_key(argv)
165
166
  login, key_name, key_file = argv
166
167
  user = User.find_by_login(login)
167
- if File.exist?(key_file)
168
- if user
169
- key = user.keys.create(name: key_name, key: File.open(key_file).readlines.join)
170
- if key.valid?
171
- File.open(File.join(@ssh_path, 'authorized_keys'), 'w').write(Key.authorized_keys)
168
+ if user
169
+ key = user.keys.create(name: key_name, key: @stdin.read)
170
+ if key.valid?
171
+ File.open(File.join(@ssh_path, 'authorized_keys'), 'w').write(Key.authorized_keys)
172
172
  return [true, "Key added successfully."]
173
- end
174
173
  end
175
174
  end
176
175
  return [false, "Key could not be added."]
@@ -1,51 +1,85 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe Gritano::Console do
4
+
5
+ before(:each) do
6
+ stdin = double()
7
+ stdin.stub(:read).and_return("Your SSHKEY here...")
8
+ @console = Gritano::Console.new(stdin)
9
+ end
10
+
4
11
  it "should respond to gritano user add igorbonadio" do
5
- console = Gritano::Console.new
6
- console.should_receive(:user_add)
7
- console.execute("user add igorbonadio".split(' '))
12
+ @console.should_receive(:user_add)
13
+ @console.execute("user add igorbonadio".split(' '))
8
14
  end
9
15
 
10
16
  it "should respond to gritano user rm igorbonadio" do
11
- console = Gritano::Console.new
12
- console.should_receive(:user_rm)
13
- console.execute("user rm igorbonadio".split(' '))
17
+ @console.should_receive(:user_rm)
18
+ @console.execute("user rm igorbonadio".split(' '))
19
+ end
20
+
21
+ it "should respond to gritano user +key username keyname < key.pub" do
22
+ @console.should_receive(:user_add_key)
23
+ @console.execute("user +key igorbonadio keyname".split(' '))
24
+ end
25
+
26
+ it "should respond to gritano user -key username keyname" do
27
+ @console.should_receive(:user_remove_key)
28
+ @console.execute("user -key username keyname".split(' '))
29
+ end
30
+
31
+ it "should respond to gritano user list" do
32
+ @console.should_receive(:user_list)
33
+ @console.execute("user list".split(' '))
34
+ end
35
+
36
+ it "should respond to gritano user keys username" do
37
+ @console.should_receive(:user_keys)
38
+ @console.execute("user keys username".split(' '))
39
+ end
40
+
41
+ it "should respond to gritano user repos username" do
42
+ @console.should_receive(:user_repos)
43
+ @console.execute("user repos username".split(' '))
14
44
  end
15
45
 
16
46
  it "should respond to gritano repo add tmp/reponame.git" do
17
- console = Gritano::Console.new
18
- console.should_receive(:repo_add)
19
- console.execute("repo add tmp/reponame.git".split(' '))
47
+ @console.should_receive(:repo_add)
48
+ @console.execute("repo add tmp/reponame.git".split(' '))
20
49
  end
21
50
 
22
51
  it "should respond to gritano repo rm tmp/reponame.git" do
23
- console = Gritano::Console.new
24
- console.should_receive(:repo_rm)
25
- console.execute("repo rm tmp/reponame.git".split(' '))
52
+ @console.should_receive(:repo_rm)
53
+ @console.execute("repo rm tmp/reponame.git".split(' '))
26
54
  end
27
55
 
28
56
  it "should respond to gritano repo +read igorbonadio tmp/reponame.git" do
29
- console = Gritano::Console.new
30
- console.should_receive(:repo_add_read)
31
- console.execute("repo +read igorbonadio tmp/reponame.git".split(' '))
57
+ @console.should_receive(:repo_add_read)
58
+ @console.execute("repo +read igorbonadio tmp/reponame.git".split(' '))
32
59
  end
33
60
 
34
61
  it "should respond to gritano repo +write igorbonadio tmp/reponame.git" do
35
- console = Gritano::Console.new
36
- console.should_receive(:repo_add_write)
37
- console.execute("repo +write igorbonadio tmp/reponame.git".split(' '))
62
+ @console.should_receive(:repo_add_write)
63
+ @console.execute("repo +write igorbonadio tmp/reponame.git".split(' '))
38
64
  end
39
65
 
40
66
  it "should respond to gritano repo -read igorbonadio tmp/reponame.git" do
41
- console = Gritano::Console.new
42
- console.should_receive(:repo_remove_read)
43
- console.execute("repo -read igorbonadio tmp/reponame.git".split(' '))
67
+ @console.should_receive(:repo_remove_read)
68
+ @console.execute("repo -read igorbonadio tmp/reponame.git".split(' '))
44
69
  end
45
70
 
46
71
  it "should respond to gritano repo -write igorbonadio tmp/reponame.git" do
47
- console = Gritano::Console.new
48
- console.should_receive(:repo_remove_write)
49
- console.execute("repo -write igorbonadio tmp/reponame.git".split(' '))
72
+ @console.should_receive(:repo_remove_write)
73
+ @console.execute("repo -write igorbonadio tmp/reponame.git".split(' '))
74
+ end
75
+
76
+ it "should respond to gritano repo list" do
77
+ @console.should_receive(:repo_list)
78
+ @console.execute("repo list".split(' '))
79
+ end
80
+
81
+ it "should respond to gritano repo users reponame.git" do
82
+ @console.should_receive(:repo_users)
83
+ @console.execute("repo users reponame.git".split(' '))
50
84
  end
51
85
  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.1.6
4
+ version: 0.1.7
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-10-30 00:00:00.000000000 Z
12
+ date: 2012-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -245,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
245
  version: '0'
246
246
  segments:
247
247
  - 0
248
- hash: 1774883244443288831
248
+ hash: -1916713309401243545
249
249
  required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  none: false
251
251
  requirements: