Skip to content

Commit

Permalink
Update deps and cleanup (#836)
Browse files Browse the repository at this point in the history
* Cleanup in ServiceAuthRemoteTest
* Dependencies update
* Fixed unstable ErrorFlowTest
  • Loading branch information
artem-v authored May 28, 2023
1 parent 1af8169 commit 7c924d2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
28 changes: 20 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -57,12 +59,13 @@
</scm>

<properties>
<scalecube-cluster.version>2.6.13</scalecube-cluster.version>
<scalecube-commons.version>1.0.21</scalecube-commons.version>
<scalecube-security.version>1.0.28</scalecube-security.version>
<scalecube-cluster.version>2.6.15</scalecube-cluster.version>
<scalecube-commons.version>1.0.22</scalecube-commons.version>
<scalecube-security.version>1.0.29</scalecube-security.version>

<reactor.version>2020.0.23</reactor.version>
<jackson.version>2.13.3</jackson.version>
<reactor.version>2022.0.7</reactor.version>
<jackson.version>2.15.1</jackson.version>
<netty.version>4.1.92.Final</netty.version>
<rsocket.version>1.1.3</rsocket.version>
<protostuff.version>1.6.0</protostuff.version>
<slf4j.version>1.7.36</slf4j.version>
Expand All @@ -71,7 +74,7 @@
<jsr305.version>3.0.2</jsr305.version>
<jctools.version>2.1.2</jctools.version>

<mockito-junit-jupiter.version>4.6.1</mockito-junit-jupiter.version>
<mockito-junit.version>4.6.1</mockito-junit.version>
<junit-jupiter.version>5.8.2</junit-jupiter.version>
<hamcrest.version>1.3</hamcrest.version>

Expand Down Expand Up @@ -132,6 +135,15 @@
<scope>import</scope>
</dependency>

<!-- Reactor -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>${netty.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -219,7 +231,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-junit-jupiter.version}</version>
<version>${mockito-junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
12 changes: 7 additions & 5 deletions services/src/test/java/io/scalecube/services/ErrorFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static reactor.core.publisher.Mono.from;

import io.scalecube.net.Address;
import io.scalecube.services.api.ServiceMessage;
import io.scalecube.services.discovery.ScalecubeServiceDiscovery;
import io.scalecube.services.exceptions.BadRequestException;
Expand All @@ -29,7 +28,7 @@ public class ErrorFlowTest extends BaseTest {
private static Microservices consumer;

@BeforeAll
public static void initNodes() {
public static void initNodes() throws InterruptedException {
provider =
Microservices.builder()
.discovery(
Expand All @@ -42,19 +41,22 @@ public static void initNodes() {
.services(new GreetingServiceImpl())
.startAwait();

final Address seedAddress = provider.discoveryAddress();

consumer =
Microservices.builder()
.discovery(
endpoint ->
new ScalecubeServiceDiscovery()
.membership(cfg -> cfg.seedMembers(seedAddress))
.membership(cfg -> cfg.seedMembers(provider.discoveryAddress()))
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.transport(cfg -> cfg.port(PORT.incrementAndGet()))
.options(opts -> opts.metadata(endpoint)))
.transport(RSocketServiceTransport::new)
.startAwait();

while (consumer.serviceEndpoints().size() != 1) {
//noinspection BusyWait
Thread.sleep(1);
}
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ static void afterAll() {
@Test
@DisplayName("Successful authentication")
void successfulAuthentication() {
Microservices caller = newCaller();
try {
try (Microservices caller = newCaller()) {
SecuredService securedService = caller.call().api(SecuredService.class);

StepVerifier.create(securedService.helloWithRequest("Bob"))
Expand All @@ -150,16 +149,13 @@ void successfulAuthentication() {
StepVerifier.create(securedService.helloWithRequestAndPrincipal("Bob"))
.assertNext(response -> assertEquals("Hello, Bob and Alice", response))
.verifyComplete();
} finally {
caller.shutdown().block(TIMEOUT);
}
}

@Test
@DisplayName("Authentication failed if authenticator not provided")
void failedAuthenticationWhenAuthenticatorNotProvided() {
Microservices caller = newCaller();
try {
try (Microservices caller = newCaller()) {
AnotherSecuredService securedService = caller.call().api(AnotherSecuredService.class);

Consumer<Throwable> verifyError =
Expand All @@ -179,16 +175,13 @@ void failedAuthenticationWhenAuthenticatorNotProvided() {
StepVerifier.create(securedService.helloWithRequestAndPrincipal("Bob"))
.expectErrorSatisfies(verifyError)
.verify();
} finally {
caller.shutdown().block(TIMEOUT);
}
}

@Test
@DisplayName("Authentication failed with empty credentials")
void failedAuthenticationWithEmptyCredentials() {
Microservices caller = newEmptyCredentialsCaller();
try {
try (Microservices caller = newEmptyCredentialsCaller()) {
SecuredService securedService = caller.call().api(SecuredService.class);

Consumer<Throwable> verifyError =
Expand All @@ -208,16 +201,13 @@ void failedAuthenticationWithEmptyCredentials() {
StepVerifier.create(securedService.helloWithRequestAndPrincipal("Bob"))
.expectErrorSatisfies(verifyError)
.verify();
} finally {
caller.shutdown().block(TIMEOUT);
}
}

@Test
@DisplayName("Authentication failed with invalid credentials")
void failedAuthenticationWithInvalidCredentials() {
Microservices caller = newInvalidCredentialsCaller();
try {
try (Microservices caller = newInvalidCredentialsCaller()) {
SecuredService securedService = caller.call().api(SecuredService.class);

Consumer<Throwable> verifyError =
Expand All @@ -237,32 +227,26 @@ void failedAuthenticationWithInvalidCredentials() {
StepVerifier.create(securedService.helloWithRequestAndPrincipal("Bob"))
.expectErrorSatisfies(verifyError)
.verify();
} finally {
caller.shutdown().block(TIMEOUT);
}
}

@Test
@DisplayName("Successful authentication of partially secured service")
void successfulAuthenticationOnPartiallySecuredService() {
Microservices caller = newCaller();
try {
try (Microservices caller = newCaller()) {
StepVerifier.create(caller.call().api(PartiallySecuredService.class).securedMethod("Alice"))
.assertNext(response -> assertEquals("Hello, Alice", response))
.verifyComplete();
StepVerifier.create(caller.call().api(PartiallySecuredService.class).publicMethod("Alice"))
.assertNext(response -> assertEquals("Hello, Alice", response))
.verifyComplete();
} finally {
caller.shutdown().block(TIMEOUT);
}
}

@Test
@DisplayName("Successful call public method of partially secured service without authentication")
void successfulCallOfPublicMethodWithoutAuthentication() {
Microservices caller = newCaller();
try {
try (Microservices caller = newCaller()) {
StepVerifier.create(caller.call().api(PartiallySecuredService.class).publicMethod("Alice"))
.assertNext(response -> assertEquals("Hello, Alice", response))
.verifyComplete();
Expand All @@ -275,8 +259,6 @@ void successfulCallOfPublicMethodWithoutAuthentication() {

StepVerifier.create(caller.call().api(PartiallySecuredService.class).securedMethod("Alice"))
.verifyErrorSatisfies(verifyError);
} finally {
caller.shutdown().block(TIMEOUT);
}
}

Expand Down

0 comments on commit 7c924d2

Please sign in to comment.