-
-
Notifications
You must be signed in to change notification settings - Fork 931
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
Move Integration tests #1173
Merged
WojciechNagorski
merged 16 commits into
sshnet:develop
from
WojciechNagorski:integration-tests-move-tests
Sep 12, 2023
Merged
Move Integration tests #1173
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
95b8933
Renci.SshNet.IntegrationTests
WojciechNagorski bc98501
Renci.SshNet.TestTools.OpenSSH
WojciechNagorski f677cef
Move integration tests to main repo
WojciechNagorski 0e2a45c
Merge branch 'develop' into integration-tests-move-tests
WojciechNagorski e44f631
Move old tests to new integration tests
WojciechNagorski 051a1c5
Move old integration tests to new integration tests
WojciechNagorski a590aaa
Move more tests
WojciechNagorski df6fbdb
Move authentication tests
WojciechNagorski e2df8ff
Move SshClientTests
WojciechNagorski a8d8bcd
Fix some tests
WojciechNagorski e59188b
Remove duplicated test
WojciechNagorski d76a711
Poc of ProcessDisruptor
WojciechNagorski e78383e
Rename
WojciechNagorski f39a0ff
Some fixes
WojciechNagorski 796cc0a
Remove performance tests
WojciechNagorski b18d102
Small improvements
WojciechNagorski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TestResults/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<system.diagnostics> | ||
<trace autoflush="true"/> | ||
<sources> | ||
<source name="SshNet.Logging" switchName="SshNetSwitch" switchType="System.Diagnostics.SourceSwitch"> | ||
<listeners> | ||
<!--<add name="SshDotNetTraceFile" />--> | ||
<!--<add name="Console"/>--> | ||
</listeners> | ||
</source> | ||
</sources> | ||
<switches> | ||
<add name="SshNetSwitch" value="Verbose"/> | ||
</switches> | ||
<sharedListeners> | ||
<add name="SshDotNetTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="SshNetTrace.log"> | ||
<!--<filter type="System.Diagnostics.EventTypeFilter" initializeData="Warning" />--> | ||
</add> | ||
<add name="Console" type="System.Diagnostics.ConsoleTraceListener" traceOutputOptions="DateTime,Timestamp,ThreadId"/> | ||
</sharedListeners> | ||
</system.diagnostics> | ||
</configuration> |
84 changes: 84 additions & 0 deletions
84
src/Renci.SshNet.IntegrationTests/AuthenticationMethodFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
namespace Renci.SshNet.IntegrationTests | ||
{ | ||
public class AuthenticationMethodFactory | ||
{ | ||
public PasswordAuthenticationMethod CreatePowerUserPasswordAuthenticationMethod() | ||
{ | ||
var user = Users.Admin; | ||
return new PasswordAuthenticationMethod(user.UserName, user.Password); | ||
} | ||
|
||
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyAuthenticationMethod() | ||
{ | ||
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa"); | ||
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile); | ||
} | ||
|
||
public PrivateKeyAuthenticationMethod CreateRegularUserMultiplePrivateKeyAuthenticationMethod() | ||
{ | ||
var privateKeyFile1 = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa"); | ||
var privateKeyFile2 = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa"); | ||
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile1, privateKeyFile2); | ||
} | ||
|
||
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyWithPassPhraseAuthenticationMethod() | ||
{ | ||
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa_with_pass", "tester"); | ||
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile); | ||
} | ||
|
||
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyWithEmptyPassPhraseAuthenticationMethod() | ||
{ | ||
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa_with_pass", null); | ||
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile); | ||
} | ||
|
||
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyAuthenticationMethodWithBadKey() | ||
{ | ||
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_noaccess.rsa"); | ||
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile); | ||
} | ||
|
||
public PasswordAuthenticationMethod CreateRegulatUserPasswordAuthenticationMethod() | ||
{ | ||
return new PasswordAuthenticationMethod(Users.Regular.UserName, Users.Regular.Password); | ||
} | ||
|
||
public PasswordAuthenticationMethod CreateRegularUserPasswordAuthenticationMethodWithBadPassword() | ||
{ | ||
return new PasswordAuthenticationMethod(Users.Regular.UserName, "xxx"); | ||
} | ||
|
||
public KeyboardInteractiveAuthenticationMethod CreateRegularUserKeyboardInteractiveAuthenticationMethod() | ||
{ | ||
var keyboardInteractive = new KeyboardInteractiveAuthenticationMethod(Users.Regular.UserName); | ||
keyboardInteractive.AuthenticationPrompt += (sender, args) => | ||
{ | ||
foreach (var authenticationPrompt in args.Prompts) | ||
{ | ||
authenticationPrompt.Response = Users.Regular.Password; | ||
} | ||
}; | ||
return keyboardInteractive; | ||
} | ||
|
||
private PrivateKeyFile GetPrivateKey(string resourceName, string passPhrase = null) | ||
{ | ||
using (var stream = GetResourceStream(resourceName)) | ||
{ | ||
return new PrivateKeyFile(stream, passPhrase); | ||
} | ||
} | ||
|
||
private Stream GetResourceStream(string resourceName) | ||
{ | ||
var type = GetType(); | ||
var resourceStream = type.Assembly.GetManifestResourceStream(resourceName); | ||
if (resourceStream == null) | ||
{ | ||
throw new ArgumentException($"Resource '{resourceName}' not found in assembly '{type.Assembly.FullName}'.", nameof(resourceName)); | ||
} | ||
return resourceStream; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it work?