Mercurial > hg > soundsoftware-site
comparison .svn/pristine/eb/eb6cb0f6889f62dec8dd9c85a7fb5ed905af22c8.svn-base @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../test_case', __FILE__) | |
19 require 'tmpdir' | |
20 | |
21 class RedminePmTest::RepositoryGitTest < RedminePmTest::TestCase | |
22 fixtures :projects, :users, :members, :roles, :member_roles | |
23 | |
24 GIT_BIN = Redmine::Configuration['scm_git_command'] || "git" | |
25 | |
26 def test_anonymous_read_on_public_repo_with_permission_should_succeed | |
27 assert_success "ls-remote", git_url | |
28 end | |
29 | |
30 def test_anonymous_read_on_public_repo_without_permission_should_fail | |
31 Role.anonymous.remove_permission! :browse_repository | |
32 assert_failure "ls-remote", git_url | |
33 end | |
34 | |
35 def test_invalid_credentials_should_fail | |
36 Project.find(1).update_attribute :is_public, false | |
37 with_credentials "dlopper", "foo" do | |
38 assert_success "ls-remote", git_url | |
39 end | |
40 with_credentials "dlopper", "wrong" do | |
41 assert_failure "ls-remote", git_url | |
42 end | |
43 end | |
44 | |
45 def test_clone | |
46 Dir.mktmpdir do |dir| | |
47 Dir.chdir(dir) do | |
48 assert_success "clone", git_url | |
49 end | |
50 end | |
51 end | |
52 | |
53 def test_write_commands | |
54 Role.find(2).add_permission! :commit_access | |
55 filename = random_filename | |
56 | |
57 Dir.mktmpdir do |dir| | |
58 assert_success "clone", git_url, dir | |
59 Dir.chdir(dir) do | |
60 f = File.new(File.join(dir, filename), "w") | |
61 f.write "test file content" | |
62 f.close | |
63 | |
64 with_credentials "dlopper", "foo" do | |
65 assert_success "add", filename | |
66 assert_success "commit -a --message Committing_a_file" | |
67 assert_success "push", git_url, "--all" | |
68 end | |
69 end | |
70 end | |
71 | |
72 Dir.mktmpdir do |dir| | |
73 assert_success "clone", git_url, dir | |
74 Dir.chdir(dir) do | |
75 assert File.exists?(File.join(dir, "#{filename}")) | |
76 end | |
77 end | |
78 end | |
79 | |
80 protected | |
81 | |
82 def execute(*args) | |
83 a = [GIT_BIN] | |
84 super a, *args | |
85 end | |
86 | |
87 def git_url(path=nil) | |
88 host = ENV['REDMINE_TEST_DAV_SERVER'] || '127.0.0.1' | |
89 credentials = nil | |
90 if username && password | |
91 credentials = "#{username}:#{password}" | |
92 end | |
93 url = "http://#{credentials}@#{host}/git/ecookbook" | |
94 url << "/#{path}" if path | |
95 url | |
96 end | |
97 end |