This repository was archived by the owner on Jan 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathibm_devops_test.rb
More file actions
73 lines (63 loc) · 1.8 KB
/
Copy pathibm_devops_test.rb
File metadata and controls
73 lines (63 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require File.expand_path('../helper', __FILE__)
class IBMDevOpsServicesTest < Service::TestCase
def setup
@stubs= Faraday::Adapter::Test::Stubs.new
@Pushes= 0
end
def test_push
svc = service(
{'ibm_id' => username,
'ibm_password' => password},
payload)
@stubs.post "/manage/processGitHubPayload" do |env|
assert_equal 'hub.jazz.net', env[:url].host
params = Faraday::Utils.parse_nested_query(env[:url].query)
assert_equal({'auth_type' => 'ibmlogin'}, params)
@Pushes += 1
[200, {}, '']
end
svc.receive_push
assert_equal 1, @Pushes
end
def test_push_empty_server_override
svc = service(
{'ibm_id' => username,
'ibm_password' => password,
'override_server_url' => ""},
payload)
@stubs.post "/manage/processGitHubPayload" do |env|
assert_equal 'hub.jazz.net', env[:url].host
params = Faraday::Utils.parse_nested_query(env[:url].query)
assert_equal({'auth_type' => 'ibmlogin'}, params)
@Pushes += 1
[200, {}, '']
end
svc.receive_push
assert_equal 1, @Pushes
end
def test_push_server_override
svc = service(
{'ibm_id' => username,
'ibm_password' => password,
'override_server_url' => "https://test.example.org/foo"},
payload)
@stubs.post "/foo/processGitHubPayload" do |env|
assert_equal 'test.example.org', env[:url].host
params = Faraday::Utils.parse_nested_query(env[:url].query)
assert_equal({'auth_type' => 'ibmlogin'}, params)
@Pushes += 1
[200, {}, '']
end
svc.receive_push
assert_equal 1, @Pushes
end
def username
return 'test_user'
end
def password
return 'test_pass'
end
def service(*args)
super Service::IBMDevOpsServices, *args
end
end