8000 CI: test fix · arangodb/arangodb-java-driver@65eee45 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65eee45

Browse files
committed
CI: test fix
1 parent 7c29d58 commit 65eee45

File tree

2 files changed

+109
-28
lines changed

2 files changed

+109
-28
lines changed

test-functional/src/test-ssl/java/com/arangodb/ArangoSslTest.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
package com.arangodb;
2222

2323
import com.arangodb.entity.ArangoDBVersion;
24-
import com.arangodb.http.HttpProtocolConfig;
25-
import io.vertx.core.net.ProxyOptions;
26-
import io.vertx.core.net.ProxyType;
2724
import org.junit.jupiter.params.ParameterizedTest;
2825
import org.junit.jupiter.params.provider.EnumSource;
2926

@@ -41,31 +38,6 @@
4138
*/
4239
class ArangoSslTest extends BaseTest {
4340

44-
@ParameterizedTest
45-
@EnumSource(Protocol.class)
46-
void httpProxy(Protocol protocol) {
47-
assumeTrue(protocol != Protocol.VST);
48-
49-
final ArangoDB arangoDB = new ArangoDB.Builder()
50-
.protocol(protocol)
51-
.host("172.28.0.1", 8529)
52-
.password("test")
53-
.useSsl(true)
54-
.sslContext(createSslContext())
55-
.verifyHost(false)
56-
.protocolConfig(HttpProtocolConfig.builder()
57-
.proxyOptions(new ProxyOptions()
58-
.setType(ProxyType.HTTP)
59-
.setHost("172.28.0.1")
60-
.setPort(8888)
61-
.setUsername("user")
62-
.setPassword("password"))
63-
.build())
64-
.build();
65-
final ArangoDBVersion version = arangoDB.getVersion();
66-
assertThat(version).isNotNull();
67-
}
68-
6941
@ParameterizedTest
7042
@EnumSource(Protocol.class)
7143
void connect(Protocol protocol) {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb;
22+
23+
import com.arangodb.entity.ArangoDBVersion;
24+
import com.arangodb.http.HttpProtocolConfig;
25+
import io.netty.handler.proxy.ProxyConnectException;
26+
import io.vertx.core.net.ProxyOptions;
27+
import io.vertx.core.net.ProxyType;
28+
import org.junit.jupiter.api.BeforeEach;
29+
import org.junit.jupiter.params.ParameterizedTest;
30+
import org.junit.jupiter.params.provider.EnumSource;
31+
32+
import java.util.List;
33+
34+
import static org.assertj.core.api.Assertions.assertThat;
35+
import static org.assertj.core.api.Assertions.catchThrowable;
36+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
37+
38+
39+
/**
40+
* @author Michele Rastelli
41+
*/
42+
class HttpProxyTest extends BaseTest {
43+
44+
@BeforeEach
45+
void setUp() {
46+
assumeTrue(!PackageVersion.SHADED);
47+
}
48+
49+
@ParameterizedTest
50+
@EnumSource(Protocol.class)
51+
void httpProxy(Protocol protocol) {
52+
assumeTrue(protocol != Protocol.VST);
53+
54+
final ArangoDB arangoDB = new ArangoDB.Builder()
55+
.protocol(protocol)
56+
.host("172.28.0.1", 8529)
57+
.password("test")
58+
.useSsl(true)
59+
.sslContext(createSslContext())
60+
.verifyHost(false)
61+
.protocolConfig(HttpProtocolConfig.builder()
62+
.proxyOptions(new ProxyOptions()
63+
67E6 .setType(ProxyType.HTTP)
64+
.setHost("172.28.0.1")
65+
.setPort(8888)
66+
.setUsername("user")
67+
.setPassword("password"))
68+
.build())
69+
.build();
70+
final ArangoDBVersion version = arangoDB.getVersion();
71+
assertThat(version).isNotNull();
72+
}
73+
74+
75+
@ParameterizedTest
76+
@EnumSource(Protocol.class)
77+
void httpProxyWrongPassword(Protocol protocol) {
78+
assumeTrue(protocol != Protocol.VST);
79+
80+
final ArangoDB arangoDB = new ArangoDB.Builder()
81+
.protocol(protocol)
82+
.host("172.28.0.1", 8529)
83+
.password("test")
84+
.useSsl(true)
85+
.sslContext(createSslContext())
86+
.verifyHost(false)
87+
.protocolConfig(HttpProtocolConfig.builder()
88+
.proxyOptions(new ProxyOptions()
89+
.setType(ProxyType.HTTP)
90+
.setHost("172.28.0.1")
91+
.setPort(8888)
92+
.setUsername("user")
93+
.setPassword("wrong"))
94+
.build())
95+
.build();
96+
Throwable thrown = catchThrowable(arangoDB::getVersion);
97+
assertThat(thrown)
98+
.isInstanceOf(ArangoDBException.class)
99+
.hasMessageContaining("Cannot contact any host!")
100+
.cause()
101+
.isInstanceOf(ArangoDBMultipleException.class);
102+
List<Throwable> causes = ((ArangoDBMultipleException) thrown.getCause()).getExceptions();
103+
assertThat(causes).allSatisfy(e -> assertThat(e)
104+
.isInstanceOf(ProxyConnectException.class)
105+
.hasMessageContaining("status: 401 Unauthorized"));
106+
assertThat(version).isNotNull();
107+
}
108+
109+
}

0 commit comments

Comments
 (0)
0