Skip to content

Commit 3edf0e2

Browse files
authored
Add support for Feature:API:Driver.IsEncrypted Testkit feature (#1152) (#1170)
1 parent 5abc24b commit 3edf0e2

File tree

4 files changed

+114
-1
lines changed

4 files changed

+114
-1
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package neo4j.org.testkit.backend.messages.requests;
20+
21+
import lombok.Getter;
22+
import lombok.Setter;
23+
import neo4j.org.testkit.backend.TestkitState;
24+
import neo4j.org.testkit.backend.holder.DriverHolder;
25+
import neo4j.org.testkit.backend.messages.responses.DriverIsEncrypted;
26+
import neo4j.org.testkit.backend.messages.responses.TestkitResponse;
27+
import reactor.core.publisher.Mono;
28+
29+
import java.util.concurrent.CompletableFuture;
30+
import java.util.concurrent.CompletionStage;
31+
32+
@Setter
33+
@Getter
34+
public class CheckDriverIsEncrypted implements TestkitRequest
35+
{
36+
private CheckDriverIsEncryptedBody data;
37+
38+
@Override
39+
public TestkitResponse process( TestkitState testkitState )
40+
{
41+
return createResponse( testkitState );
42+
}
43+
44+
@Override
45+
public CompletionStage<TestkitResponse> processAsync( TestkitState testkitState )
46+
{
47+
return CompletableFuture.completedFuture( createResponse( testkitState ) );
48+
}
49+
50+
@Override
51+
public Mono<TestkitResponse> processRx( TestkitState testkitState )
52+
{
53+
return Mono.just( createResponse( testkitState ) );
54+
}
55+
56+
private DriverIsEncrypted createResponse( TestkitState testkitState )
57+
{
58+
DriverHolder driverHolder = testkitState.getDriverHolder( data.getDriverId() );
59+
return DriverIsEncrypted.builder()
60+
.data( DriverIsEncrypted.DriverIsEncryptedBody.builder().encrypted( driverHolder.getDriver().isEncrypted() ).build() )
61+
.build();
62+
}
63+
64+
@Setter
65+
@Getter
66+
public static class CheckDriverIsEncryptedBody
67+
{
68+
private String driverId;
69+
}
70+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class GetFeatures implements TestkitRequest
6363
"Temporary:ResultKeys",
6464
"Temporary:TransactionClose",
6565
"Optimization:EagerTransactionBegin",
66+
"Feature:API:Driver.IsEncrypted",
6667
"Feature:API:SSLConfig",
6768
"Detail:DefaultSecurityConfigValueEquality"
6869
) );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
@JsonSubTypes.Type( TransactionRollback.class ), @JsonSubTypes.Type( GetFeatures.class ),
4242
@JsonSubTypes.Type( GetRoutingTable.class ), @JsonSubTypes.Type( TransactionClose.class ),
4343
@JsonSubTypes.Type( ResultList.class ), @JsonSubTypes.Type( GetConnectionPoolMetrics.class ),
44-
@JsonSubTypes.Type( ResultPeek.class )
44+
@JsonSubTypes.Type( ResultPeek.class ), @JsonSubTypes.Type( CheckDriverIsEncrypted.class )
4545
} )
4646
public interface TestkitRequest
4747
{
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package neo4j.org.testkit.backend.messages.responses;
20+
21+
import lombok.Builder;
22+
import lombok.Getter;
23+
24+
@Getter
25+
@Builder
26+
public class DriverIsEncrypted implements TestkitResponse
27+
{
28+
private final DriverIsEncryptedBody data;
29+
30+
@Override
31+
public String testkitName()
32+
{
33+
return "DriverIsEncrypted";
34+
}
35+
36+
@Getter
37+
@Builder
38+
public static class DriverIsEncryptedBody
39+
{
40+
private final boolean encrypted;
41+
}
42+
}

0 commit comments

Comments
 (0)