Skip to content

Commit

Permalink
Add support for Feature:API:Driver.IsEncrypted Testkit feature (neo4j…
Browse files Browse the repository at this point in the history
  • Loading branch information
injectives authored Mar 3, 2022
1 parent 5abc24b commit 3edf0e2
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* 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.
*/
package neo4j.org.testkit.backend.messages.requests;

import lombok.Getter;
import lombok.Setter;
import neo4j.org.testkit.backend.TestkitState;
import neo4j.org.testkit.backend.holder.DriverHolder;
import neo4j.org.testkit.backend.messages.responses.DriverIsEncrypted;
import neo4j.org.testkit.backend.messages.responses.TestkitResponse;
import reactor.core.publisher.Mono;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

@Setter
@Getter
public class CheckDriverIsEncrypted implements TestkitRequest
{
private CheckDriverIsEncryptedBody data;

@Override
public TestkitResponse process( TestkitState testkitState )
{
return createResponse( testkitState );
}

@Override
public CompletionStage<TestkitResponse> processAsync( TestkitState testkitState )
{
return CompletableFuture.completedFuture( createResponse( testkitState ) );
}

@Override
public Mono<TestkitResponse> processRx( TestkitState testkitState )
{
return Mono.just( createResponse( testkitState ) );
}

private DriverIsEncrypted createResponse( TestkitState testkitState )
{
DriverHolder driverHolder = testkitState.getDriverHolder( data.getDriverId() );
return DriverIsEncrypted.builder()
.data( DriverIsEncrypted.DriverIsEncryptedBody.builder().encrypted( driverHolder.getDriver().isEncrypted() ).build() )
.build();
}

@Setter
@Getter
public static class CheckDriverIsEncryptedBody
{
private String driverId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class GetFeatures implements TestkitRequest
"Temporary:ResultKeys",
"Temporary:TransactionClose",
"Optimization:EagerTransactionBegin",
"Feature:API:Driver.IsEncrypted",
"Feature:API:SSLConfig",
"Detail:DefaultSecurityConfigValueEquality"
) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@JsonSubTypes.Type( TransactionRollback.class ), @JsonSubTypes.Type( GetFeatures.class ),
@JsonSubTypes.Type( GetRoutingTable.class ), @JsonSubTypes.Type( TransactionClose.class ),
@JsonSubTypes.Type( ResultList.class ), @JsonSubTypes.Type( GetConnectionPoolMetrics.class ),
@JsonSubTypes.Type( ResultPeek.class )
@JsonSubTypes.Type( ResultPeek.class ), @JsonSubTypes.Type( CheckDriverIsEncrypted.class )
} )
public interface TestkitRequest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* 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.
*/
package neo4j.org.testkit.backend.messages.responses;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class DriverIsEncrypted implements TestkitResponse
{
private final DriverIsEncryptedBody data;

@Override
public String testkitName()
{
return "DriverIsEncrypted";
}

@Getter
@Builder
public static class DriverIsEncryptedBody
{
private final boolean encrypted;
}
}

0 comments on commit 3edf0e2

Please sign in to comment.