Skip to content

Add support for Feature:API:Driver.IsEncrypted Testkit feature #1152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -61,7 +61,8 @@ public class GetFeatures implements TestkitRequest
"Temporary:FullSummary",
"Temporary:ResultKeys",
"Temporary:TransactionClose",
"Optimization:EagerTransactionBegin"
"Optimization:EagerTransactionBegin",
"Feature:API:Driver.IsEncrypted"
) );

private static final Set<String> SYNC_FEATURES = new HashSet<>( Arrays.asList(
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;
}
}