txgh-server 4.0.0.beta → 4.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/txgh-server/version.rb +1 -1
- data/spec/download_handler_spec.rb +4 -4
- data/spec/helpers/integration_setup.rb +55 -20
- data/spec/integration/cassettes/gitlab_hook_endpoint.yml +446 -0
- data/spec/integration/cassettes/pull.yml +346 -173
- data/spec/integration/cassettes/push.yml +320 -341
- data/spec/integration/cassettes/transifex_hook_endpoint.yml +349 -262
- data/spec/integration/config/tx_gitlab.config +10 -0
- data/spec/integration/hooks_spec.rb +54 -63
- data/spec/integration/payloads/gitlab_postbody.json +62 -0
- data/spec/integration/triggers_spec.rb +11 -4
- data/txgh-server.gemspec +1 -1
- metadata +8 -6
@@ -7,8 +7,7 @@ require 'rack/test'
|
|
7
7
|
require 'helpers/integration_setup'
|
8
8
|
require 'uri'
|
9
9
|
require 'yaml'
|
10
|
-
|
11
|
-
include TxghServer
|
10
|
+
require_relative '../../lib/txgh-server/application'
|
12
11
|
|
13
12
|
describe 'hook integration tests', integration: true do
|
14
13
|
include Rack::Test::Methods
|
@@ -24,43 +23,14 @@ describe 'hook integration tests', integration: true do
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
let(:base_config) do
|
28
|
-
{
|
29
|
-
'github' => {
|
30
|
-
'repos' => {
|
31
|
-
'txgh-bot/txgh-test-resources' => {
|
32
|
-
'api_username' => 'txgh-bot',
|
33
|
-
# github will auto-revoke a token if they notice it in one of your commits ;)
|
34
|
-
'api_token' => Base64.decode64('YjViYWY3Nzk5NTdkMzVlMmI0OGZmYjk4YThlY2M1ZDY0NzAwNWRhZA=='),
|
35
|
-
'push_source_to' => 'test-project-88',
|
36
|
-
'branch' => 'master',
|
37
|
-
'webhook_secret' => '18d3998f576dfe933357104b87abfd61'
|
38
|
-
}
|
39
|
-
}
|
40
|
-
},
|
41
|
-
'transifex' => {
|
42
|
-
'projects' => {
|
43
|
-
'test-project-88' => {
|
44
|
-
'tx_config' => 'file://./config/tx.config',
|
45
|
-
'api_username' => 'txgh.bot',
|
46
|
-
'api_password' => '2aqFGW99fPRKWvXBPjbrxkdiR',
|
47
|
-
'push_translations_to' => 'txgh-bot/txgh-test-resources',
|
48
|
-
'webhook_secret' => 'fce95b1748fd638c22174d34200f10cf',
|
49
|
-
'languages' => ['el_GR']
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
26
|
before(:all) do
|
57
27
|
VCR.configure do |config|
|
58
28
|
config.filter_sensitive_data('<GITHUB_TOKEN>') do
|
59
|
-
base_config[
|
29
|
+
base_config[git_source]['repos']['txgh-bot/txgh-test-resources']['api_token']
|
60
30
|
end
|
61
31
|
|
62
32
|
config.filter_sensitive_data('<TRANSIFEX_PASSWORD>') do
|
63
|
-
base_config['transifex']['projects'][
|
33
|
+
base_config['transifex']['projects'][project_name]['api_password']
|
64
34
|
end
|
65
35
|
end
|
66
36
|
end
|
@@ -81,21 +51,22 @@ describe 'hook integration tests', integration: true do
|
|
81
51
|
File.read(payload_path.join('github_postbody.json'))
|
82
52
|
end
|
83
53
|
|
54
|
+
let(:gitlab_postbody) do
|
55
|
+
File.read(payload_path.join('gitlab_postbody.json'))
|
56
|
+
end
|
57
|
+
|
84
58
|
let(:github_postbody_release) do
|
85
59
|
File.read(payload_path.join('github_postbody_release.json'))
|
86
60
|
end
|
87
61
|
|
88
|
-
let(:project_name) { 'test-project-88' }
|
89
|
-
let(:repo_name) { 'txgh-bot/txgh-test-resources' }
|
90
|
-
|
91
62
|
let(:config) do
|
92
63
|
Txgh::Config::KeyManager.config_from(project_name, repo_name)
|
93
64
|
end
|
94
65
|
|
95
66
|
def sign_github_request(body)
|
96
67
|
header(
|
97
|
-
GithubRequestAuth::GITHUB_HEADER,
|
98
|
-
GithubRequestAuth.compute_signature(
|
68
|
+
TxghServer::GithubRequestAuth::GITHUB_HEADER,
|
69
|
+
TxghServer::GithubRequestAuth.compute_signature(
|
99
70
|
body, config.git_repo.webhook_secret
|
100
71
|
)
|
101
72
|
)
|
@@ -123,38 +94,58 @@ describe 'hook integration tests', integration: true do
|
|
123
94
|
expect(config.project_config).to_not be_nil
|
124
95
|
end
|
125
96
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
'language' => 'el_GR', 'translated' => 100
|
131
|
-
}
|
97
|
+
context 'GitLab' do
|
98
|
+
let(:git_source) { 'gitlab' }
|
99
|
+
let(:repo_name) { 'idanci/txgl-test' }
|
100
|
+
let(:project_name) { 'txgl-test' }
|
132
101
|
|
133
|
-
|
102
|
+
it 'verifies the gitlab hook endpoint works' do
|
103
|
+
VCR.use_cassette('gitlab_hook_endpoint') do
|
104
|
+
header 'X-Gitlab-Token', base_config[git_source]['repos'][repo_name]['webhook_secret']
|
105
|
+
header 'X-GitLab-Event', 'Push Hook'
|
106
|
+
header 'content-type', 'application/x-www-form-urlencoded'
|
107
|
+
post '/gitlab', gitlab_postbody
|
134
108
|
|
135
|
-
|
136
|
-
|
137
|
-
expect(last_response).to be_ok
|
109
|
+
expect(last_response).to be_ok
|
110
|
+
end
|
138
111
|
end
|
139
|
-
end
|
140
112
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
113
|
+
it 'verifies the transifex hook endpoint works' do
|
114
|
+
VCR.use_cassette('transifex_hook_endpoint') do
|
115
|
+
params = {
|
116
|
+
'project' => project_name, 'resource' => 'enyml-heads_test_hook',
|
117
|
+
'language' => 'de', 'translated' => 100
|
118
|
+
}
|
119
|
+
|
120
|
+
payload = params.to_json
|
121
|
+
|
122
|
+
sign_transifex_request(payload)
|
123
|
+
post '/transifex', payload
|
124
|
+
|
125
|
+
expect(last_response).to be_ok
|
126
|
+
end
|
148
127
|
end
|
149
128
|
end
|
150
129
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
130
|
+
context 'GitHub' do
|
131
|
+
it 'verifies the github hook endpoint works' do
|
132
|
+
VCR.use_cassette('github_hook_endpoint') do
|
133
|
+
sign_github_request(github_postbody)
|
134
|
+
header 'X-GitHub-Event', 'push'
|
135
|
+
header 'content-type', 'application/x-www-form-urlencoded'
|
136
|
+
post '/github', github_postbody
|
137
|
+
expect(last_response).to be_ok
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'verifies the github release hook endpoint works' do
|
142
|
+
VCR.use_cassette('github_release_hook_endpoint') do
|
143
|
+
sign_github_request(github_postbody_release)
|
144
|
+
header 'X-GitHub-Event', 'push'
|
145
|
+
header 'content-type', 'application/x-www-form-urlencoded'
|
146
|
+
post '/github', github_postbody_release
|
147
|
+
expect(last_response).to be_ok
|
148
|
+
end
|
158
149
|
end
|
159
150
|
end
|
160
151
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
{
|
2
|
+
"object_kind": "push",
|
3
|
+
"event_name": "push",
|
4
|
+
"before": "d2e8cee2a4119235ea5ffd91e50dc91fe2e6632e",
|
5
|
+
"after": "3bf889a1310b515ec4d8d64a93542977a6dbe106",
|
6
|
+
"ref": "refs/heads/test_hook",
|
7
|
+
"checkout_sha": "3bf889a1310b515ec4d8d64a93542977a6dbe106",
|
8
|
+
"message": null,
|
9
|
+
"user_id": 745271,
|
10
|
+
"user_name": "Ivan Danci",
|
11
|
+
"user_username": "idanci",
|
12
|
+
"user_email": "",
|
13
|
+
"user_avatar": "https://secure.gravatar.com/avatar/dbda838e9b7bca615829ac151e01f3c0?s=80&d=identicon",
|
14
|
+
"project_id": 17514841,
|
15
|
+
"project": {
|
16
|
+
"id": 17514841,
|
17
|
+
"name": "txgl-test",
|
18
|
+
"description": "Test transifex-gitlab",
|
19
|
+
"web_url": "https://gitlab.com/idanci/txgl-test",
|
20
|
+
"avatar_url": null,
|
21
|
+
"git_ssh_url": "git@gitlab.com:idanci/txgl-test.git",
|
22
|
+
"git_http_url": "https://gitlab.com/idanci/txgl-test.git",
|
23
|
+
"namespace": "Ivan Danci",
|
24
|
+
"visibility_level": 20,
|
25
|
+
"path_with_namespace": "idanci/txgl-test",
|
26
|
+
"default_branch": "master",
|
27
|
+
"ci_config_path": null,
|
28
|
+
"homepage": "https://gitlab.com/idanci/txgl-test",
|
29
|
+
"url": "git@gitlab.com:idanci/txgl-test.git",
|
30
|
+
"ssh_url": "git@gitlab.com:idanci/txgl-test.git",
|
31
|
+
"http_url": "https://gitlab.com/idanci/txgl-test.git"
|
32
|
+
},
|
33
|
+
"commits": [
|
34
|
+
{
|
35
|
+
"id": "3bf889a1310b515ec4d8d64a93542977a6dbe106",
|
36
|
+
"message": "Test\n",
|
37
|
+
"title": "Test",
|
38
|
+
"timestamp": "2020-03-26T18:27:52+02:00",
|
39
|
+
"url": "https://gitlab.com/idanci/txgl-test/-/commit/3bf889a1310b515ec4d8d64a93542977a6dbe106",
|
40
|
+
"author": {
|
41
|
+
"name": "Ivan Danci",
|
42
|
+
"email": "bah4uk@gmail.com"
|
43
|
+
},
|
44
|
+
"added": [],
|
45
|
+
"modified": [
|
46
|
+
"config/locales/en.yml"
|
47
|
+
],
|
48
|
+
"removed": []
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"total_commits_count": 1,
|
52
|
+
"push_options": {},
|
53
|
+
"repository": {
|
54
|
+
"name": "txgl-test",
|
55
|
+
"url": "git@gitlab.com:idanci/txgl-test.git",
|
56
|
+
"description": "Test transifex-gitlab",
|
57
|
+
"homepage": "https://gitlab.com/idanci/txgl-test",
|
58
|
+
"git_http_url": "https://gitlab.com/idanci/txgl-test.git",
|
59
|
+
"git_ssh_url": "git@gitlab.com:idanci/txgl-test.git",
|
60
|
+
"visibility_level": 20
|
61
|
+
}
|
62
|
+
}
|
@@ -2,11 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
require 'rack/test'
|
4
4
|
require 'helpers/integration_setup'
|
5
|
+
require_relative '../../lib/txgh-server/application'
|
5
6
|
|
6
7
|
describe 'trigger integration tests', integration: true do
|
7
8
|
include Rack::Test::Methods
|
8
9
|
include IntegrationSetup
|
9
10
|
|
11
|
+
let(:git_source) { 'gitlab' }
|
12
|
+
let(:repo_name) { 'idanci/txgl-test' }
|
13
|
+
let(:project_name) { 'txgl-test' }
|
14
|
+
|
10
15
|
def app
|
11
16
|
@app ||= TxghServer::TriggerEndpoints.new
|
12
17
|
end
|
@@ -20,12 +25,13 @@ describe 'trigger integration tests', integration: true do
|
|
20
25
|
it 'verifies the pull endpoint works' do
|
21
26
|
VCR.use_cassette('pull') do
|
22
27
|
params = {
|
23
|
-
project_slug:
|
24
|
-
resource_slug: '
|
28
|
+
project_slug: project_name,
|
29
|
+
resource_slug: 'enyml-heads_master',
|
25
30
|
branch: 'master'
|
26
31
|
}
|
27
32
|
|
28
33
|
patch '/pull', params
|
34
|
+
|
29
35
|
expect(last_response).to be_ok
|
30
36
|
end
|
31
37
|
end
|
@@ -33,12 +39,13 @@ describe 'trigger integration tests', integration: true do
|
|
33
39
|
it 'verifies the push endpoint works' do
|
34
40
|
VCR.use_cassette('push') do
|
35
41
|
params = {
|
36
|
-
project_slug:
|
37
|
-
resource_slug: '
|
42
|
+
project_slug: project_name,
|
43
|
+
resource_slug: 'enyml-heads_master',
|
38
44
|
branch: 'master'
|
39
45
|
}
|
40
46
|
|
41
47
|
patch '/push', params
|
48
|
+
|
42
49
|
expect(last_response).to be_ok
|
43
50
|
end
|
44
51
|
end
|
data/txgh-server.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency 'sinatra', '~> 1.4'
|
17
17
|
s.add_dependency 'sinatra-contrib', '~> 1.4'
|
18
18
|
s.add_dependency 'rubyzip', '>= 1.0', '<= 1.1.2'
|
19
|
-
s.add_dependency 'txgh', '7.0.0.
|
19
|
+
s.add_dependency 'txgh', '7.0.0.beta2'
|
20
20
|
|
21
21
|
s.require_path = 'lib'
|
22
22
|
s.files = Dir['{lib,spec}/**/*', 'README.md', 'txgh-server.gemspec', 'LICENSE']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txgh-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Jackowski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-03-
|
12
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|
@@ -79,14 +79,14 @@ dependencies:
|
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 7.0.0.
|
82
|
+
version: 7.0.0.beta2
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 7.0.0.
|
89
|
+
version: 7.0.0.beta2
|
90
90
|
description: An HTTP server for interacting with txgh.
|
91
91
|
email:
|
92
92
|
- mattjjacko@gmail.com
|
@@ -150,13 +150,16 @@ files:
|
|
150
150
|
- spec/helpers/gitlab_payload_builder.rb
|
151
151
|
- spec/helpers/integration_setup.rb
|
152
152
|
- spec/helpers/test_request.rb
|
153
|
+
- spec/integration/cassettes/gitlab_hook_endpoint.yml
|
153
154
|
- spec/integration/cassettes/pull.yml
|
154
155
|
- spec/integration/cassettes/push.yml
|
155
156
|
- spec/integration/cassettes/transifex_hook_endpoint.yml
|
156
157
|
- spec/integration/config/tx.config
|
158
|
+
- spec/integration/config/tx_gitlab.config
|
157
159
|
- spec/integration/hooks_spec.rb
|
158
160
|
- spec/integration/payloads/github_postbody.json
|
159
161
|
- spec/integration/payloads/github_postbody_release.json
|
162
|
+
- spec/integration/payloads/gitlab_postbody.json
|
160
163
|
- spec/integration/triggers_spec.rb
|
161
164
|
- spec/spec_helper.rb
|
162
165
|
- spec/tgz_stream_response_spec.rb
|
@@ -196,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
199
|
- !ruby/object:Gem::Version
|
197
200
|
version: 1.3.1
|
198
201
|
requirements: []
|
199
|
-
|
200
|
-
rubygems_version: 2.7.6
|
202
|
+
rubygems_version: 3.0.6
|
201
203
|
signing_key:
|
202
204
|
specification_version: 4
|
203
205
|
summary: An HTTP server for interacting with txgh.
|