loadrunner 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/load_runner/client.rb +13 -3
- data/lib/load_runner/command_line.rb +2 -1
- data/lib/load_runner/docopt.txt +8 -4
- data/lib/load_runner/server.rb +6 -1
- data/lib/load_runner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f956c6c96502b4a447c61d0ba22965de6384a5388979160538eadf19554a60a1
|
4
|
+
data.tar.gz: d34ffbdb98ecf2c288655456ac527ef56ebf87cbaa8d6c8849cfc3acca33e656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc5af284ca6ad9dd20a8c24debce0d774653a30dfbcdce33f8afbda5fb192a9afc8e2e22045dab4c12cb5f598f1f22bf32d2a58b509d00ffb5b73190d807f4d
|
7
|
+
data.tar.gz: 5f62450212ac311be7baad8ee8c55729d6f026e351766e5e252977655453a6b8a034321991dd1e3bde1fddeb80801cd54e6551a4515e78441f1c74c44313fd30
|
data/README.md
CHANGED
data/lib/load_runner/client.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
module LoadRunner
|
4
5
|
|
5
6
|
# Send simulated GitHub events to any webhook server
|
6
7
|
class Client
|
7
8
|
include HTTParty
|
8
|
-
attr_accessor :secret_token, :base_url, :payload
|
9
|
+
attr_accessor :secret_token, :base_url, :payload, :encoding
|
9
10
|
|
10
11
|
def initialize(opts={})
|
11
12
|
@secret_token = opts[:secret_token]
|
12
13
|
@base_url = opts[:base_url] || 'localhost:3000/payload'
|
14
|
+
@encoding = opts[:encoding] || :json
|
13
15
|
self.class.base_uri base_url
|
14
16
|
end
|
15
17
|
|
@@ -27,8 +29,8 @@ module LoadRunner
|
|
27
29
|
# Send a simulated event. Payload can be a hash or a JSON string.
|
28
30
|
def send_payload(event, payload)
|
29
31
|
@payload = payload.is_a?(String) ? payload : payload.to_json
|
30
|
-
|
31
|
-
self.class.post "", body: @payload, headers: headers
|
32
|
+
@payload = URI.encode_www_form(payload: @payload) if encoding == :form
|
33
|
+
self.class.post "", body: @payload, headers: headers(event)
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
@@ -37,6 +39,7 @@ module LoadRunner
|
|
37
39
|
{}.tap do |header|
|
38
40
|
header['X_GITHUB_EVENT'] = event.to_s if event
|
39
41
|
header['X_HUB_SIGNATURE'] = signature if secret_token
|
42
|
+
header['Content-Type'] = content_type[encoding]
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -71,5 +74,12 @@ module LoadRunner
|
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
77
|
+
def content_type
|
78
|
+
{
|
79
|
+
json: 'application/json',
|
80
|
+
form: 'application/x-www-form-urlencoded',
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
74
84
|
end
|
75
85
|
end
|
data/lib/load_runner/docopt.txt
CHANGED
@@ -2,7 +2,7 @@ LoadRunner
|
|
2
2
|
|
3
3
|
Usage:
|
4
4
|
loadrunner server [--port N --bind IP]
|
5
|
-
loadrunner send URL REPO EVENT [REF]
|
5
|
+
loadrunner send URL REPO EVENT [REF --form]
|
6
6
|
loadrunner status REPO SHA STATE [--context TEXT --desc TEXT --url URL]
|
7
7
|
loadrunner (-h|--help|--version)
|
8
8
|
|
@@ -18,8 +18,9 @@ Commands:
|
|
18
18
|
|
19
19
|
Parameters:
|
20
20
|
URL
|
21
|
-
The URL of the webhook
|
22
|
-
|
21
|
+
The URL of the webhook endpoint. This path should responds
|
22
|
+
to POST requests. If you are sending an event to a loadrunner server,
|
23
|
+
send it to the /payload endpoint (e.g. localhost:3000/payload).
|
23
24
|
|
24
25
|
REPO
|
25
26
|
The name of the repository. This can be either the short name
|
@@ -57,6 +58,9 @@ Options:
|
|
57
58
|
--desc TEXT
|
58
59
|
A short description of the status.
|
59
60
|
|
61
|
+
--form
|
62
|
+
Send request as x-www-form-urlencoded instead of sending JSON.
|
63
|
+
|
60
64
|
Environment Variables:
|
61
65
|
GITHUB_SECRET_TOKEN=y0urk3y
|
62
66
|
Set Your GitHub secret token as set in your webhook.
|
@@ -68,7 +72,7 @@ Examples:
|
|
68
72
|
# Simulate push events
|
69
73
|
loadrunner send localhost:3000/payload my_repo push master
|
70
74
|
loadrunner send localhost:3000/payload my_repo push branch=master
|
71
|
-
loadrunner send localhost:3000/payload my_repo push tag=staging
|
75
|
+
loadrunner send localhost:3000/payload my_repo push tag=staging --form
|
72
76
|
loadrunner send localhost:3000/payload my_repo push refs/tags/staging
|
73
77
|
|
74
78
|
# Start the server
|
data/lib/load_runner/server.rb
CHANGED
@@ -18,7 +18,12 @@ module LoadRunner
|
|
18
18
|
|
19
19
|
halt 401, halt_messages[state] if state != :ok
|
20
20
|
|
21
|
-
|
21
|
+
if request.content_type == 'application/json'
|
22
|
+
json_string = payload_body
|
23
|
+
else
|
24
|
+
json_string = URI.decode_www_form(payload_body).to_h["payload"]
|
25
|
+
end
|
26
|
+
push = ActiveSupport::HashWithIndifferentAccess.new JSON.parse json_string
|
22
27
|
|
23
28
|
opts = {}
|
24
29
|
opts[:repo] = push.dig(:repository, :name)
|
data/lib/load_runner/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
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: 2018-04-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: super_docopt
|