-
-
Notifications
You must be signed in to change notification settings - Fork 957
Test integration tests #1250
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
Test integration tests #1250
Changes from 20 commits
7c6af7a
4f37634
a504e27
2b20162
547e4a6
f1e652f
f2fe3e1
393a7a1
e26f86b
4cd89e3
0b96523
e7611a5
91e2ce5
83e9b20
2a891a6
ceeb17c
1d3b07e
11aac88
401600d
8b9cae2
179fa7f
c088277
fe010a4
7a4e418
89e84c1
9246e91
05f4a28
2b30996
aeb1492
d768f19
fabf8c7
1b6c73b
49c730c
5129976
06a52e3
a0d6360
914f419
5426cf1
63dbf1c
82cf3bb
cca8ba6
63ef6ef
b2b0b88
6d4e59f
093193c
624486c
df3fb94
24e76e4
ecc0fae
309ae1b
5bcc756
eee3db5
70ab38d
b9764c2
9944991
30a3620
19b0ac6
e10fc14
cf26535
4aebfd2
9399fd9
46cbe42
850e87c
0a0a473
0eb40d6
48ce561
ec33d6d
65e84f9
f850d9b
68cc3a8
03df17d
4336148
2210fa1
64bb26b
e732710
c7c0b66
25e0aac
0c1d4af
ca4536e
e0f9dd0
d96c7f7
edce619
b378cf1
980dbf5
81f8d03
f3ca592
cf23073
06a7444
52d9c68
c2143d3
769863f
e398e63
0251c81
502ef8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md | ||
!**/.gitignore | ||
!.git/HEAD | ||
!.git/config | ||
!.git/packed-refs | ||
!.git/refs/heads/** | ||
!**/Dockerfile.TestServer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
os: Visual Studio 2022 | ||
os: Ubuntu2204 | ||
|
||
before_build: | ||
- nuget restore Renci.SshNet.sln | ||
services: | ||
- docker | ||
|
||
install: | ||
- cinst dotnet-sdk --version=7.0.403 --limit-output | ||
|
||
build: | ||
project: Renci.SshNet.sln | ||
verbosity: minimal | ||
#for testing purposes only | ||
build_script: | ||
- dotnet build test/Renci.SshNet.IntegrationTests/ -c Debug | ||
|
||
test_script: | ||
- cmd: >- | ||
vstest.console /logger:Appveyor test\Renci.SshNet.Tests\bin\Debug\net462\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame | ||
|
||
vstest.console /logger:Appveyor test\Renci.SshNet.Tests\bin\Debug\net7.0\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame | ||
- mkdir artifacts | ||
- sudo tcpdump -i any -c1000 -w artifacts/tcpdump.pcap | ||
#- dotnet test -c Debug --no-restore --no-build --results-directory artifacts --logger "console;verbosity=detailed" --logger "liquid.md;LogFileName=TestReport.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=artifacts/coverage.xml test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj | ||
WojciechNagorski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- ls artifacts | ||
|
||
artifacts: | ||
- path: artifacts | ||
name: artifacts |
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did these changes fix something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the new Dotnet, I wanted to try the new overloaded method What do you think, should I revert this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to revert the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I am fine with removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will revert some changes. I did some of them because I wanted to try if something helped.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Renci.SshNet.Common | ||
{ | ||
#pragma warning disable CA2008 | ||
internal static class AsyncHelper | ||
{ | ||
private static readonly TaskFactory MyTaskFactory = new TaskFactory( | ||
CancellationToken.None, | ||
TaskCreationOptions.None, | ||
TaskContinuationOptions.None, | ||
TaskScheduler.Default); | ||
|
||
public static TResult RunSync<TResult>(Func<Task<TResult>> func) | ||
{ | ||
var cultureUi = CultureInfo.CurrentUICulture; | ||
var culture = CultureInfo.CurrentCulture; | ||
return MyTaskFactory.StartNew(() => | ||
{ | ||
Thread.CurrentThread.CurrentCulture = culture; | ||
Thread.CurrentThread.CurrentUICulture = cultureUi; | ||
return func(); | ||
}).Unwrap().GetAwaiter().GetResult(); | ||
} | ||
|
||
public static void RunSync(Func<Task> func) | ||
{ | ||
var cultureUi = CultureInfo.CurrentUICulture; | ||
var culture = CultureInfo.CurrentCulture; | ||
MyTaskFactory.StartNew(() => | ||
{ | ||
Thread.CurrentThread.CurrentCulture = culture; | ||
Thread.CurrentThread.CurrentUICulture = cultureUi; | ||
return func(); | ||
}).Unwrap().GetAwaiter().GetResult(); | ||
} | ||
} | ||
#pragma warning restore CA2008 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,28 @@ | ||
FROM alpine:latest | ||
|
||
COPY --chown=root:root server/ssh /etc/ssh/ | ||
COPY --chown=root:root server/script /opt/sshnet | ||
COPY user/sshnet /home/sshnet/.ssh | ||
|
||
RUN apk update && apk upgrade --no-cache && \ | ||
apk add --no-cache syslog-ng && \ | ||
# install and configure sshd | ||
apk add --no-cache openssh && \ | ||
# install openssh-server-pam to allow for keyboard-interactive authentication | ||
apk add --no-cache openssh-server-pam && \ | ||
dos2unix /etc/ssh/* && \ | ||
chmod 400 /etc/ssh/ssh*key && \ | ||
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \ | ||
sed -i 's/#LogLevel\s*INFO/LogLevel DEBUG3/' /etc/ssh/sshd_config && \ | ||
# Set the default RSA key | ||
echo 'HostKey /etc/ssh/ssh_host_rsa_key' >> /etc/ssh/sshd_config && \ | ||
chmod 646 /etc/ssh/sshd_config && \ | ||
# install and configure sudo | ||
apk add --no-cache sudo && \ | ||
addgroup sudo && \ | ||
# allow root to run any command | ||
echo 'root ALL=(ALL) ALL' > /etc/sudoers && \ | ||
# allow everyone in the 'sudo' group to run any command without a password | ||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \ | ||
# add user to run most of the integration tests | ||
adduser -D sshnet && \ | ||
passwd -u sshnet && \ | ||
echo 'sshnet:ssh4ever' | chpasswd && \ | ||
dos2unix /home/sshnet/.ssh/* && \ | ||
chown -R sshnet:sshnet /home/sshnet && \ | ||
chmod -R 700 /home/sshnet/.ssh && \ | ||
chmod -R 644 /home/sshnet/.ssh/authorized_keys && \ | ||
# add user to administer container (update configs, restart sshd) | ||
adduser -D sshnetadm && \ | ||
passwd -u sshnetadm && \ | ||
echo 'sshnetadm:ssh4ever' | chpasswd && \ | ||
addgroup sshnetadm sudo && \ | ||
dos2unix /opt/sshnet/* && \ | ||
# install shadow package; we use chage command in this package to expire/unexpire password of the sshnet user | ||
apk add --no-cache shadow && \ | ||
# allow us to use telnet command; we use this in the remote port forwarding tests | ||
apk --no-cache add busybox-extras && \ | ||
# install full-fledged ps command | ||
apk add --no-cache procps | ||
|
||
EXPOSE 22 22 | ||
|
||
ENTRYPOINT ["/opt/sshnet/start.sh"] | ||
FROM mcr.microsoft.com/dotnet/sdk:7.0.403-bullseye-slim AS build | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DEBCONF_NOWARNINGS="yes" | ||
ARG BUILD_CONFIGURATION=Debug | ||
|
||
RUN curl -fsSL https://get.docker.com -o get-docker.sh \ | ||
&& sh get-docker.sh | ||
|
||
WORKDIR /src | ||
|
||
COPY ["test/Directory.Build.props", "test/"] | ||
COPY ["Directory.Build.props", "."] | ||
COPY ["test/Renci.SshNet.IntegrationTests/Dockerfile.TestServer", "test/Renci.SshNet.IntegrationTests/"] | ||
COPY ["test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj", "test/Renci.SshNet.IntegrationTests/"] | ||
COPY ["test/Renci.SshNet.TestTools.OpenSSH/Renci.SshNet.TestTools.OpenSSH.csproj", "test/Renci.SshNet.TestTools.OpenSSH/"] | ||
COPY ["src/Renci.SshNet/Renci.SshNet.csproj", "src/Renci.SshNet/"] | ||
RUN dotnet restore "./test/Renci.SshNet.IntegrationTests/./Renci.SshNet.IntegrationTests.csproj" | ||
|
||
COPY . . | ||
|
||
run ls test/Renci.SshNet.IntegrationTests/ | ||
|
||
WORKDIR "/src/test/Renci.SshNet.IntegrationTests" | ||
RUN dotnet build "./Renci.SshNet.IntegrationTests.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||
|
||
WORKDIR "/src/test/Renci.SshNet.IntegrationTests" | ||
CMD ["dotnet", "test", "--no-restore", "--no-build", "-o", "/app/build", "--results-directory", "artifacts", "--logger", "console;verbosity=detailed", "--logger", "liquid.md;LogFileName=TestReport.md", "-p:CollectCoverage=true", "-p:CoverletOutputFormat=cobertura", "-p:CoverletOutput=artifacts/coverage.xml", "Renci.SshNet.IntegrationTests.csproj"] | ||
|
Uh oh!
There was an error while loading. Please reload this page.