gritano 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -17
- data/Gemfile.lock +78 -50
- data/Guardfile +9 -0
- data/README.rdoc +23 -24
- data/Rakefile +8 -12
- data/TODO +12 -8
- data/VERSION +1 -1
- data/bin/gritano +8 -1
- data/bin/gritano-remote +16 -2
- data/gritano.gemspec +52 -230
- data/lib/gritano.rb +12 -6
- data/lib/gritano/config.rb +11 -31
- data/lib/gritano/console/base.rb +6 -74
- data/lib/gritano/console/git.rb +29 -0
- data/lib/gritano/console/local.rb +131 -0
- data/lib/gritano/console/remote.rb +47 -93
- data/lib/gritano/core/key.rb +18 -0
- data/lib/gritano/core/user.rb +12 -0
- data/lib/gritano/helpers.rb +52 -0
- data/lib/gritano/renderer.rb +36 -0
- data/lib/gritano/thor.rb +27 -0
- data/spec/data/development.yml +2 -0
- data/spec/gritano/console/git_spec.rb +55 -0
- data/spec/gritano/console/local_spec.rb +148 -0
- data/spec/gritano/console/remote_spec.rb +56 -0
- data/spec/gritano/core/key_spec.rb +21 -0
- data/spec/gritano/core/user_spec.rb +43 -0
- data/spec/gritano/helpers_spec.rb +113 -0
- data/spec/gritano/thor_spec.rb +29 -0
- data/spec/spec_helper.rb +1 -16
- data/templates/local.gritano +4 -0
- data/templates/remote.gritano +5 -0
- metadata +61 -280
- data/.gritano/config.yml +0 -2
- data/.gritano/database.yml +0 -2
- data/.ssh/.gitignore +0 -4
- data/bin/gritano-pub-key +0 -15
- data/db/migrate/001_create_users.rb +0 -8
- data/db/migrate/002_create_repositories.rb +0 -9
- data/db/migrate/003_create_permissions.rb +0 -10
- data/db/migrate/004_create_keys.rb +0 -11
- data/db/migrate/005_add_admin_to_users.rb +0 -10
- data/db/migrate/006_add_email_to_users.rb +0 -10
- data/db/migrate/007_add_password_to_users.rb +0 -10
- data/db/migrate/008_remove_password_from_user.rb +0 -10
- data/db/migrate/009_remove_email_from_users.rb +0 -10
- data/features/data/config_true.yml +0 -2
- data/features/data/local_commands/repo_add_tmp_jeka_git.txt +0 -1
- data/features/data/local_commands/repo_add_tmp_p_lang_git.txt +0 -1
- data/features/data/local_commands/repo_add_tmp_p_lang_git_igorbonadio.txt +0 -1
- data/features/data/local_commands/repo_add_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/local_commands/repo_list.txt +0 -6
- data/features/data/local_commands/repo_read_add_tmp_gritano_git_arybonadio.txt +0 -1
- data/features/data/local_commands/repo_read_add_tmp_gritano_git_jessicaeto.txt +0 -1
- data/features/data/local_commands/repo_read_add_tmp_p_lang_git_jessicaeto.txt +0 -1
- data/features/data/local_commands/repo_read_rm_tmp_jeka_git_aribonadio.txt +0 -1
- data/features/data/local_commands/repo_read_rm_tmp_jeka_git_igorbonadio.txt +0 -1
- data/features/data/local_commands/repo_read_rm_tmp_p_lang_git_igorbonadio.txt +0 -1
- data/features/data/local_commands/repo_rm_tmp_jeka_git.txt +0 -1
- data/features/data/local_commands/repo_rm_tmp_p_lang_git.txt +0 -1
- data/features/data/local_commands/repo_user_list_tmp_jeka_git.txt +0 -6
- data/features/data/local_commands/repo_user_list_tmp_ruby_git.txt +0 -1
- data/features/data/local_commands/repo_write_add_tmp_gritano_git_arybonadio.txt +0 -1
- data/features/data/local_commands/repo_write_add_tmp_gritano_git_jessicaeto.txt +0 -1
- data/features/data/local_commands/repo_write_add_tmp_p_lang_git_jessicaeto.txt +0 -1
- data/features/data/local_commands/repo_write_rm_tmp_gritano_git_arybonadio.txt +0 -1
- data/features/data/local_commands/repo_write_rm_tmp_gritano_git_igorbonadio.txt +0 -1
- data/features/data/local_commands/repo_write_rm_tmp_p_lang_git_igorbonadio.txt +0 -1
- data/features/data/local_commands/user_add_igorbonadio.txt +0 -1
- data/features/data/local_commands/user_add_jose.txt +0 -1
- data/features/data/local_commands/user_admin_add_arybonadio.txt +0 -1
- data/features/data/local_commands/user_admin_add_igorbonadio.txt +0 -1
- data/features/data/local_commands/user_admin_rm_arybonadio.txt +0 -1
- data/features/data/local_commands/user_admin_rm_igorbonadio.txt +0 -1
- data/features/data/local_commands/user_key_add_igorbonadio_marvin.txt +0 -1
- data/features/data/local_commands/user_key_add_userrr_marvino.txt +0 -1
- data/features/data/local_commands/user_key_list_arybonadio.txt +0 -1
- data/features/data/local_commands/user_key_list_igorbonadio.txt +0 -5
- data/features/data/local_commands/user_key_rm_igorbonadio_eva.txt +0 -1
- data/features/data/local_commands/user_key_rm_igorbonadio_marvino.txt +0 -1
- data/features/data/local_commands/user_list.txt +0 -6
- data/features/data/local_commands/user_repo_list_arybonadio.txt +0 -1
- data/features/data/local_commands/user_repo_list_igorbonadio.txt +0 -6
- data/features/data/local_commands/user_rm_igorbonadio.txt +0 -1
- data/features/data/local_commands/user_rm_jose.txt +0 -1
- data/features/data/local_commands/version.txt +0 -1
- data/features/data/local_help.txt +0 -32
- data/features/data/remote_commands/admin_help_igorbonadio.txt +0 -32
- data/features/data/remote_commands/admin_help_jessicaeto.txt +0 -32
- data/features/data/remote_commands/admin_repo_add_tmp_jeka_git_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_add_tmp_jeka_git_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_jessicaeto_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_jessicaeto_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_list_igorbonadio.txt +0 -6
- data/features/data/remote_commands/admin_repo_list_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_arybonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_arybonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_jessicaeto_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_jessicaeto_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_add_tmp_p_lang_git_jessicaeto_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_add_tmp_p_lang_git_jessicaeto_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_aribonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_aribonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_rm_tmp_p_lang_git_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_read_rm_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_rm_tmp_jeka_git_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_rm_tmp_jeka_git_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_rm_tmp_p_lang_git_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_rm_tmp_p_lang_git_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_user_list_tmp_jeka_git_igorbonadio.txt +0 -6
- data/features/data/remote_commands/admin_repo_user_list_tmp_jeka_git_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_user_list_tmp_ruby_git_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_user_list_tmp_ruby_git_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_arybonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_arybonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_jessicaeto_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_jessicaeto_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_add_tmp_p_lang_git_jessicaeto_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_add_tmp_p_lang_git_jessicaeto_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_arybonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_arybonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_rm_tmp_p_lang_git_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_repo_write_rm_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_add_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_add_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_add_jose_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_add_jose_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_add_arybonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_add_arybonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_add_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_add_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_rm_arybonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_rm_arybonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_rm_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_admin_rm_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_key_add_igorbonadio_marvin_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_key_add_igorbonadio_marvin_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_key_add_userrr_marvino_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_key_add_userrr_marvino_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_key_list_arybonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_key_list_arybonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_key_list_igorbonadio_igorbonadio.txt +0 -5
- data/features/data/remote_commands/admin_user_key_list_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_key_rm_igorbonadio_eva_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_key_rm_igorbonadio_eva_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_key_rm_igorbonadio_marvino_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_key_rm_igorbonadio_marvino_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_list_igorbonadio.txt +0 -6
- data/features/data/remote_commands/admin_user_list_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_repo_list_arybonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_repo_list_arybonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_repo_list_igorbonadio_igorbonadio.txt +0 -6
- data/features/data/remote_commands/admin_user_repo_list_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_rm_igorbonadio_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_rm_igorbonadio_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_user_rm_jose_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_user_rm_jose_jessicaeto.txt +0 -1
- data/features/data/remote_commands/admin_version_igorbonadio.txt +0 -1
- data/features/data/remote_commands/admin_version_jessicaeto.txt +0 -1
- data/features/data/remote_commands/email_get_igorbonadio.txt +0 -1
- data/features/data/remote_commands/email_get_jessicaeto.txt +0 -1
- data/features/data/remote_commands/email_update_email@server_com_igorbonadio.txt +0 -1
- data/features/data/remote_commands/email_update_email@server_com_jessicaeto.txt +0 -1
- data/features/data/remote_commands/help_igorbonadio.txt +0 -14
- data/features/data/remote_commands/help_jessicaeto.txt +0 -14
- data/features/data/remote_commands/invalid_command_igorbonadio.txt +0 -14
- data/features/data/remote_commands/invalid_command_jessicaeto.txt +0 -14
- data/features/data/remote_commands/key_add_keyname_igorbonadio.txt +0 -1
- data/features/data/remote_commands/key_add_keyname_jessicaeto.txt +0 -1
- data/features/data/remote_commands/key_list_igorbonadio.txt +0 -5
- data/features/data/remote_commands/key_list_jessicaeto.txt +0 -5
- data/features/data/remote_commands/key_rm_hal_igorbonadio.txt +0 -1
- data/features/data/remote_commands/key_rm_hal_jessicaeto.txt +0 -1
- data/features/data/remote_commands/repo_list_igorbonadio.txt +0 -6
- data/features/data/remote_commands/repo_list_jessicaeto.txt +0 -5
- data/features/data/remote_commands/version_igorbonadio.txt +0 -1
- data/features/data/remote_commands/version_jessicaeto.txt +0 -1
- data/features/data/remote_help.txt +0 -14
- data/features/install.feature +0 -40
- data/features/local.feature +0 -80
- data/features/pub_key.feature +0 -25
- data/features/remote.feature +0 -150
- data/features/step_definitions/background_step.rb +0 -26
- data/features/step_definitions/install_step.rb +0 -30
- data/features/step_definitions/local_step.rb +0 -25
- data/features/step_definitions/pub_key_step.rb +0 -15
- data/features/step_definitions/remote_step.rb +0 -49
- data/features/support/database_cleaner.rb +0 -15
- data/features/support/env.rb +0 -30
- data/lib/gritano/cli.rb +0 -49
- data/lib/gritano/console.rb +0 -26
- data/lib/gritano/console/executor.rb +0 -298
- data/lib/gritano/console/gritano.rb +0 -35
- data/lib/gritano/console/installer.rb +0 -55
- data/lib/gritano/models.rb +0 -7
- data/lib/gritano/models/key.rb +0 -37
- data/lib/gritano/models/permission.rb +0 -39
- data/lib/gritano/models/repository.rb +0 -29
- data/lib/gritano/models/user.rb +0 -39
- data/spec/cli_spec.rb +0 -26
- data/spec/config_spec.rb +0 -64
- data/spec/console_base_spec.rb +0 -61
- data/spec/console_executor_spec.rb +0 -183
- data/spec/console_gritano_spec.rb +0 -121
- data/spec/console_installer_spec.rb +0 -28
- data/spec/console_remote_spec.rb +0 -70
- data/spec/console_spec.rb +0 -27
- data/spec/data/help_command_name.txt +0 -7
- data/spec/model_key_spec.rb +0 -44
- data/spec/model_permission_spec.rb +0 -72
- data/spec/model_repository_spec.rb +0 -56
- data/spec/model_user_spec.rb +0 -96
@@ -1,29 +0,0 @@
|
|
1
|
-
module Gritano
|
2
|
-
class Repository < ActiveRecord::Base
|
3
|
-
validates :name, presence: true
|
4
|
-
validates_uniqueness_of :name
|
5
|
-
|
6
|
-
has_many :permissions
|
7
|
-
has_many :users, through: :permissions
|
8
|
-
|
9
|
-
before_create :create_bare_repo
|
10
|
-
after_destroy :destroy_bare_repo
|
11
|
-
|
12
|
-
def create_bare_repo
|
13
|
-
Grit::Repo.init_bare(full_path)
|
14
|
-
end
|
15
|
-
|
16
|
-
def destroy_bare_repo
|
17
|
-
FileUtils.rm_r(full_path, force: true)
|
18
|
-
end
|
19
|
-
|
20
|
-
def full_path
|
21
|
-
if path
|
22
|
-
File.join(path, name)
|
23
|
-
else
|
24
|
-
name
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
data/lib/gritano/models/user.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'bcrypt'
|
2
|
-
|
3
|
-
module Gritano
|
4
|
-
class User < ActiveRecord::Base
|
5
|
-
include BCrypt
|
6
|
-
|
7
|
-
validates :login, presence: true
|
8
|
-
validates_uniqueness_of :login
|
9
|
-
|
10
|
-
has_many :permissions
|
11
|
-
has_many :repositories, through: :permissions
|
12
|
-
has_many :keys
|
13
|
-
|
14
|
-
def add_access(repo, access)
|
15
|
-
change_access(repo, "add", access)
|
16
|
-
end
|
17
|
-
|
18
|
-
def remove_access(repo, access)
|
19
|
-
change_access(repo, "remove", access)
|
20
|
-
end
|
21
|
-
|
22
|
-
def change_access(repo, op, access)
|
23
|
-
permission = Permission.find_by_user_id_and_repository_id(self.id, repo.id) || Permission.new
|
24
|
-
permission.user_id = self.id
|
25
|
-
permission.repository_id = repo.id
|
26
|
-
if permission.send("#{op}_access", access)
|
27
|
-
return permission.save
|
28
|
-
else
|
29
|
-
return false
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def check_access(repo, access)
|
34
|
-
permission = Permission.find_by_user_id_and_repository_id(self.id, repo.id)
|
35
|
-
return permission.is(access) if permission
|
36
|
-
return false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/spec/cli_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Gritano
|
4
|
-
describe CLI do
|
5
|
-
it "should execute local commands" do
|
6
|
-
console = double()
|
7
|
-
console.should_receive(:execute).and_return([true, "ok"])
|
8
|
-
Gritano::Console.should_receive(:remote_console).with(false, Etc.getpwuid.dir)
|
9
|
-
Gritano::Console::Gritano.should_receive(:new).and_return(console)
|
10
|
-
CLI.execute(["user:list"])
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should execute remote commands" do
|
14
|
-
console = double()
|
15
|
-
console.should_receive(:execute).and_return([true, "ok"])
|
16
|
-
Gritano::Console.should_receive(:remote_console).with(true, Etc.getpwuid.dir)
|
17
|
-
Gritano::Console::Remote.should_receive(:new).and_return(console)
|
18
|
-
CLI.check(["repo:list"], "login")
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should check public keys" do
|
22
|
-
Key.should_receive(:find_by_key).and_return(nil)
|
23
|
-
CLI.check_pub_key("key", ".")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/config_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Gritano
|
4
|
-
describe Config do
|
5
|
-
it "should get parameters" do
|
6
|
-
config = Config.new(File.join(".gritano", "config.yml"))
|
7
|
-
config.host_url.should be == "gritano.org"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should add parameters" do
|
11
|
-
FileUtils.mkdir_p('tmp')
|
12
|
-
if File.exist?(File.join("tmp", "config_test.yml"))
|
13
|
-
FileUtils.rm(File.join("tmp", "config_test.yml"))
|
14
|
-
end
|
15
|
-
config = Config.new(File.join("tmp", "config_test.yml"))
|
16
|
-
config.host_url.should be == "undefined"
|
17
|
-
config.host_url = "gritano.org"
|
18
|
-
config.host_url.should be == "gritano.org"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should remove parameters" do
|
22
|
-
FileUtils.mkdir_p('tmp')
|
23
|
-
if File.exist?(File.join("tmp", "config_test.yml"))
|
24
|
-
FileUtils.rm(File.join("tmp", "config_test.yml"))
|
25
|
-
end
|
26
|
-
config = Config.new(File.join("tmp", "config_test.yml"))
|
27
|
-
|
28
|
-
config.host_url = "gritano.org"
|
29
|
-
config.host_url.should be == "gritano.org"
|
30
|
-
|
31
|
-
config.remove(:host_url)
|
32
|
-
config.host_url.should be == "undefined"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should modify parameters" do
|
36
|
-
FileUtils.mkdir_p('tmp')
|
37
|
-
if File.exist?(File.join("tmp", "config_test.yml"))
|
38
|
-
FileUtils.rm(File.join("tmp", "config_test.yml"))
|
39
|
-
end
|
40
|
-
config = Config.new(File.join("tmp", "config_test.yml"))
|
41
|
-
config.host_url.should be == "undefined"
|
42
|
-
config.host_url = "gritano.org"
|
43
|
-
config.host_url.should be == "gritano.org"
|
44
|
-
config.host_url = "host.org"
|
45
|
-
config.host_url.should be == "host.org"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should save a config file" do
|
49
|
-
FileUtils.mkdir_p('tmp')
|
50
|
-
if File.exist?(File.join("tmp", "config_test.yml"))
|
51
|
-
FileUtils.rm(File.join("tmp", "config_test.yml"))
|
52
|
-
end
|
53
|
-
config = Config.new(File.join("tmp", "config_test.yml"))
|
54
|
-
config.host_url = "gritano.org"
|
55
|
-
config.email = {login: 'igor', smtp: 'smtp.igor.com'}
|
56
|
-
config.save
|
57
|
-
|
58
|
-
config2 = Config.new(File.join("tmp", "config_test.yml"))
|
59
|
-
config2.host_url.should be == "gritano.org"
|
60
|
-
config2.email[:login].should be == "igor"
|
61
|
-
config2.email[:smtp].should be == "smtp.igor.com"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/spec/console_base_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Gritano
|
4
|
-
module Console
|
5
|
-
describe Base do
|
6
|
-
def create_base(home)
|
7
|
-
stdin = double()
|
8
|
-
stdin.stub(:read).and_return("Your SSHKEY here...")
|
9
|
-
Base.new(stdin, home)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should define commands" do
|
13
|
-
Base.should_receive(:define_method).with("command_name")
|
14
|
-
Base.add_command "command:name", "parameters" do end
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should execute commands" do
|
18
|
-
Base.add_command "command:name", "parameters" do end
|
19
|
-
base = create_base('.')
|
20
|
-
base.should_receive('command_name')
|
21
|
-
base.execute(['command:name'])
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should show a help message" do
|
25
|
-
Base.add_command "command:name", "parameters" do end
|
26
|
-
Base.help.should == File.open("spec/data/help_command_name.txt").readlines.join.
|
27
|
-
gsub('{{VERSION}}', File.open("VERSION").readlines.join)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should check if gritano is not installed" do
|
31
|
-
FileUtils.rm_rf(File.join("tmp", ".gritano"))
|
32
|
-
base = create_base('tmp')
|
33
|
-
lambda { base.check_gritano }.should raise_error SystemExit
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should check if gritano is installed" do
|
37
|
-
base = create_base('.')
|
38
|
-
lambda { base.check_gritano }.should_not raise_error SystemExit
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should check if git is not installed" do
|
42
|
-
base = create_base('.')
|
43
|
-
base.stub(:unknown_command).and_return(true)
|
44
|
-
lambda { base.check_git }.should raise_error SystemExit
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should check if git is installed" do
|
48
|
-
base = create_base('.')
|
49
|
-
base.stub(:unknown_command).and_return(false)
|
50
|
-
lambda { base.check_git }.should_not raise_error SystemExit
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should check if a command exists" do
|
54
|
-
base = create_base('.')
|
55
|
-
base.unknown_command('ls').should be_false
|
56
|
-
base.unknown_command('qwertyuioplkjhgfdsa').should be_true
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,183 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Gritano
|
4
|
-
module Console
|
5
|
-
describe Executor do
|
6
|
-
def create_executor(home, repo_dir)
|
7
|
-
stdin = double()
|
8
|
-
stdin.stub(:read).and_return("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9UnnlDwmvid+WRAyIhVzFhIjUUxA3Wul7LN8mk18dHZDv5HSVADmM4EoqbVSbpeVIyTIchqS3y3XF1rh8dfM41f/W3lcTcFihHM6RDx45Q3Lz9hfyrT8tttlWRA7prvlXu6bUOqMmNtvFFow+bJEo/HgCZHshvoDHcnlHfziU7bDCo+p50SdafFwZRe3AWp/f4TsxiP7jpBnluQM0Dl9Om8jfW8IYAJ+WxlKBsKLMkRH/HWSuigs4AQBD4ADiQfOm2RO4yeSiVFNwGFmgG7NmEq1sNALLAQw+ijN9vyiD99ybr0pqoJX3vhyRBWvCrgQdHjh8ucaoMXI89LxyYts/ igorbonadio@marvin.local")
|
9
|
-
Executor.new(stdin, home, repo_dir)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should list users" do
|
13
|
-
User.should_receive(:all).and_return([])
|
14
|
-
create_executor('.', 'tmp').execute(["user:list"])
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should list users' keys" do
|
18
|
-
user = double()
|
19
|
-
user.should_receive(:keys).and_return([])
|
20
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
21
|
-
create_executor('.', 'tmp').execute(["user:key:list", "login"])
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should list users' repos" do
|
25
|
-
user = double()
|
26
|
-
user.should_receive(:repositories).and_return([])
|
27
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
28
|
-
create_executor('.', 'tmp').execute(["user:repo:list", "login"])
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should add users" do
|
32
|
-
user = double()
|
33
|
-
user.should_receive(:save).and_return(true)
|
34
|
-
User.should_receive(:new).with(login: "login", admin: false).and_return(user)
|
35
|
-
create_executor('.', 'tmp').execute(["user:add", "login"])
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should remove users" do
|
39
|
-
user = double()
|
40
|
-
user.should_receive(:destroy).and_return(true)
|
41
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
42
|
-
create_executor('.', 'tmp').execute(["user:rm", "login"])
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should add users' keys" do
|
46
|
-
user = double()
|
47
|
-
keys = double()
|
48
|
-
key = double()
|
49
|
-
key.should_receive(:valid?).and_return(true)
|
50
|
-
keys.should_receive(:create).with(name: "keyname", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9UnnlDwmvid+WRAyIhVzFhIjUUxA3Wul7LN8mk18dHZDv5HSVADmM4EoqbVSbpeVIyTIchqS3y3XF1rh8dfM41f/W3lcTcFihHM6RDx45Q3Lz9hfyrT8tttlWRA7prvlXu6bUOqMmNtvFFow+bJEo/HgCZHshvoDHcnlHfziU7bDCo+p50SdafFwZRe3AWp/f4TsxiP7jpBnluQM0Dl9Om8jfW8IYAJ+WxlKBsKLMkRH/HWSuigs4AQBD4ADiQfOm2RO4yeSiVFNwGFmgG7NmEq1sNALLAQw+ijN9vyiD99ybr0pqoJX3vhyRBWvCrgQdHjh8ucaoMXI89LxyYts/").and_return(key)
|
51
|
-
user.should_receive(:keys).and_return(keys)
|
52
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
53
|
-
create_executor('.', 'tmp').execute(["user:key:add", "login", "keyname"])
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should add users' keys" do
|
57
|
-
user = double()
|
58
|
-
keys = double()
|
59
|
-
key = double()
|
60
|
-
|
61
|
-
key.should_receive(:valid?).and_return(true)
|
62
|
-
keys.should_receive(:create).with(name: "keyname", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9UnnlDwmvid+WRAyIhVzFhIjUUxA3Wul7LN8mk18dHZDv5HSVADmM4EoqbVSbpeVIyTIchqS3y3XF1rh8dfM41f/W3lcTcFihHM6RDx45Q3Lz9hfyrT8tttlWRA7prvlXu6bUOqMmNtvFFow+bJEo/HgCZHshvoDHcnlHfziU7bDCo+p50SdafFwZRe3AWp/f4TsxiP7jpBnluQM0Dl9Om8jfW8IYAJ+WxlKBsKLMkRH/HWSuigs4AQBD4ADiQfOm2RO4yeSiVFNwGFmgG7NmEq1sNALLAQw+ijN9vyiD99ybr0pqoJX3vhyRBWvCrgQdHjh8ucaoMXI89LxyYts==").and_return(key)
|
63
|
-
user.should_receive(:keys).and_return(keys)
|
64
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
65
|
-
|
66
|
-
stdin = double()
|
67
|
-
stdin.stub(:read).and_return("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9UnnlDwmvid+WRAyIhVzFhIjUUxA3Wul7LN8mk18dHZDv5HSVADmM4EoqbVSbpeVIyTIchqS3y3XF1rh8dfM41f/W3lcTcFihHM6RDx45Q3Lz9hfyrT8tttlWRA7prvlXu6bUOqMmNtvFFow+bJEo/HgCZHshvoDHcnlHfziU7bDCo+p50SdafFwZRe3AWp/f4TsxiP7jpBnluQM0Dl9Om8jfW8IYAJ+WxlKBsKLMkRH/HWSuigs4AQBD4ADiQfOm2RO4yeSiVFNwGFmgG7NmEq1sNALLAQw+ijN9vyiD99ybr0pqoJX3vhyRBWvCrgQdHjh8ucaoMXI89LxyYts== igorbonadio@marvin.local")
|
68
|
-
Executor.new(stdin, '.', 'tmp').execute(["user:key:add", "login", "keyname"])
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should remove users' keys" do
|
72
|
-
keys = double()
|
73
|
-
users = double()
|
74
|
-
limit = double()
|
75
|
-
key = double()
|
76
|
-
key.should_receive(:destroy).and_return(true)
|
77
|
-
limit.should_receive(:limit).with(1).and_return([key])
|
78
|
-
users.should_receive(:where).with("users.login" => "login").and_return(limit)
|
79
|
-
keys.should_receive(:includes).with(:user).and_return(users)
|
80
|
-
Key.should_receive(:where).with(name: "keyname").and_return(keys)
|
81
|
-
create_executor('.', 'tmp').execute(["user:key:rm", "login", "keyname"])
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should add admin rights to user" do
|
85
|
-
user = double()
|
86
|
-
user.should_receive(:admin=).with(true)
|
87
|
-
user.should_receive(:save).and_return(true)
|
88
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
89
|
-
create_executor('.', 'tmp').execute(["user:admin:add", "login"])
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should remove admin rights from users" do
|
93
|
-
user = double()
|
94
|
-
user.should_receive(:admin=).with(false)
|
95
|
-
user.should_receive(:save).and_return(true)
|
96
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
97
|
-
create_executor('.', 'tmp').execute(["user:admin:rm", "login"])
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should list repos" do
|
101
|
-
Repository.should_receive(:all).and_return([])
|
102
|
-
create_executor('.', 'tmp').execute(["repo:list"])
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should create repos" do
|
106
|
-
repo = double()
|
107
|
-
repo.should_receive(:save).and_return(true)
|
108
|
-
Repository.should_receive(:new).with(name: "repo.git", path: "tmp").and_return(repo)
|
109
|
-
create_executor('.', 'tmp').execute(["repo:add", "repo.git"])
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should create repos and add a user" do
|
113
|
-
repo = double()
|
114
|
-
repo.should_receive(:save).and_return(true)
|
115
|
-
Repository.should_receive(:new).with(name: "repo.git", path: "tmp").and_return(repo)
|
116
|
-
|
117
|
-
user = double()
|
118
|
-
user.should_receive(:add_access).twice
|
119
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
120
|
-
|
121
|
-
create_executor('.', 'tmp').execute(["repo:add", "repo.git", "login"])
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should list repos' users" do
|
125
|
-
repo = double()
|
126
|
-
repo.should_receive(:users).and_return([])
|
127
|
-
Repository.should_receive(:find_by_name).with("repo.git").and_return(repo)
|
128
|
-
create_executor('.', 'tmp').execute(["repo:user:list", "repo.git"])
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should remove repos" do
|
132
|
-
repo = double()
|
133
|
-
repo.should_receive(:destroy).and_return(true)
|
134
|
-
Repository.should_receive(:find_by_name).with("repo.git").and_return(repo)
|
135
|
-
create_executor('.', 'tmp').execute(["repo:rm", "repo.git"])
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should allow user to read a repo" do
|
139
|
-
repo = double()
|
140
|
-
Repository.should_receive(:find_by_name).with("repo.git").and_return(repo)
|
141
|
-
|
142
|
-
user = double()
|
143
|
-
user.should_receive(:add_access).with(repo, :read).and_return(true)
|
144
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
145
|
-
|
146
|
-
create_executor('.', 'tmp').execute(["repo:read:add", "repo.git", "login"])
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should allow user to write to a repo" do
|
150
|
-
repo = double()
|
151
|
-
Repository.should_receive(:find_by_name).with("repo.git").and_return(repo)
|
152
|
-
|
153
|
-
user = double()
|
154
|
-
user.should_receive(:add_access).with(repo, :write).and_return(true)
|
155
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
156
|
-
|
157
|
-
create_executor('.', 'tmp').execute(["repo:write:add", "repo.git", "login"])
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should deny user to read a repo" do
|
161
|
-
repo = double()
|
162
|
-
Repository.should_receive(:find_by_name).with("repo.git").and_return(repo)
|
163
|
-
|
164
|
-
user = double()
|
165
|
-
user.should_receive(:remove_access).with(repo, :read).and_return(true)
|
166
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
167
|
-
|
168
|
-
create_executor('.', 'tmp').execute(["repo:read:rm", "repo.git", "login"])
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should deny user to write to a repo"do
|
172
|
-
repo = double()
|
173
|
-
Repository.should_receive(:find_by_name).with("repo.git").and_return(repo)
|
174
|
-
|
175
|
-
user = double()
|
176
|
-
user.should_receive(:remove_access).with(repo, :write).and_return(true)
|
177
|
-
User.should_receive(:find_by_login).with("login").and_return(user)
|
178
|
-
|
179
|
-
create_executor('.', 'tmp').execute(["repo:write:rm", "repo.git", "login"])
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Gritano
|
4
|
-
module Console
|
5
|
-
describe Gritano do
|
6
|
-
def create_gritano(home, repo_dir)
|
7
|
-
stdin = double()
|
8
|
-
stdin.stub(:read).and_return("Your SSHKEY here...")
|
9
|
-
Gritano.new(stdin, home, repo_dir)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_console_call(console, msg)
|
13
|
-
executor = double()
|
14
|
-
executor.should_receive(:execute).with(msg)
|
15
|
-
console.should_receive(:new).and_return(executor)
|
16
|
-
create_gritano('.', 'tmp').execute(msg)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_executor(msg)
|
20
|
-
test_console_call(Executor, msg)
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_installer(msg)
|
24
|
-
test_console_call(Installer, msg)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should show the complete help" do
|
28
|
-
create_gritano(".", "tmp").
|
29
|
-
execute(["help"])[1].
|
30
|
-
should == File.open("features/data/local_help.txt").readlines.join.
|
31
|
-
gsub('{{VERSION}}', File.open("VERSION").readlines.join)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should show the version" do
|
35
|
-
create_gritano(".", "tmp").
|
36
|
-
execute(["version"])[1].
|
37
|
-
should == "v#{File.open("VERSION").readlines.join}"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should list users" do
|
41
|
-
test_executor(["user:list"])
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should list users' keys" do
|
45
|
-
test_executor(["user:key:list", "login"])
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should list users' repos" do
|
49
|
-
test_executor(["user:repo:list", "login"])
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should add users" do
|
53
|
-
test_executor(["user:add", "login"])
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should remove users" do
|
57
|
-
test_executor(["user:rm", "login"])
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should add users' keys" do
|
61
|
-
test_executor(["user:key:add", "login", "keyname"])
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should remove users' keys" do
|
65
|
-
test_executor(["user:key:rm", "login", "keyname"])
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should add admin rights to user" do
|
69
|
-
test_executor(["user:admin:add", "login"])
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should remove admin rights from users" do
|
73
|
-
test_executor(["user:admin:rm", "login"])
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should list repos" do
|
77
|
-
test_executor(["repo:list"])
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should create repos" do
|
81
|
-
test_executor(["repo:add", "repo.git"])
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should create repos and add a user" do
|
85
|
-
test_executor(["repo:add", "repo.git", "login"])
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should list repos' users" do
|
89
|
-
test_executor(["repo:user:list", "repo.git"])
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should remove repos" do
|
93
|
-
test_executor(["repo:rm", "repo.git"])
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should allow user to read a repo" do
|
97
|
-
test_executor(["repo:read:add", "repo.git", "login"])
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should allow user to write to a repo" do
|
101
|
-
test_executor(["repo:write:add", "repo.git", "login"])
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should deny user to read a repo" do
|
105
|
-
test_executor(["repo:read:rm", "repo.git", "login"])
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should deny user to write to a repo"do
|
109
|
-
test_executor(["repo:write:rm", "repo.git", "login"])
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should prepare the environment" do
|
113
|
-
test_installer(["setup:prepare"])
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should install" do
|
117
|
-
test_installer(["setup:install"])
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|