lita-jenkins 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e4bae16d034bae22bcb09463001f0713740b7f4
4
- data.tar.gz: 827d8a0c091f77c8f44c7b4cfb1c0991d35cc9e1
3
+ metadata.gz: de14bb62c3dfbc3a6b48a6adb72230dd0f63290f
4
+ data.tar.gz: 292efa6a989179b0e60e90f4232d70d33cf53965
5
5
  SHA512:
6
- metadata.gz: 9ea7092693b33fb132b24db70261bad4e4a581b6e65583cfdffeb7f72cd07aef307a6d017dc4db0abb9002b37244b5275024f3edb2cab75f4aa13dc5073b668a
7
- data.tar.gz: 548703e81c0ca9ea1ca82a175f811cb0b2336b99a74260fbf39239b2c6617e0f8ea1d2df7f86b0bc4947813153c8c152186af2bc7b340d05673506ef1cdf4efb
6
+ metadata.gz: 74010566d3e08326c7618df2bbb3faa371e0bf538c6588bbedf24b20a20511731c3e8fc9bfc9729425f1790707516ea29ac2770fbaaf29e0a560ea11847f27b6
7
+ data.tar.gz: d3a794d404c972effb2735b7f1067adcb02cc8a5a64b64e6fdd743e6d56c9e7ab71fbd7e57e9a14b6abc9c3a8a790652eb24b3a9790910b262e812d9120b5daa
@@ -7,6 +7,7 @@ module Lita
7
7
 
8
8
  config :auth
9
9
  config :url
10
+ config :http_options, required: false, type: Hash, default: {}
10
11
 
11
12
  route /j(?:enkins)? list( (.+))?/i, :jenkins_list, command: true, help: {
12
13
  'jenkins list <filter>' => 'lists Jenkins jobs'
@@ -31,7 +32,7 @@ module Lita
31
32
  named_job_url = job_url(job['name'])
32
33
  path = job_build_url(named_job_url, params)
33
34
 
34
- http_resp = http.post(path) do |req|
35
+ http_resp = http(config.http_options).post(path) do |req|
35
36
  req.headers = headers
36
37
  req.params = params if params.is_a? Hash
37
38
  end
@@ -65,12 +66,12 @@ module Lita
65
66
 
66
67
  def headers
67
68
  {}.tap do |headers|
68
- headers["Authorization"] = "Basic #{Base64.encode64(config.auth).chomp}" if config.auth
69
+ headers["Authorization"] = "Basic #{Base64.strict_encode64(config.auth).chomp}" if config.auth
69
70
  end
70
71
  end
71
72
 
72
73
  def jobs
73
- api_response = http.get(api_url) do |req|
74
+ api_response = http(config.http_options).get(api_url) do |req|
74
75
  req.headers = headers
75
76
  end
76
77
  JSON.parse(api_response.body)["jobs"]
data/lita-jenkins.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-jenkins"
3
- spec.version = "0.0.4"
3
+ spec.version = "0.0.5"
4
4
  spec.authors = ["Daniel Yoon", "Mike Fiedler"]
5
5
  spec.email = ["daniel.kiros@gmail.com", "miketheman@gmail.com"]
6
6
  spec.description = %q{Interact with Jenkins CI server.}
@@ -43,6 +43,49 @@ describe Lita::Handlers::Jenkins, lita_handler: true do
43
43
  return_value = described_class.new(robot).headers
44
44
  expect(return_value.inspect).to eq("{\"Authorization\"=>\"Basic Zm9vOmJhcg==\"}")
45
45
  end
46
+
47
+ it 'encodes auth headers without line breaks' do
48
+ registry.config.handlers.jenkins.auth = "foo:thisisalongtokenthatmighthavelinebreakswithoutstrict"
49
+ return_value = described_class.new(robot).headers
50
+ expect(return_value.inspect).to eq("{\"Authorization\"=>\"Basic Zm9vOnRoaXNpc2Fsb25ndG9rZW50aGF0bWlnaHRoYXZlbGluZWJyZWFrc3dpdGhvdXRzdHJpY3Q=\"}")
51
+ end
52
+ end
53
+
54
+ describe '#http_options' do
55
+ it 'handles no options specified by default' do
56
+ http = described_class.new(robot).http
57
+ expect(http.options.empty?).to be true
58
+ end
59
+
60
+ it 'sets default http options on jobs request' do
61
+ handler = described_class.new(robot)
62
+ expect(handler).to receive(:http).with({}).and_call_original
63
+ allow(response).to receive(:body).and_return(api_response)
64
+ handler.jobs
65
+ end
66
+
67
+ it 'sets default http options for build' do
68
+ expect_any_instance_of(Lita::Handlers::Jenkins).to receive(:http).twice.with({}).and_call_original
69
+ allow(response).to receive(:body).and_return(api_response)
70
+ allow(response).to receive(:status).and_return(201)
71
+ send_command('jenkins b deploy')
72
+ end
73
+
74
+ it 'sets configured http options on jobs request' do
75
+ registry.config.handlers.jenkins.http_options = { url: 'http://test.com' }
76
+ handler = described_class.new(robot)
77
+ expect(handler).to receive(:http).with({ url: 'http://test.com' }).and_call_original
78
+ allow(response).to receive(:body).and_return(api_response)
79
+ handler.jobs
80
+ end
81
+
82
+ it 'sets configured http options for build' do
83
+ registry.config.handlers.jenkins.http_options = { url: 'http://test.com' }
84
+ expect_any_instance_of(Lita::Handlers::Jenkins).to receive(:http).twice.with({ url: 'http://test.com' }).and_call_original
85
+ allow(response).to receive(:body).and_return(api_response)
86
+ allow(response).to receive(:status).and_return(201)
87
+ send_command('jenkins b deploy')
88
+ end
46
89
  end
47
90
 
48
91
  describe '#jenkins list' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-jenkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Yoon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-14 00:00:00.000000000 Z
12
+ date: 2016-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lita
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.4.7
140
+ rubygems_version: 2.5.1
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Interact with Jenkins CI server.