gritano 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data/Gemfile +9 -17
  2. data/Gemfile.lock +78 -50
  3. data/Guardfile +9 -0
  4. data/README.rdoc +23 -24
  5. data/Rakefile +8 -12
  6. data/TODO +12 -8
  7. data/VERSION +1 -1
  8. data/bin/gritano +8 -1
  9. data/bin/gritano-remote +16 -2
  10. data/gritano.gemspec +52 -230
  11. data/lib/gritano.rb +12 -6
  12. data/lib/gritano/config.rb +11 -31
  13. data/lib/gritano/console/base.rb +6 -74
  14. data/lib/gritano/console/git.rb +29 -0
  15. data/lib/gritano/console/local.rb +131 -0
  16. data/lib/gritano/console/remote.rb +47 -93
  17. data/lib/gritano/core/key.rb +18 -0
  18. data/lib/gritano/core/user.rb +12 -0
  19. data/lib/gritano/helpers.rb +52 -0
  20. data/lib/gritano/renderer.rb +36 -0
  21. data/lib/gritano/thor.rb +27 -0
  22. data/spec/data/development.yml +2 -0
  23. data/spec/gritano/console/git_spec.rb +55 -0
  24. data/spec/gritano/console/local_spec.rb +148 -0
  25. data/spec/gritano/console/remote_spec.rb +56 -0
  26. data/spec/gritano/core/key_spec.rb +21 -0
  27. data/spec/gritano/core/user_spec.rb +43 -0
  28. data/spec/gritano/helpers_spec.rb +113 -0
  29. data/spec/gritano/thor_spec.rb +29 -0
  30. data/spec/spec_helper.rb +1 -16
  31. data/templates/local.gritano +4 -0
  32. data/templates/remote.gritano +5 -0
  33. metadata +61 -280
  34. data/.gritano/config.yml +0 -2
  35. data/.gritano/database.yml +0 -2
  36. data/.ssh/.gitignore +0 -4
  37. data/bin/gritano-pub-key +0 -15
  38. data/db/migrate/001_create_users.rb +0 -8
  39. data/db/migrate/002_create_repositories.rb +0 -9
  40. data/db/migrate/003_create_permissions.rb +0 -10
  41. data/db/migrate/004_create_keys.rb +0 -11
  42. data/db/migrate/005_add_admin_to_users.rb +0 -10
  43. data/db/migrate/006_add_email_to_users.rb +0 -10
  44. data/db/migrate/007_add_password_to_users.rb +0 -10
  45. data/db/migrate/008_remove_password_from_user.rb +0 -10
  46. data/db/migrate/009_remove_email_from_users.rb +0 -10
  47. data/features/data/config_true.yml +0 -2
  48. data/features/data/local_commands/repo_add_tmp_jeka_git.txt +0 -1
  49. data/features/data/local_commands/repo_add_tmp_p_lang_git.txt +0 -1
  50. data/features/data/local_commands/repo_add_tmp_p_lang_git_igorbonadio.txt +0 -1
  51. data/features/data/local_commands/repo_add_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
  52. data/features/data/local_commands/repo_list.txt +0 -6
  53. data/features/data/local_commands/repo_read_add_tmp_gritano_git_arybonadio.txt +0 -1
  54. data/features/data/local_commands/repo_read_add_tmp_gritano_git_jessicaeto.txt +0 -1
  55. data/features/data/local_commands/repo_read_add_tmp_p_lang_git_jessicaeto.txt +0 -1
  56. data/features/data/local_commands/repo_read_rm_tmp_jeka_git_aribonadio.txt +0 -1
  57. data/features/data/local_commands/repo_read_rm_tmp_jeka_git_igorbonadio.txt +0 -1
  58. data/features/data/local_commands/repo_read_rm_tmp_p_lang_git_igorbonadio.txt +0 -1
  59. data/features/data/local_commands/repo_rm_tmp_jeka_git.txt +0 -1
  60. data/features/data/local_commands/repo_rm_tmp_p_lang_git.txt +0 -1
  61. data/features/data/local_commands/repo_user_list_tmp_jeka_git.txt +0 -6
  62. data/features/data/local_commands/repo_user_list_tmp_ruby_git.txt +0 -1
  63. data/features/data/local_commands/repo_write_add_tmp_gritano_git_arybonadio.txt +0 -1
  64. data/features/data/local_commands/repo_write_add_tmp_gritano_git_jessicaeto.txt +0 -1
  65. data/features/data/local_commands/repo_write_add_tmp_p_lang_git_jessicaeto.txt +0 -1
  66. data/features/data/local_commands/repo_write_rm_tmp_gritano_git_arybonadio.txt +0 -1
  67. data/features/data/local_commands/repo_write_rm_tmp_gritano_git_igorbonadio.txt +0 -1
  68. data/features/data/local_commands/repo_write_rm_tmp_p_lang_git_igorbonadio.txt +0 -1
  69. data/features/data/local_commands/user_add_igorbonadio.txt +0 -1
  70. data/features/data/local_commands/user_add_jose.txt +0 -1
  71. data/features/data/local_commands/user_admin_add_arybonadio.txt +0 -1
  72. data/features/data/local_commands/user_admin_add_igorbonadio.txt +0 -1
  73. data/features/data/local_commands/user_admin_rm_arybonadio.txt +0 -1
  74. data/features/data/local_commands/user_admin_rm_igorbonadio.txt +0 -1
  75. data/features/data/local_commands/user_key_add_igorbonadio_marvin.txt +0 -1
  76. data/features/data/local_commands/user_key_add_userrr_marvino.txt +0 -1
  77. data/features/data/local_commands/user_key_list_arybonadio.txt +0 -1
  78. data/features/data/local_commands/user_key_list_igorbonadio.txt +0 -5
  79. data/features/data/local_commands/user_key_rm_igorbonadio_eva.txt +0 -1
  80. data/features/data/local_commands/user_key_rm_igorbonadio_marvino.txt +0 -1
  81. data/features/data/local_commands/user_list.txt +0 -6
  82. data/features/data/local_commands/user_repo_list_arybonadio.txt +0 -1
  83. data/features/data/local_commands/user_repo_list_igorbonadio.txt +0 -6
  84. data/features/data/local_commands/user_rm_igorbonadio.txt +0 -1
  85. data/features/data/local_commands/user_rm_jose.txt +0 -1
  86. data/features/data/local_commands/version.txt +0 -1
  87. data/features/data/local_help.txt +0 -32
  88. data/features/data/remote_commands/admin_help_igorbonadio.txt +0 -32
  89. data/features/data/remote_commands/admin_help_jessicaeto.txt +0 -32
  90. data/features/data/remote_commands/admin_repo_add_tmp_jeka_git_igorbonadio.txt +0 -1
  91. data/features/data/remote_commands/admin_repo_add_tmp_jeka_git_jessicaeto.txt +0 -1
  92. data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio.txt +0 -1
  93. data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_igorbonadio.txt +0 -1
  94. data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
  95. data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_jessicaeto_igorbonadio.txt +0 -1
  96. data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_igorbonadio_jessicaeto_jessicaeto.txt +0 -1
  97. data/features/data/remote_commands/admin_repo_add_tmp_p_lang_git_jessicaeto.txt +0 -1
  98. data/features/data/remote_commands/admin_repo_list_igorbonadio.txt +0 -6
  99. data/features/data/remote_commands/admin_repo_list_jessicaeto.txt +0 -1
  100. data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_arybonadio_igorbonadio.txt +0 -1
  101. data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_arybonadio_jessicaeto.txt +0 -1
  102. data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_jessicaeto_igorbonadio.txt +0 -1
  103. data/features/data/remote_commands/admin_repo_read_add_tmp_gritano_git_jessicaeto_jessicaeto.txt +0 -1
  104. data/features/data/remote_commands/admin_repo_read_add_tmp_p_lang_git_jessicaeto_igorbonadio.txt +0 -1
  105. data/features/data/remote_commands/admin_repo_read_add_tmp_p_lang_git_jessicaeto_jessicaeto.txt +0 -1
  106. data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_aribonadio_igorbonadio.txt +0 -1
  107. data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_aribonadio_jessicaeto.txt +0 -1
  108. data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_igorbonadio_igorbonadio.txt +0 -1
  109. data/features/data/remote_commands/admin_repo_read_rm_tmp_jeka_git_igorbonadio_jessicaeto.txt +0 -1
  110. data/features/data/remote_commands/admin_repo_read_rm_tmp_p_lang_git_igorbonadio_igorbonadio.txt +0 -1
  111. data/features/data/remote_commands/admin_repo_read_rm_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
  112. data/features/data/remote_commands/admin_repo_rm_tmp_jeka_git_igorbonadio.txt +0 -1
  113. data/features/data/remote_commands/admin_repo_rm_tmp_jeka_git_jessicaeto.txt +0 -1
  114. data/features/data/remote_commands/admin_repo_rm_tmp_p_lang_git_igorbonadio.txt +0 -1
  115. data/features/data/remote_commands/admin_repo_rm_tmp_p_lang_git_jessicaeto.txt +0 -1
  116. data/features/data/remote_commands/admin_repo_user_list_tmp_jeka_git_igorbonadio.txt +0 -6
  117. data/features/data/remote_commands/admin_repo_user_list_tmp_jeka_git_jessicaeto.txt +0 -1
  118. data/features/data/remote_commands/admin_repo_user_list_tmp_ruby_git_igorbonadio.txt +0 -1
  119. data/features/data/remote_commands/admin_repo_user_list_tmp_ruby_git_jessicaeto.txt +0 -1
  120. data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_arybonadio_igorbonadio.txt +0 -1
  121. data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_arybonadio_jessicaeto.txt +0 -1
  122. data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_jessicaeto_igorbonadio.txt +0 -1
  123. data/features/data/remote_commands/admin_repo_write_add_tmp_gritano_git_jessicaeto_jessicaeto.txt +0 -1
  124. data/features/data/remote_commands/admin_repo_write_add_tmp_p_lang_git_jessicaeto_igorbonadio.txt +0 -1
  125. data/features/data/remote_commands/admin_repo_write_add_tmp_p_lang_git_jessicaeto_jessicaeto.txt +0 -1
  126. data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_arybonadio_igorbonadio.txt +0 -1
  127. data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_arybonadio_jessicaeto.txt +0 -1
  128. data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_igorbonadio_igorbonadio.txt +0 -1
  129. data/features/data/remote_commands/admin_repo_write_rm_tmp_gritano_git_igorbonadio_jessicaeto.txt +0 -1
  130. data/features/data/remote_commands/admin_repo_write_rm_tmp_p_lang_git_igorbonadio_igorbonadio.txt +0 -1
  131. data/features/data/remote_commands/admin_repo_write_rm_tmp_p_lang_git_igorbonadio_jessicaeto.txt +0 -1
  132. data/features/data/remote_commands/admin_user_add_igorbonadio_igorbonadio.txt +0 -1
  133. data/features/data/remote_commands/admin_user_add_igorbonadio_jessicaeto.txt +0 -1
  134. data/features/data/remote_commands/admin_user_add_jose_igorbonadio.txt +0 -1
  135. data/features/data/remote_commands/admin_user_add_jose_jessicaeto.txt +0 -1
  136. data/features/data/remote_commands/admin_user_admin_add_arybonadio_igorbonadio.txt +0 -1
  137. data/features/data/remote_commands/admin_user_admin_add_arybonadio_jessicaeto.txt +0 -1
  138. data/features/data/remote_commands/admin_user_admin_add_igorbonadio_igorbonadio.txt +0 -1
  139. data/features/data/remote_commands/admin_user_admin_add_igorbonadio_jessicaeto.txt +0 -1
  140. data/features/data/remote_commands/admin_user_admin_rm_arybonadio_igorbonadio.txt +0 -1
  141. data/features/data/remote_commands/admin_user_admin_rm_arybonadio_jessicaeto.txt +0 -1
  142. data/features/data/remote_commands/admin_user_admin_rm_igorbonadio_igorbonadio.txt +0 -1
  143. data/features/data/remote_commands/admin_user_admin_rm_igorbonadio_jessicaeto.txt +0 -1
  144. data/features/data/remote_commands/admin_user_key_add_igorbonadio_marvin_igorbonadio.txt +0 -1
  145. data/features/data/remote_commands/admin_user_key_add_igorbonadio_marvin_jessicaeto.txt +0 -1
  146. data/features/data/remote_commands/admin_user_key_add_userrr_marvino_igorbonadio.txt +0 -1
  147. data/features/data/remote_commands/admin_user_key_add_userrr_marvino_jessicaeto.txt +0 -1
  148. data/features/data/remote_commands/admin_user_key_list_arybonadio_igorbonadio.txt +0 -1
  149. data/features/data/remote_commands/admin_user_key_list_arybonadio_jessicaeto.txt +0 -1
  150. data/features/data/remote_commands/admin_user_key_list_igorbonadio_igorbonadio.txt +0 -5
  151. data/features/data/remote_commands/admin_user_key_list_igorbonadio_jessicaeto.txt +0 -1
  152. data/features/data/remote_commands/admin_user_key_rm_igorbonadio_eva_igorbonadio.txt +0 -1
  153. data/features/data/remote_commands/admin_user_key_rm_igorbonadio_eva_jessicaeto.txt +0 -1
  154. data/features/data/remote_commands/admin_user_key_rm_igorbonadio_marvino_igorbonadio.txt +0 -1
  155. data/features/data/remote_commands/admin_user_key_rm_igorbonadio_marvino_jessicaeto.txt +0 -1
  156. data/features/data/remote_commands/admin_user_list_igorbonadio.txt +0 -6
  157. data/features/data/remote_commands/admin_user_list_jessicaeto.txt +0 -1
  158. data/features/data/remote_commands/admin_user_repo_list_arybonadio_igorbonadio.txt +0 -1
  159. data/features/data/remote_commands/admin_user_repo_list_arybonadio_jessicaeto.txt +0 -1
  160. data/features/data/remote_commands/admin_user_repo_list_igorbonadio_igorbonadio.txt +0 -6
  161. data/features/data/remote_commands/admin_user_repo_list_igorbonadio_jessicaeto.txt +0 -1
  162. data/features/data/remote_commands/admin_user_rm_igorbonadio_igorbonadio.txt +0 -1
  163. data/features/data/remote_commands/admin_user_rm_igorbonadio_jessicaeto.txt +0 -1
  164. data/features/data/remote_commands/admin_user_rm_jose_igorbonadio.txt +0 -1
  165. data/features/data/remote_commands/admin_user_rm_jose_jessicaeto.txt +0 -1
  166. data/features/data/remote_commands/admin_version_igorbonadio.txt +0 -1
  167. data/features/data/remote_commands/admin_version_jessicaeto.txt +0 -1
  168. data/features/data/remote_commands/email_get_igorbonadio.txt +0 -1
  169. data/features/data/remote_commands/email_get_jessicaeto.txt +0 -1
  170. data/features/data/remote_commands/email_update_email@server_com_igorbonadio.txt +0 -1
  171. data/features/data/remote_commands/email_update_email@server_com_jessicaeto.txt +0 -1
  172. data/features/data/remote_commands/help_igorbonadio.txt +0 -14
  173. data/features/data/remote_commands/help_jessicaeto.txt +0 -14
  174. data/features/data/remote_commands/invalid_command_igorbonadio.txt +0 -14
  175. data/features/data/remote_commands/invalid_command_jessicaeto.txt +0 -14
  176. data/features/data/remote_commands/key_add_keyname_igorbonadio.txt +0 -1
  177. data/features/data/remote_commands/key_add_keyname_jessicaeto.txt +0 -1
  178. data/features/data/remote_commands/key_list_igorbonadio.txt +0 -5
  179. data/features/data/remote_commands/key_list_jessicaeto.txt +0 -5
  180. data/features/data/remote_commands/key_rm_hal_igorbonadio.txt +0 -1
  181. data/features/data/remote_commands/key_rm_hal_jessicaeto.txt +0 -1
  182. data/features/data/remote_commands/repo_list_igorbonadio.txt +0 -6
  183. data/features/data/remote_commands/repo_list_jessicaeto.txt +0 -5
  184. data/features/data/remote_commands/version_igorbonadio.txt +0 -1
  185. data/features/data/remote_commands/version_jessicaeto.txt +0 -1
  186. data/features/data/remote_help.txt +0 -14
  187. data/features/install.feature +0 -40
  188. data/features/local.feature +0 -80
  189. data/features/pub_key.feature +0 -25
  190. data/features/remote.feature +0 -150
  191. data/features/step_definitions/background_step.rb +0 -26
  192. data/features/step_definitions/install_step.rb +0 -30
  193. data/features/step_definitions/local_step.rb +0 -25
  194. data/features/step_definitions/pub_key_step.rb +0 -15
  195. data/features/step_definitions/remote_step.rb +0 -49
  196. data/features/support/database_cleaner.rb +0 -15
  197. data/features/support/env.rb +0 -30
  198. data/lib/gritano/cli.rb +0 -49
  199. data/lib/gritano/console.rb +0 -26
  200. data/lib/gritano/console/executor.rb +0 -298
  201. data/lib/gritano/console/gritano.rb +0 -35
  202. data/lib/gritano/console/installer.rb +0 -55
  203. data/lib/gritano/models.rb +0 -7
  204. data/lib/gritano/models/key.rb +0 -37
  205. data/lib/gritano/models/permission.rb +0 -39
  206. data/lib/gritano/models/repository.rb +0 -29
  207. data/lib/gritano/models/user.rb +0 -39
  208. data/spec/cli_spec.rb +0 -26
  209. data/spec/config_spec.rb +0 -64
  210. data/spec/console_base_spec.rb +0 -61
  211. data/spec/console_executor_spec.rb +0 -183
  212. data/spec/console_gritano_spec.rb +0 -121
  213. data/spec/console_installer_spec.rb +0 -28
  214. data/spec/console_remote_spec.rb +0 -70
  215. data/spec/console_spec.rb +0 -27
  216. data/spec/data/help_command_name.txt +0 -7
  217. data/spec/model_key_spec.rb +0 -44
  218. data/spec/model_permission_spec.rb +0 -72
  219. data/spec/model_repository_spec.rb +0 -56
  220. data/spec/model_user_spec.rb +0 -96
