Skip to content

Commit

Permalink
Introduce integration-tests
Browse files Browse the repository at this point in the history
Cleanup build descriptors

Add integration tests

Update workflows
  • Loading branch information
gastaldi committed Apr 12, 2024
1 parent fee6a97 commit 8132bbf
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 118 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ jobs:
run: git config --global core.autocrlf false
if: startsWith(matrix.os, 'windows')

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
Expand All @@ -56,4 +57,4 @@ jobs:
run: mvn -B clean install -Dno-format

- name: Build with Maven (Native)
run: mvn -B install -Dnative -Dquarkus.native.container-build -Dnative.surefire.skip
run: mvn -B install -Dnative -Dquarkus.native.container-build -Dnative.surefire.skip
8 changes: 4 additions & 4 deletions .github/workflows/quarkus-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ jobs:
uses: dcarbone/[email protected]

- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}

- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: current-repo

- name: Checkout Ecosystem
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ env.ECOSYSTEM_CI_REPO }}
path: ecosystem-ci

- name: Setup and Run Tests
run: ./ecosystem-ci/setup-and-test
env:
ECOSYSTEM_CI_TOKEN: ${{ secrets.ECOSYSTEM_CI_TOKEN }}
ECOSYSTEM_CI_TOKEN: ${{ secrets.ECOSYSTEM_CI_TOKEN }}
14 changes: 5 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,19 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
metadata-file-path: '.github/project.yml'

- uses: actions/checkout@v3

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Configure Git author
run: |
Expand All @@ -67,6 +62,7 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Push changes to ${{github.base_ref}} branch
run: |
Expand Down
8 changes: 2 additions & 6 deletions deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-sshd-deployment</artifactId>
<name>Quarkus Apache sshd Quarkus extention - Deployment</name>
<name>Quarkus Apache SSHD - Deployment</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security-deployment</artifactId>
Expand Down Expand Up @@ -48,4 +44,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.security.KeyFactory;
import java.security.KeyPairGenerator;
import java.security.Signature;
import java.util.Arrays;

import javax.crypto.KeyAgreement;
import javax.crypto.Mac;
Expand Down Expand Up @@ -48,12 +47,10 @@ NativeImageResourceBuildItem nativeImageResourceBuildItem() {

@BuildStep
void sessionProxy(BuildProducer<NativeImageProxyDefinitionBuildItem> proxiesProducer) {
for (String s : Arrays.asList(
proxiesProducer.produce(new NativeImageProxyDefinitionBuildItem(
SessionListener.class.getName(),
ChannelListener.class.getName(),
PortForwardingEventListener.class.getName())) {
proxiesProducer.produce(new NativeImageProxyDefinitionBuildItem(s));
}
PortForwardingEventListener.class.getName()));
}

}
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>quarkus-sshd-docs</artifactId>
<name>Quarkus Apache sshd Quarkus extention - Documentation</name>
<name>Quarkus Apache SSHD - Documentation</name>

<dependencies>
<!-- Make sure the doc is built after the other artifacts -->
Expand Down
92 changes: 92 additions & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.sshd</groupId>
<artifactId>quarkus-sshd-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-sshd-integration-tests</artifactId>
<name>Quarkus Apache SSHD - Integration Tests</name>
<dependencies>
<dependency>
<groupId>io.quarkiverse.sshd</groupId>
<artifactId>quarkus-sshd</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native-image</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${native.surefire.skip}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.additional-build-args>--initialize-at-run-time=org.apache.activemq.artemis.api.core.ActiveMQBuffers\,org.apache.activemq.artemis.utils.RandomUtil</quarkus.native.additional-build-args>
</properties>
</profile>
</profiles>

</project>
30 changes: 30 additions & 0 deletions integration-tests/src/test/java/io/quarkiverse/sshd/SmokeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkiverse.sshd;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;

import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.client.simple.SimpleClient;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Test;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
@QuarkusTestResource(value = SshdServerTestResource.class, restrictToAnnotatedClass = true)
public class SmokeTest {

@Test
void shouldOpenSession() throws IOException {
String host = ConfigProvider.getConfig().getValue("quarkiverse.sshd.host", String.class);
int port = ConfigProvider.getConfig().getValue("quarkiverse.sshd.port", Integer.class);
try (SimpleClient client = SshClient.setUpDefaultSimpleClient()) {
try (ClientSession clientSession = client.sessionLogin(host, port, "anonymous", "anonymous")) {
assertThat(clientSession).isNotNull();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkiverse.sshd;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class SmokeTestIT extends SmokeTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.quarkiverse.sshd;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.util.Map;

import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.hostbased.AcceptAllHostBasedAuthenticator;
import org.apache.sshd.server.auth.password.AcceptAllPasswordAuthenticator;
import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.shell.UnknownCommandFactory;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;

public class SshdServerTestResource implements QuarkusTestResourceLifecycleManager {

private SshServer sshd;

@Override
public Map<String, String> start() {
try {
sshd = SshServer.setUpDefaultServer();
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(Files.createTempFile("host", "key")));
sshd.setHostBasedAuthenticator(AcceptAllHostBasedAuthenticator.INSTANCE);
sshd.setPasswordAuthenticator(AcceptAllPasswordAuthenticator.INSTANCE);
sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
sshd.setCommandFactory(UnknownCommandFactory.INSTANCE);
sshd.setIoServiceFactoryFactory(new Nio2ServiceFactoryFactory());
sshd.setHost("localhost");
sshd.start();
return Map.of(
"quarkiverse.sshd.host", sshd.getHost(),
"quarkiverse.sshd.port", Integer.toString(sshd.getPort()));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

@Override
public void stop() {
try {
sshd.stop(true);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
Loading

0 comments on commit 8132bbf

Please sign in to comment.