Skip to content

Commit

Permalink
chore: rename ssh session handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierChanth committed Dec 3, 2023
1 parent 6787c9f commit f95628f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:dartssh2/dartssh2.dart';
import 'package:noports_core/sshnp_foundation.dart';

class SshnpDartPureImpl extends SshnpCore
with SshnpDartSshKeyHandler, SshnpDartSshSessionHandler {
with SshnpDartSshKeyHandler, DartSshSessionHandler {
SshnpDartPureImpl({
required super.atClient,
required super.params,
Expand Down Expand Up @@ -114,10 +114,12 @@ class SshnpDartPureImpl extends SshnpCore
@override
Future<SshnpRemoteProcess> runShell() async {
if (tunnelSshClient == null) {
throw StateError('Cannot execute runShell, tunnel has not yet been created');
throw StateError(
'Cannot execute runShell, tunnel has not yet been created');
}

SSHClient userSession = await startUserSession(tunnelSession: tunnelSshClient!);
SSHClient userSession =
await startUserSession(tunnelSession: tunnelSshClient!);

SSHSession shell = await userSession.shell();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:noports_core/src/common/io_types.dart';
import 'package:noports_core/sshnp_foundation.dart';

class SshnpOpensshLocalImpl extends SshnpCore
with SshnpLocalSshKeyHandler, SshnpOpensshSshSessionHandler {
with SshnpLocalSshKeyHandler, OpensshSshSessionHandler {
SshnpOpensshLocalImpl({
required super.atClient,
required super.params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'package:dartssh2/dartssh2.dart';
import 'package:meta/meta.dart';
import 'package:noports_core/sshnp_foundation.dart';

mixin SshnpDartSshSessionHandler on SshnpCore
implements SshnpSshSessionHandler<SSHClient> {
mixin DartSshSessionHandler on SshnpCore
implements SshSessionHandler<SSHClient> {
/// Set up timer to check to see if all connections are down
@visibleForTesting
String get terminateMessage =>
Expand Down Expand Up @@ -69,8 +69,7 @@ mixin SshnpDartSshSessionHandler on SshnpCore
}

@override
Future<SSHClient> startUserSession(
{required SSHClient tunnelSession}) async {
Future<SSHClient> startUserSession({required SSHClient tunnelSession}) async {
throw UnimplementedError();
// TODO v similar to startInitialTunnelSession
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:noports_core/src/common/io_types.dart';
import 'package:noports_core/src/common/openssh_binary_path.dart';
import 'package:noports_core/sshnp_foundation.dart';

mixin SshnpOpensshSshSessionHandler on SshnpCore
implements SshnpSshSessionHandler<Process?> {
mixin OpensshSshSessionHandler on SshnpCore
implements SshSessionHandler<Process?> {
@override
Future<Process?> startInitialTunnelSession({
required String keyPairIdentifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';
import 'package:meta/meta.dart';

mixin SshnpSshSessionHandler<T> {
mixin SshSessionHandler<T> {
@protected
@visibleForTesting
Future<T> startInitialTunnelSession({required String keyPairIdentifier});
Expand Down
6 changes: 3 additions & 3 deletions packages/noports_core/lib/sshnp_foundation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export 'src/sshnp/util/sshrvd_channel/sshrvd_channel.dart';
export 'src/sshnp/util/sshrvd_channel/sshrvd_dart_channel.dart';
export 'src/sshnp/util/sshrvd_channel/sshrvd_exec_channel.dart';

export 'src/sshnp/util/sshnp_initial_tunnel_handler/sshnp_initial_tunnel_handler.dart';
export 'src/sshnp/util/sshnp_initial_tunnel_handler/sshnp_dart_initial_tunnel_handler.dart';
export 'src/sshnp/util/sshnp_initial_tunnel_handler/sshnp_openssh_initial_tunnel_handler.dart';
export 'src/sshnp/util/ssh_session_handler/ssh_session_handler.dart';
export 'src/sshnp/util/ssh_session_handler/dart_ssh_session_handler.dart';
export 'src/sshnp/util/ssh_session_handler/openssh_ssh_session_handler.dart';

export 'src/sshnp/util/sshnp_ssh_key_handler/sshnp_ssh_key_handler.dart';
export 'src/sshnp/util/sshnp_ssh_key_handler/sshnp_local_ssh_key_handler.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class StartInitialTunnelCaller {
class StartInitialTunnelStub extends Mock implements StartInitialTunnelCaller {}

/// Stubbed Mixin that we are testing
mixin StubbedSshnpOpensshSshSessionHandler on SshnpOpensshSshSessionHandler {
mixin StubbedSshnpOpensshSshSessionHandler on OpensshSshSessionHandler {
late StartInitialTunnelStub _stubbedStartInitialTunnel;
late StartProcessStub _stubbedStartProcess;

Expand All @@ -39,9 +39,7 @@ mixin StubbedSshnpOpensshSshSessionHandler on SshnpOpensshSshSessionHandler {

/// Stubbed Sshnp instance with the mixin
class StubbedSshnp extends SshnpCore
with
SshnpOpensshSshSessionHandler,
StubbedSshnpOpensshSshSessionHandler {
with OpensshSshSessionHandler, StubbedSshnpOpensshSshSessionHandler {
StubbedSshnp({
required super.atClient,
required super.params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:noports_core/sshnp_foundation.dart';
import 'package:test/test.dart';

import '../../sshnp_mocks.dart';
import 'sshnp_openssh_initial_tunnel_handler_mocks.dart';
import 'openssh_ssh_session_handler_mocks.dart';

void main() {
group('SshnpOpensshSshSessionHandler', () {
Expand Down Expand Up @@ -44,7 +44,7 @@ void main() {
});

test('implements SshnpSshSessionHandler<Process?>', () {
expect(stubbedSshnp, isA<SshnpSshSessionHandler<Process?>>());
expect(stubbedSshnp, isA<SshSessionHandler<Process?>>());
}); // test public API
test('startInitialTunnel', () {}); // test startInitialTunnel
}); // group SshnpOpensshSshSessionHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:test/test.dart';
import 'package:mocktail/mocktail.dart';

class StubbedSshnpSshSessionHandler extends Mock
with SshnpSshSessionHandler<String> {}
with SshSessionHandler<String> {}

void main() {
group('SshnpSshSessionHandler', () {
Expand Down

0 comments on commit f95628f

Please sign in to comment.