@@ -1,28 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module Gritano
4
- module Console
5
- describe Installer do
6
- def create_installer(home)
7
- FileUtils.rm_rf(File.join(home, ".gritano"))
8
- stdin = double()
9
- stdin.stub(:read).and_return("Your SSHKEY here...")
10
- Installer.new(stdin, home)
11
- end
12
-
13
- it "should prepare the environment" do
14
- installer = create_installer("tmp")
15
- installer.should_receive(:create_gritano_dirs)
16
- installer.should_receive(:create_sqlite_config)
17
- installer.execute(["setup:prepare"])
18
- end
19
-
20
- it "should install" do
21
- installer = create_installer("tmp")
22
- installer.should_receive(:create_database)
23
- installer.should_receive(:create_authorization_keys)
24
- installer.execute(["setup:install"])
25
- end
26
- end
27
- end
28
- end
@@ -1,70 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module Gritano
4
- module Console
5
- describe Remote do
6
- def create_remote(home, repo_dir)
7
- stdin = double()
8
- stdin.stub(:read).and_return("Your SSHKEY here...")
9
- Remote.new(stdin, home, repo_dir)
10
- end
11
-
12
- def test_remote_execute(cmd)
13
- _cmd = ["user:" + cmd[0]] + ["login"] + cmd[1..-1]
14
- Executor.any_instance.should_receive(:execute).with(_cmd)
15
- create_remote(".", "tmp").execute(cmd + ["login"])
16
- end
17
-
18
- it "should show a help message" do
19
- create_remote(".", "tmp").
20
- execute(["help"])[1].
21
- should == File.open("features/data/remote_help.txt").readlines.join.
22
- gsub('{{VERSION}}', File.open("VERSION").readlines.join)
23
- end
24
-
25
- it "should show the version" do
26
- create_remote(".", "tmp").
27
- execute(["version"])[1].
28
- should == "v#{File.open("VERSION").readlines.join}"
29
- end
30
-
31
- it "should list user's repositories" do
32
- test_remote_execute(["repo:list"])
33
- end
34
-
35
- it "should list user's keys" do
36
- test_remote_execute(["key:list"])
37
- end
38
-
39
- it "should add a key" do
40
- test_remote_execute(["key:add", "keyname"])
41
- end
42
-
43
- it "should remove a key" do
44
- test_remote_execute(["key:rm", "keyname"])
45
- end
46
-
47
- it "should execute admin commands" do
48
- admin = double()
49
- admin.should_receive(:admin?).and_return(true)
50
- ::Gritano::User.should_receive(:find_by_login).and_return(admin)
51
- remote = create_remote(".", "tmp")
52
- remote.should_receive(:admin_command)
53
- remote.execute(["admin:user:list"])
54
- end
55
-
56
- it "should get a git repository" do
57
- remote = create_remote(".", "tmp")
58
- remote.should_receive(:git_receive_pack)
59
- remote.execute(["git-receive-pack"])
60
- end
61
-
62
- it "should send a git repository" do
63
- remote = create_remote(".", "tmp")
64
- remote.should_receive(:git_upload_pack)
65
- remote.execute(["git-upload-pack"])
66
- end
67
-
68
- end
69
- end
70
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module Gritano
4
- describe Console do
5
- it "should setup a local console" do
6
- Console::Base.should_receive(:bin_name=).with("gritano ")
7
- Console::Remote.should_receive(:bin_name=).with("gritano ")
8
- Console::Executor.should_receive(:bin_name=).with("gritano ")
9
- Console::Gritano.should_receive(:bin_name=).with("gritano ")
10
- Console::Installer.should_receive(:bin_name=).with("gritano ")
11
- FileUtils.rm_rf(File.join("tmp", ".gritano"))
12
- FileUtils.mkdir(File.join('tmp', '.gritano'))
13
- Console.remote_console(false, 'tmp')
14
- end
15
-
16
- it "should setup a remote console" do
17
- Console::Base.should_receive(:bin_name=).with("ssh undefined@undefined admin:")
18
- Console::Remote.should_receive(:bin_name=).with("ssh undefined@undefined ")
19
- Console::Executor.should_receive(:bin_name=).with("ssh undefined@undefined admin:")
20
- Console::Gritano.should_receive(:bin_name=).with("ssh undefined@undefined admin:")
21
- Console::Installer.should_receive(:bin_name=).with("ssh undefined@undefined admin:")
22
- FileUtils.rm_rf(File.join("tmp", ".gritano"))
23
- FileUtils.mkdir(File.join('tmp', '.gritano'))
24
- Console.remote_console(true, 'tmp')
25
- end
26
- end
27
- end
@@ -1,7 +0,0 @@
1
- gritano [command]
2
-
3
- Examples:
4
- gritano command:name parameters
5
-
6
- --
7
- v{{VERSION}}
@@ -1,44 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module Gritano
4
- describe Key do
5
-
6
- def create_new_user_and_key
7
- user = User.create(login: "igor")
8
- key = user.keys.create(name: "mykey", key: "sshkey")
9
- return user, key
10
- end
11
-
12
- it "should have a name" do
13
- key = Gritano::Key.new(key: "key")
14
- key.should be_invalid
15
- end
16
-
17
- it "should have a ssh key" do
18
- key = Gritano::Key.new(name: "name")
19
- key.should be_invalid
20
- end
21
-
22
- it "should have a unique name per user" do
23
- user, key = create_new_user_and_key
24
- user.keys.create(name: "mykey", key: "sshkey").should be_invalid
25
- user.keys.count.should == 1
26
- end
27
-
28
- it "should belongs to a user" do
29
- user, key = create_new_user_and_key
30
- key.user.should == user
31
- end
32
-
33
- it "should generate the authorized_keys files if ssh's configurations is false" do
34
- create_new_user_and_key
35
- Key.authorized_keys.should == "command=\"gritano-remote igor\" sshkey\n\n"
36
- end
37
-
38
- it "should not generate the authorized_keys files if ssh's configurations is true" do
39
- user, key = create_new_user_and_key
40
- Key.config = YAML::load(File.open(File.join('features', 'data', 'config_true.yml')))
41
- Key.authorized_keys.should == ""
42
- end
43
- end
44
- end
@@ -1,72 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module Gritano
4
- describe Permission do
5
-
6
- def create_permission(access)
7
- permission = Permission.new
8
- access.each do |a|
9
- permission.add_access(a)
10
- end
11
- return permission
12
- end
13
-
14
- it "should add READ access" do
15
- permission = create_permission([])
16
- permission.add_access(:read)
17
- permission.is(:read).should be_true
18
- permission.is(:write).should be_false
19
- end
20
-
21
- it "should add WRITE access" do
22
- permission = create_permission([])
23
- permission.add_access(:write)
24
- permission.is(:write).should be_true
25
- permission.is(:read).should be_false
26
- end
27
-
28
- it "should add READ and WRITE access" do
29
- permission = create_permission([])
30
- permission.add_access(:read)
31
- permission.add_access(:write)
32
- permission.is(:write).should be_true
33
- permission.is(:read).should be_true
34
- end
35
-
36
- it "should remove READ access" do
37
- permission = create_permission([:read, :write])
38
- permission.remove_access(:read)
39
- permission.is(:read).should be_false
40
- permission.is(:write).should be_true
41
- end
42
-
43
- it "should remove WRITE access" do
44
- permission = create_permission([:read, :write])
45
- permission.remove_access(:write)
46
- permission.is(:write).should be_false
47
- permission.is(:read).should be_true
48
- end
49
-
50
- it "should remove READ and WRITE access" do
51
- permission = create_permission([:read, :write])
52
- permission.remove_access(:write)
53
- permission.remove_access(:read)
54
- permission.is(:write).should be_false
55
- permission.is(:read).should be_false
56
- end
57
-
58
- it "should not add wrong access" do
59
- permission = create_permission([:read, :write])
60
- permission.add_access(:wrong).should be_false
61
- permission.is(:write).should be_true
62
- permission.is(:read).should be_true
63
- end
64
-
65
- it "should not remove wrong access" do
66
- permission = create_permission([:read, :write])
67
- permission.remove_access(:wrong).should be_false
68
- permission.is(:write).should be_true
69
- permission.is(:read).should be_true
70
- end
71
- end
72
- end
@@ -1,56 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module Gritano
4
- describe Repository do
5
- def stub_hooks
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 name" do
11
- stub_hooks
12
- repo = Repository.new(path: 'path')
13
- repo.should be_invalid
14
- end
15
-
16
- it "should have a unique name" do
17
- stub_hooks
18
- repo = Repository.create(name:'myrepo', path: 'path')
19
- repo.should be_valid
20
- repo = Repository.create(name:'myrepo', path: 'path')
21
- repo.should be_invalid
22
- end
23
-
24
- it "can have many users" do
25
- stub_hooks
26
- repo = Repository.create(name:'myrepo', path: 'path')
27
- repo.users.create(login: 'login1')
28
- repo.users.create(login: 'login2')
29
- repo.users.count.should == 2
30
- end
31
-
32
- it "have a full path" do
33
- stub_hooks
34
- repo = Repository.create(name:'myrepo', path: 'path')
35
- repo.full_path.should == 'path/myrepo'
36
- end
37
-
38
- it "have a full path even if it doesn't have a path" do
39
- stub_hooks
40
- repo = Repository.create(name:'myrepo')
41
- repo.full_path.should == 'myrepo'
42
- end
43
-
44
- it "should create a bare repo when it is created" do
45
- Grit::Repo.should_receive("init_bare").with('path/myrepo')
46
- Repository.create(name:'myrepo', path: 'path')
47
- end
48
-
49
- it "should remove the repository when it is destroyed" do
50
- Grit::Repo.should_receive("init_bare").with('path/myrepo')
51
- FileUtils.should_receive("rm_r").with('path/myrepo', force: true)
52
- repo = Repository.create(name:'myrepo', path: 'path')
53
- repo.destroy
54
- end
55
- end
56
- end
@@ -1,96 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
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
95
- end
96
- end