Skip to content

Commit 637e377

Browse files
fbivilleinjectives
authored andcommitted
Skip more unknown timezone tests (neo4j#1269)
These are currently passing by coincidence, as TestKit stub server silently swallows the error, resulting from the Java driver early connection close.
1 parent f40f45d commit 637e377

File tree

4 files changed

+66
-54
lines changed

4 files changed

+66
-54
lines changed

driver/src/main/java/org/neo4j/driver/AuthTokens.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,34 @@ public static AuthToken custom(String principal, String credentials, String real
126126

127127
/**
128128
* A custom authentication token used for doing custom authentication on the server side.
129-
* @param principal this used to identify who this token represents
129+
*
130+
* @param principal this used to identify who this token represents
130131
* @param credentials this is credentials authenticating the principal
131-
* @param realm this is the "realm:, specifying the authentication provider.
132-
* @param scheme this it the authentication scheme, specifying what kind of authentication that should be used
133-
* @param parameters extra parameters to be sent along the authentication provider.
132+
* @param realm this is the "realm:", specifying the authentication provider.
133+
* @param scheme this is the authentication scheme, specifying what kind of authentication that should be used
134+
* @param parameters extra parameters to be sent along the authentication provider.
134135
* @return an authentication token that can be used to connect to Neo4j
136+
* @throws NullPointerException when scheme is {@code null}
135137
* @see GraphDatabase#driver(String, AuthToken)
136-
* @throws NullPointerException when either principal, credentials or scheme is {@code null}
137138
*/
138-
public static AuthToken custom(
139-
String principal, String credentials, String realm, String scheme, Map<String, Object> parameters) {
140-
Objects.requireNonNull(principal, "Principal can't be null");
141-
Objects.requireNonNull(credentials, "Credentials can't be null");
142-
Objects.requireNonNull(scheme, "Scheme can't be null");
139+
public static AuthToken custom( String principal, String credentials, String realm, String scheme, Map<String,Object> parameters )
140+
{
141+
Objects.requireNonNull( scheme, "Scheme can't be null" );
143142

144-
Map<String, Value> map = newHashMapWithSize(5);
145-
map.put(SCHEME_KEY, value(scheme));
146-
map.put(PRINCIPAL_KEY, value(principal));
147-
map.put(CREDENTIALS_KEY, value(credentials));
148-
if (realm != null) {
149-
map.put(REALM_KEY, value(realm));
143+
Map<String,Value> map = newHashMapWithSize( 5 );
144+
map.put( SCHEME_KEY, value( scheme ) );
145+
map.put( PRINCIPAL_KEY, value( principal != null ? principal : "" ) );
146+
if ( credentials != null && !credentials.isEmpty() )
147+
{
148+
map.put( CREDENTIALS_KEY, value( credentials ) );
149+
}
150+
if ( realm != null && !realm.isEmpty() )
151+
{
152+
map.put( REALM_KEY, value( realm ) );
150153
}
151-
if (parameters != null) {
152-
map.put(PARAMETERS_KEY, value(parameters));
154+
if ( parameters != null && !parameters.isEmpty() )
155+
{
156+
map.put( PARAMETERS_KEY, value( parameters ) );
153157
}
154158
return new InternalAuthToken(map);
155159
}

driver/src/test/java/org/neo4j/driver/AuthTokensTest.java

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import static org.hamcrest.core.IsEqual.equalTo;
2323
import static org.hamcrest.junit.MatcherAssert.assertThat;
2424
import static org.junit.jupiter.api.Assertions.assertEquals;
25+
import static org.junit.jupiter.api.Assertions.assertFalse;
2526
import static org.junit.jupiter.api.Assertions.assertThrows;
27+
import static org.junit.jupiter.api.Assertions.assertTrue;
2628
import static org.neo4j.driver.AuthTokens.basic;
2729
import static org.neo4j.driver.AuthTokens.custom;
2830
import static org.neo4j.driver.Values.values;
@@ -42,10 +44,10 @@ void basicAuthWithoutRealm() {
4244

4345
Map<String, Value> map = basic.toMap();
4446

45-
assertThat(map.size(), equalTo(3));
46-
assertThat(map.get("scheme"), equalTo((Value) new StringValue("basic")));
47-
assertThat(map.get("principal"), equalTo((Value) new StringValue("foo")));
48-
assertThat(map.get("credentials"), equalTo((Value) new StringValue("bar")));
47+
assertThat( map.size(), equalTo( 3 ) );
48+
assertThat( map.get( "scheme" ), equalTo( new StringValue( "basic" ) ) );
49+
assertThat( map.get( "principal" ), equalTo( new StringValue( "foo" ) ) );
50+
assertThat( map.get( "credentials" ), equalTo( new StringValue( "bar" ) ) );
4951
}
5052

5153
@Test
@@ -54,11 +56,11 @@ void basicAuthWithRealm() {
5456

5557
Map<String, Value> map = basic.toMap();
5658

57-
assertThat(map.size(), equalTo(4));
58-
assertThat(map.get("scheme"), equalTo((Value) new StringValue("basic")));
59-
assertThat(map.get("principal"), equalTo((Value) new StringValue("foo")));
60-
assertThat(map.get("credentials"), equalTo((Value) new StringValue("bar")));
61-
assertThat(map.get("realm"), equalTo((Value) new StringValue("baz")));
59+
assertThat( map.size(), equalTo( 4 ) );
60+
assertThat( map.get( "scheme" ), equalTo( new StringValue( "basic" ) ) );
61+
assertThat( map.get( "principal" ), equalTo( new StringValue( "foo" ) ) );
62+
assertThat( map.get( "credentials" ), equalTo( new StringValue( "bar" ) ) );
63+
assertThat( map.get( "realm" ), equalTo( new StringValue( "baz" ) ) );
6264
}
6365

6466
@Test
@@ -67,11 +69,11 @@ void customAuthWithoutParameters() {
6769

6870
Map<String, Value> map = basic.toMap();
6971

70-
assertThat(map.size(), equalTo(4));
71-
assertThat(map.get("scheme"), equalTo((Value) new StringValue("my_scheme")));
72-
assertThat(map.get("principal"), equalTo((Value) new StringValue("foo")));
73-
assertThat(map.get("credentials"), equalTo((Value) new StringValue("bar")));
74-
assertThat(map.get("realm"), equalTo((Value) new StringValue("baz")));
72+
assertThat( map.size(), equalTo( 4 ) );
73+
assertThat( map.get( "scheme" ), equalTo( new StringValue( "my_scheme" ) ) );
74+
assertThat( map.get( "principal" ), equalTo( new StringValue( "foo" ) ) );
75+
assertThat( map.get( "credentials" ), equalTo( new StringValue( "bar" ) ) );
76+
assertThat( map.get( "realm" ), equalTo( new StringValue( "baz" ) ) );
7577
}
7678

7779
@Test
@@ -80,16 +82,16 @@ void customAuthParameters() {
8082
parameters.put("list", asList(1, 2, 3));
8183
InternalAuthToken basic = (InternalAuthToken) custom("foo", "bar", "baz", "my_scheme", parameters);
8284

83-
Map<String, Value> expectedParameters = new HashMap<>();
84-
expectedParameters.put("list", new ListValue(values(1, 2, 3)));
85-
Map<String, Value> map = basic.toMap();
85+
Map<String,Value> expectedParameters = new HashMap<>();
86+
expectedParameters.put( "list", new ListValue( values( 1, 2, 3 ) ) );
87+
Map<String,Value> map = basic.toMap();
8688

87-
assertThat(map.size(), equalTo(5));
88-
assertThat(map.get("scheme"), equalTo((Value) new StringValue("my_scheme")));
89-
assertThat(map.get("principal"), equalTo((Value) new StringValue("foo")));
90-
assertThat(map.get("credentials"), equalTo((Value) new StringValue("bar")));
91-
assertThat(map.get("realm"), equalTo((Value) new StringValue("baz")));
92-
assertThat(map.get("parameters"), equalTo((Value) new MapValue(expectedParameters)));
89+
assertThat( map.size(), equalTo( 5 ) );
90+
assertThat( map.get( "scheme" ), equalTo( new StringValue( "my_scheme" ) ) );
91+
assertThat( map.get( "principal" ), equalTo( new StringValue( "foo" ) ) );
92+
assertThat( map.get( "credentials" ), equalTo( new StringValue( "bar" ) ) );
93+
assertThat( map.get( "realm" ), equalTo( new StringValue( "baz" ) ) );
94+
assertThat( map.get( "parameters" ), equalTo( new MapValue( expectedParameters ) ) );
9395
}
9496

9597
@Test
@@ -112,10 +114,10 @@ void basicKerberosAuthWithRealm() {
112114
InternalAuthToken token = (InternalAuthToken) AuthTokens.kerberos("base64");
113115
Map<String, Value> map = token.toMap();
114116

115-
assertThat(map.size(), equalTo(3));
116-
assertThat(map.get("scheme"), equalTo((Value) new StringValue("kerberos")));
117-
assertThat(map.get("principal"), equalTo((Value) new StringValue("")));
118-
assertThat(map.get("credentials"), equalTo((Value) new StringValue("base64")));
117+
assertThat( map.size(), equalTo( 3 ) );
118+
assertThat( map.get( "scheme" ), equalTo( new StringValue( "kerberos" ) ) );
119+
assertThat( map.get( "principal" ), equalTo( new StringValue( "" ) ) );
120+
assertThat( map.get( "credentials" ), equalTo( new StringValue( "base64" ) ) );
119121
}
120122

121123
@Test
@@ -154,17 +156,19 @@ void shouldNotAllowKerberosAuthTokenWithNullTicket() {
154156
}
155157

156158
@Test
157-
void shouldNotAllowCustomAuthTokenWithNullPrincipal() {
158-
NullPointerException e = assertThrows(
159-
NullPointerException.class, () -> AuthTokens.custom(null, "credentials", "realm", "scheme"));
160-
assertEquals("Principal can't be null", e.getMessage());
159+
void shouldAllowCustomAuthTokenWithNullPrincipal()
160+
{
161+
InternalAuthToken token = (InternalAuthToken) AuthTokens.custom( null, "credentials", "realm", "scheme" );
162+
163+
assertTrue( token.toMap().containsKey( InternalAuthToken.PRINCIPAL_KEY ) );
161164
}
162165

163166
@Test
164-
void shouldNotAllowCustomAuthTokenWithNullCredentials() {
165-
NullPointerException e =
166-
assertThrows(NullPointerException.class, () -> AuthTokens.custom("principal", null, "realm", "scheme"));
167-
assertEquals("Credentials can't be null", e.getMessage());
167+
void shouldAllowCustomAuthTokenWithNullCredentials()
168+
{
169+
InternalAuthToken token = (InternalAuthToken) AuthTokens.custom( "principal", null, "realm", "scheme" );
170+
171+
assertFalse( token.toMap().containsKey( InternalAuthToken.CREDENTIALS_KEY ) );
168172
}
169173

170174
@Test

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/GetFeatures.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public class GetFeatures implements TestkitRequest {
5858
"Optimization:ImplicitDefaultArguments",
5959
"Feature:Bolt:Patch:UTC",
6060
"Feature:API:Type.Temporal",
61-
"Feature:API:UpdateRoutingTableTimeout"));
61+
"Feature:API:UpdateRoutingTableTimeout",
62+
"Optimization:ImplicitDefaultArguments"));
6263

6364
private static final Set<String> SYNC_FEATURES = new HashSet<>(Arrays.asList(
6465
"Feature:Bolt:3.0",

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/StartTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public class StartTest implements TestkitRequest {
8686
COMMON_SKIP_PATTERN_TO_REASON.put(
8787
"^.*\\.test_unknown_then_known_zoned_date_time(_patched)?$",
8888
"Unknown zone names make the driver close the connection.");
89+
COMMON_SKIP_PATTERN_TO_REASON.put(
90+
"^.*\\.test_unknown_zoned_date_time(_patched)?$",
91+
"Unknown zone names make the driver close the connection.");
8992

9093
ASYNC_SKIP_PATTERN_TO_REASON.putAll(COMMON_SKIP_PATTERN_TO_REASON);
9194

0 commit comments

Comments
 (0)