Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit bd13b92

Browse files
committed
Mitmproxy process stop fix; rest-clients tests fix
1 parent ea5f41a commit bd13b92

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

browserup-proxy-core/src/main/java/com/browserup/bup/mitmproxy/MitmProxyProcessManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public void stop() {
122122

123123
if (startedProcess != null) {
124124
Process process = startedProcess.getProcess();
125+
process.children().forEach(ProcessHandle::destroy);
125126
process.destroy();
126127
Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> !process.isAlive());
127128
}

browserup-proxy-core/src/main/resources/mitmproxy/http_connect_capture.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,17 @@ def error(self, flow):
141141

142142
self.har_dump_addon.populate_har_entry_with_default_response(flow)
143143

144-
if 'Name or service not known' in str(original_error):
144+
if self.is_dns_resolution_error(str(original_error)):
145145
self.proxy_to_server_resolution_failed(flow, req_host_port, original_error)
146146
elif isinstance(original_error, TcpTimeout):
147147
self.server_to_proxy_response_timed_out(flow, req_host_port, original_error)
148148
else:
149149
self.proxy_to_server_connection_failed(flow, original_error)
150150

151+
def is_dns_resolution_error(self, error_msg):
152+
return 'getaddrinfo failed' in error_msg \
153+
or 'Name or service not known' in error_msg
154+
151155
# Populate data
152156

153157
def populate_dns_timings(self, flow):

browserup-proxy-rest-clients/src/test/groovy/com/browserup/bup/ruby/RubyClientTest.groovy

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@ class RubyClientTest extends WithRunningProxyRestTest {
5858
container = new GenericContainer(
5959
new ImageFromDockerfile()
6060
.withDockerfile(Paths.get(dockerfile.path)))
61-
.withEnv('PROXY_REST_HOST', 'host.testcontainers.internal')
62-
.withEnv('PROXY_REST_PORT', restServer.connectors[0].localPort as String)
63-
.withEnv('PROXY_PORT', proxy.port as String)
61+
.withEnv('PROXY_REST_HOST', 'host.testcontainers.internal')
62+
.withEnv('PROXY_REST_PORT', restServer.connectors[0].localPort as String)
63+
.withEnv('PROXY_PORT', proxy.port as String)
6464

6565
container.start()
66+
container.followOutput({
67+
LOG.debug('Container log: ' + it.utf8String)
68+
})
6669

67-
Awaitility.await().atMost(10, TimeUnit.SECONDS).until({-> !container.isRunning()})
70+
Awaitility.await().atMost(10, TimeUnit.SECONDS).until({ -> !container.isRunning() })
6871

6972
LOG.info('Docker log: ' + container.getLogs())
7073

browserup-proxy-rest-clients/src/test/javascript/test/javascript_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ var port = process.env.PROXY_PORT;
77
var urlPattern = ".*";
88
var callback = function(error, data, response) {
99
if (error) {
10-
console.error(error);
10+
console.error('Error while calling API: ' + JSON.stringify(error));
1111
throw new Error(error);
1212
} else {
13-
console.log('API called successfully. Returned data: ' + data);
13+
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
1414
}
1515
};
16-
api.entries(port, urlPattern, callback);
16+
api.entries(port, urlPattern, callback);

browserup-proxy-rest-clients/src/test/ruby/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ RUN gem install ./openapi_client-1.0.0.gem
1414
COPY . /ruby/
1515
WORKDIR /ruby/
1616

17+
RUN gem install bundler
18+
RUN bundle update --bundler
1719
RUN bundle config --delete frozen
1820
RUN bundle install
1921

20-
CMD ["bundle", "exec", "rspec", "--backtrace"]
22+
CMD ["bundle", "exec", "rspec", "--backtrace"]

0 commit comments

Comments
 (0)