Skip to content

Commit

Permalink
fix: update Agent tests (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuisathaverat authored Dec 20, 2024
1 parent fcdcfa4 commit e04c942
Show file tree
Hide file tree
Showing 39 changed files with 134 additions and 180 deletions.
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ updates:
- package-ecosystem: "github-actions"
directory: /
schedule:
interval: "daily"
interval: "daily"
- package-ecosystem: "docker"
directory: /src/test/resources/hudson/plugins/sshslaves/agents
schedule:
interval: "daily"
64 changes: 64 additions & 0 deletions .github/workflows/ssh-agent-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
# Workdlow to build the SSH Agent Docker base image used on tests
name: ssh-agent-docker
on:
workflow_dispatch:

permissions:
contents: read

jobs:
docker-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,prefix=base,value=latest,enable={{is_default_branch}}
type=ref,prefix=base,event=branch
type=ref,prefix=base,vent=pr
type=sha,prefix=base
- name: Build and push
uses: docker/build-push-action@v6
id: build
with:
context: src/test/resources/hudson/plugins/sshslaves/agents/ssh-agent-base
platforms: linux/amd64,linux/arm64
push: true
sbom: true
provenance: mode=max
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}

- name: Write Summary
run: |
DOCKER_IMAGE="$(printenv DOCKER_METADATA_OUTPUT_JSON|jq -r '.tags[0]')"
echo "docker pull ${DOCKER_IMAGE}" >> "${GITHUB_STEP_SUMMARY}"

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/
@Ignore("Only for manual test.")
@Category({ AgentSSHTest.class, SSHKeyAuthenticationTest.class})
public class AgentUbuntu2004RSAConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-ubuntu-20.04";
public class AgentUbuntu20RSAConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-ubuntu-20";
public static final String SSH_KEY_PATH = "ssh/rsa-key";
public static final String SSH_KEY_PUB_PATH = "ssh/rsa-key.pub";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package hudson.plugins.sshslaves.agents;

import java.io.IOException;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.images.builder.ImageFromDockerfile;

import hudson.model.Descriptor;
import hudson.model.Node;
import hudson.plugins.sshslaves.categories.AgentSSHTest;
import hudson.plugins.sshslaves.categories.SSHKeyAuthenticationTest;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;

/**
* Connect to a remote SSH Agent
Expand All @@ -20,8 +21,8 @@
*/
@Ignore("Only for manual test.")
@Category({ AgentSSHTest.class, SSHKeyAuthenticationTest.class})
public class AgentUbuntu1404RSAConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-ubuntu-14.04";
public class AgentUbuntu22RSAConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-ubuntu-22";
public static final String SSH_KEY_PATH = "ssh/rsa-key";
public static final String SSH_KEY_PUB_PATH = "ssh/rsa-key.pub";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package hudson.plugins.sshslaves.agents;

import java.io.IOException;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.images.builder.ImageFromDockerfile;

import hudson.model.Descriptor;
import hudson.model.Node;
import hudson.plugins.sshslaves.categories.AgentSSHTest;
import hudson.plugins.sshslaves.categories.SSHKeyAuthenticationTest;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;

/**
* Connect to a remote SSH Agent
Expand All @@ -20,8 +21,8 @@
*/
@Ignore("Only for manual test.")
@Category({ AgentSSHTest.class, SSHKeyAuthenticationTest.class})
public class AgentUbuntu1604RSAConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-ubuntu-16.04";
public class AgentUbuntu24RSAConnectionTest extends AgentConnectionBase {
public static final String SSH_AGENT_NAME = "ssh-agent-ubuntu-24";
public static final String SSH_KEY_PATH = "ssh/rsa-key";
public static final String SSH_KEY_PUB_PATH = "ssh/rsa-key.pub";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
FROM ubuntu:18.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN add-apt-repository ppa:openjdk-r/ppa -y
RUN DEBIAN_FRONTEND="noninteractive" apt-get update -y -qq \
&& apt-get install -y -qq \
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq \
--no-install-recommends \
openssh-server \
software-properties-common \
git \
make

RUN add-apt-repository ppa:openjdk-r/ppa -y \
&& apt-get update -y -qq \
&& apt-get install -y -qq \
make \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

COPY ssh /home/jenkins/.ssh
RUN chown -R jenkins:jenkins /home/jenkins/ \
&& chmod 700 /home/jenkins/.ssh \
&& chmod 600 /home/jenkins/.ssh/*
COPY ssh /root/.ssh
RUN chown -R root:root /root/ \
&& chmod 700 /root/.ssh \
&& chmod 600 /root/.ssh/*
RUN ssh-keygen -A
COPY ssh/sshd_config /etc/ssh/sshd_config
RUN mkdir -p /var/run/sshd

RUN echo "password\npassword" | passwd root \
&& echo "password\npassword" | passwd jenkins

RUN ssh-keygen -A

EXPOSE 22
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-17-openjdk-amd64/jre/bin:/usr/lib/jvm/java-17-openjdk-amd64/bin
RUN echo "PATH=${PATH}" >> /etc/environment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand All @@ -43,4 +43,4 @@ RUN echo "PATH=${PATH}" >> /etc/environment
ENTRYPOINT []
CMD [ "/bin/sh", "-c", "/usr/sbin/sshd -e -D -p 22"]

RUN rm /etc/ssh/ssh_host_dsa* /etc/ssh/ssh_host_ed* /etc/ssh/ssh_host_rsa*
RUN rm /etc/ssh/ssh_host_ed* /etc/ssh/ssh_host_rsa*
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
USER root

ENV TZ=Etc/UTC
Expand All @@ -17,7 +17,7 @@ RUN add-apt-repository ppa:openjdk-r/ppa -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --password password --shell /bin/bash --uid 1000 jenkins \
RUN useradd --password password --shell /bin/bash jenkins \
&& mkdir /home/jenkins \
&& chown -R jenkins:jenkins /home/jenkins

Expand All @@ -43,4 +43,4 @@ RUN echo "PATH=${PATH}" >> /etc/environment
ENTRYPOINT []
CMD [ "/bin/sh", "-c", "/usr/sbin/sshd -e -D -p 22"]

RUN rm /etc/ssh/ssh_host_dsa* /etc/ssh/ssh_host_ec* /etc/ssh/ssh_host_rsa*
RUN rm /etc/ssh/ssh_host_ec* /etc/ssh/ssh_host_rsa*
Loading

0 comments on commit e04c942

Please sign in to comment.