loadrunner 0.0.2 → 0.0.3

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: 3b9fd36357c745fed71eae60ca9b40ee65a4efa9
4
- data.tar.gz: 6bae665acbdf5c16086c7c31f041f6a5e855c78b
3
+ metadata.gz: d485cc0bc26a01f141b992aaed25b970e290470c
4
+ data.tar.gz: a7b1bacff31b40b289b509c626ef07720146334c
5
5
  SHA512:
6
- metadata.gz: baeaa1f2dee184b212ed6e9c0fff2437b05d2d5ed9c553708e383b06dfec022415e01eb7d90aebc131ce8eab26da683e9d6c2446ca2ee1e4619a30525ec40343
7
- data.tar.gz: e99dc43867d5b07839a0e9a94d3e1330e74b803c1ba9a5afaed3d7493b50d4636a3b927651308697662f9777a6ba8938508f10c05f1510005128587477cc0292
6
+ metadata.gz: e5e7b9da7b9302209943c6c1a08acc43230210d9872fcd3d20817f3af9384076d3cc044c589199e13f52c9680c718b496aadf208e3a9599b112abbf96f0f526b
7
+ data.tar.gz: d726f209f0dc7d64c991fc01f546e48d12207b978aaf9bd75ab0676ef14f525938a37addb384dadb4ced30640f6fe186ae3dba81e5865acdd14cd22790105ec7
@@ -1,5 +1,6 @@
1
1
  require 'singleton'
2
2
  require 'docopt'
3
+ require 'awesome_print'
3
4
 
4
5
  module LoadRunner
5
6
 
@@ -33,7 +34,9 @@ module LoadRunner
33
34
  def send
34
35
  client = Client.new client_opts
35
36
  response = client.send args['EVENT'], payload_opts
36
- puts response
37
+
38
+ puts "Reesponse code: #{response.code}"
39
+ ap response
37
40
  end
38
41
 
39
42
  def server
@@ -44,10 +47,13 @@ module LoadRunner
44
47
  def client_opts
45
48
  {
46
49
  base_url: args['URL'],
47
- secret_token: '123'
50
+ secret_token: ENV['GITHUB_SECRET_TOKEN']
48
51
  }
49
52
  end
50
53
 
54
+ # Convert command line arguments to a hash suitable for consumption
55
+ # by Client#send. In essence, we are simply converting the input REF
56
+ # argument, which can come in several forms, to a valid git ref.
51
57
  def payload_opts
52
58
  result = { repo: args['REPO'] }
53
59
 
@@ -57,8 +57,8 @@ module LoadRunner
57
57
  handlers = ["#{base}/#{opts[:event]}"]
58
58
 
59
59
  handlers.tap do |h|
60
- h << "#{base}/#{opts[:event]}@branch-#{opts[:branch]}" if opts[:branch]
61
- h << "#{base}/#{opts[:event]}@tag-#{opts[:tag]}" if opts[:tag]
60
+ h << "#{base}/#{opts[:event]}@branch=#{opts[:branch]}" if opts[:branch]
61
+ h << "#{base}/#{opts[:event]}@tag=#{opts[:tag]}" if opts[:tag]
62
62
  end
63
63
  end
64
64
 
@@ -8,7 +8,7 @@ module LoadRunner
8
8
  request.body.rewind
9
9
  payload_body = request.body.read
10
10
 
11
- verify_signature payload_body if secret_token
11
+ verify_signature payload_body
12
12
 
13
13
  push = ActiveSupport::HashWithIndifferentAccess.new JSON.parse payload_body
14
14
 
@@ -1,9 +1,21 @@
1
1
  module LoadRunner
2
2
  module ServerHelper
3
3
  def verify_signature(payload_body)
4
- signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), secret_token, payload_body)
5
- signature_match = Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])
6
- return halt 401, "Bad Signature" unless signature_match
4
+ request_signature = request.env['HTTP_X_HUB_SIGNATURE']
5
+
6
+ if secret_token and !request_signature
7
+ return halt 401, "Client did not send a signature"
8
+ end
9
+
10
+ if !secret_token and request_signature
11
+ return halt 401, "Server secret token is not configured"
12
+ end
13
+
14
+ if secret_token and request_signature
15
+ signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), secret_token, payload_body)
16
+ signature_match = Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])
17
+ return halt 401, "Signature mismatch" unless signature_match
18
+ end
7
19
  end
8
20
 
9
21
  def secret_token
@@ -1,3 +1,3 @@
1
1
  module LoadRunner
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loadrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-12 00:00:00.000000000 Z
11
+ date: 2017-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: awesome_print
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.8'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.8'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: runfile
71
85
  requirement: !ruby/object:Gem::Requirement