2 load 'test/functional/arvados/v1/git_setup.rb'
4 class Arvados::V1::CommitsControllerTest < ActionController::TestCase
5 fixtures :repositories, :users
7 # See git_setup.rb for the commit log for test.git.tar
10 test "test_find_commit_range" do
11 authorize_with :active
14 a = Commit.find_commit_range(users(:active), nil, nil, '31ce37fe365b3dc204300a3e4c396ad333ed0556', nil)
15 assert_equal ['31ce37fe365b3dc204300a3e4c396ad333ed0556'], a
17 #test "test_branch1" do
18 a = Commit.find_commit_range(users(:active), nil, nil, 'master', nil)
19 assert_equal ['077ba2ad3ea24a929091a9e6ce545c93199b8e57'], a
21 #test "test_branch2" do
22 a = Commit.find_commit_range(users(:active), 'foo', nil, 'b1', nil)
23 assert_equal ['1de84a854e2b440dc53bf42f8548afa4c17da332'], a
25 #test "test_branch3" do
26 a = Commit.find_commit_range(users(:active), 'foo', nil, 'HEAD', nil)
27 assert_equal ['1de84a854e2b440dc53bf42f8548afa4c17da332'], a
29 #test "test_single_revision_repo" do
30 a = Commit.find_commit_range(users(:active), "foo", nil, '31ce37fe365b3dc204300a3e4c396ad333ed0556', nil)
31 assert_equal ['31ce37fe365b3dc204300a3e4c396ad333ed0556'], a
32 a = Commit.find_commit_range(users(:active), "bar", nil, '31ce37fe365b3dc204300a3e4c396ad333ed0556', nil)
35 #test "test_multi_revision" do
36 a = Commit.find_commit_range(users(:active), nil, '31ce37fe365b3dc204300a3e4c396ad333ed0556', '077ba2ad3ea24a929091a9e6ce545c93199b8e57', nil)
37 assert_equal ['077ba2ad3ea24a929091a9e6ce545c93199b8e57', '4fe459abe02d9b365932b8f5dc419439ab4e2577', '31ce37fe365b3dc204300a3e4c396ad333ed0556'], a
40 a = Commit.find_commit_range(users(:active), nil, 'tag1', 'master', nil)
41 assert_equal ['077ba2ad3ea24a929091a9e6ce545c93199b8e57', '4fe459abe02d9b365932b8f5dc419439ab4e2577'], a
43 #test "test_multi_revision_exclude" do
44 a = Commit.find_commit_range(users(:active), nil, '31ce37fe365b3dc204300a3e4c396ad333ed0556', '077ba2ad3ea24a929091a9e6ce545c93199b8e57', ['4fe459abe02d9b365932b8f5dc419439ab4e2577'])
45 assert_equal ['077ba2ad3ea24a929091a9e6ce545c93199b8e57', '31ce37fe365b3dc204300a3e4c396ad333ed0556'], a
47 #test "test_multi_revision_tagged_exclude" do
48 a = Commit.find_commit_range(users(:active), nil, '31ce37fe365b3dc204300a3e4c396ad333ed0556', '077ba2ad3ea24a929091a9e6ce545c93199b8e57', ['tag1'])
49 assert_equal ['077ba2ad3ea24a929091a9e6ce545c93199b8e57', '31ce37fe365b3dc204300a3e4c396ad333ed0556'], a
51 Dir.mktmpdir do |touchdir|
52 # invalid input to maximum
53 a = Commit.find_commit_range(users(:active), nil, nil, "31ce37fe365b3dc204300a3e4c396ad333ed0556 ; touch #{touchdir}/uh_oh", nil)
54 assert !File.exists?("#{touchdir}/uh_oh"), "#{touchdir}/uh_oh should not exist, 'maximum' parameter of find_commit_range is exploitable"
57 # invalid input to maximum
58 a = Commit.find_commit_range(users(:active), nil, nil, "$(uname>#{touchdir}/uh_oh)", nil)
59 assert !File.exists?("#{touchdir}/uh_oh"), "#{touchdir}/uh_oh should not exist, 'maximum' parameter of find_commit_range is exploitable"
62 # invalid input to minimum
63 a = Commit.find_commit_range(users(:active), nil, "31ce37fe365b3dc204300a3e4c396ad333ed0556 ; touch #{touchdir}/uh_oh", "31ce37fe365b3dc204300a3e4c396ad333ed0556", nil)
64 assert !File.exists?("#{touchdir}/uh_oh"), "#{touchdir}/uh_oh should not exist, 'minimum' parameter of find_commit_range is exploitable"
67 # invalid input to minimum
68 a = Commit.find_commit_range(users(:active), nil, "$(uname>#{touchdir}/uh_oh)", "31ce37fe365b3dc204300a3e4c396ad333ed0556", nil)
69 assert !File.exists?("#{touchdir}/uh_oh"), "#{touchdir}/uh_oh should not exist, 'minimum' parameter of find_commit_range is exploitable"
72 # invalid input to 'excludes'
73 a = Commit.find_commit_range(users(:active), nil, "31ce37fe365b3dc204300a3e4c396ad333ed0556", "077ba2ad3ea24a929091a9e6ce545c93199b8e57", ["4fe459abe02d9b365932b8f5dc419439ab4e2577 ; touch #{touchdir}/uh_oh"])
74 assert !File.exists?("#{touchdir}/uh_oh"), "#{touchdir}/uh_oh should not exist, 'excludes' parameter of find_commit_range is exploitable"
77 # invalid input to 'excludes'
78 a = Commit.find_commit_range(users(:active), nil, "31ce37fe365b3dc204300a3e4c396ad333ed0556", "077ba2ad3ea24a929091a9e6ce545c93199b8e57", ["$(uname>#{touchdir}/uh_oh)"])
79 assert !File.exists?("#{touchdir}/uh_oh"), "#{touchdir}/uh_oh should not exist, 'excludes' parameter of find_commit_range is exploitable"