-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
164 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
docker run -d \ | ||
-e LOG_LEVEL=Info \ | ||
-e AUTH_USER=user \ | ||
-e AUTH_PASSWORD=password \ | ||
--network=arangodb -p 8888:8888 \ | ||
docker.io/kalaksi/tinyproxy:1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
test-functional/src/test-ssl/java/com/arangodb/HttpProxyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* DISCLAIMER | ||
* | ||
* Copyright 2016 ArangoDB GmbH, Cologne, Germany | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
*/ | ||
|
||
package com.arangodb; | ||
|
||
import com.arangodb.entity.ArangoDBVersion; | ||
import com.arangodb.http.HttpProtocolConfig; | ||
import io.netty.handler.proxy.ProxyConnectException; | ||
import io.vertx.core.net.ProxyOptions; | ||
import io.vertx.core.net.ProxyType; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.catchThrowable; | ||
import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
||
|
||
/** | ||
* @author Michele Rastelli | ||
*/ | ||
class HttpProxyTest extends BaseTest { | ||
|
||
@ParameterizedTest | ||
@EnumSource(Protocol.class) | ||
void httpProxy(Protocol protocol) { | ||
assumeTrue(protocol != Protocol.VST); | ||
|
||
final ArangoDB arangoDB = new ArangoDB.Builder() | ||
.protocol(protocol) | ||
.host("172.28.0.1", 8529) | ||
.password("test") | ||
.useSsl(true) | ||
.sslContext(createSslContext()) | ||
.verifyHost(false) | ||
.protocolConfig(HttpProtocolConfig.builder() | ||
.proxyOptions(new ProxyOptions() | ||
.setType(ProxyType.HTTP) | ||
.setHost("172.28.0.1") | ||
.setPort(8888) | ||
.setUsername("user") | ||
.setPassword("password")) | ||
.build()) | ||
.build(); | ||
final ArangoDBVersion version = arangoDB.getVersion(); | ||
assertThat(version).isNotNull(); | ||
} | ||
|
||
|
||
@ParameterizedTest | ||
@EnumSource(Protocol.class) | ||
void httpProxyWrongPassword(Protocol protocol) { | ||
assumeTrue(protocol != Protocol.VST); | ||
|
||
final ArangoDB arangoDB = new ArangoDB.Builder() | ||
.protocol(protocol) | ||
.host("172.28.0.1", 8529) | ||
.password("test") | ||
.useSsl(true) | ||
.sslContext(createSslContext()) | ||
.verifyHost(false) | ||
.protocolConfig(HttpProtocolConfig.builder() | ||
.proxyOptions(new ProxyOptions() | ||
.setType(ProxyType.HTTP) | ||
.setHost("172.28.0.1") | ||
.setPort(8888) | ||
.setUsername("user") | ||
.setPassword("wrong")) | ||
.build()) | ||
.build(); | ||
Throwable thrown = catchThrowable(arangoDB::getVersion); | ||
assertThat(thrown) | ||
.isInstanceOf(ArangoDBException.class) | ||
.hasMessageContaining("Cannot contact any host!") | ||
.cause() | ||
.isInstanceOf(ArangoDBMultipleException.class); | ||
List<Throwable> causes = ((ArangoDBMultipleException) thrown.getCause()).getExceptions(); | ||
assertThat(causes).allSatisfy(e -> assertThat(e) | ||
.isInstanceOf(ProxyConnectException.class) | ||
.hasMessageContaining("status: 401 Unauthorized")); | ||
assertThat(version).isNotNull(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters