Skip to content
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

refactor: SSHNPParams unit tests preparation #539

Merged
merged 28 commits into from
Nov 10, 2023
Merged

Conversation

XavierChanth
Copy link
Member

@XavierChanth XavierChanth commented Oct 18, 2023

- What I did

  • Started writing unit tests (which some are also included in this PR)
  • Realized that I needed to replace most of the inheritance with composition of classes so I removed the hierarchy and instead:
    • Split most of the logic in the SSHNP implementations to mixins and classes:
      • SshrvdChannel - responsible for all communication to sshrvd
      • SshnpdChannel - responsible for all communication to sshnpd (there are subclasses because the legacy client uses unsigned payloads)
      • SshnpInitialTunnelHandler - a mixin which handles starting the initial ssh tunnel for forward clients
      • SshnpSshKeyHandler - a wrapper around SshKeyUtil which helps to safely use the correct ssh key management approach depending on implementation type (important for CLI vs Flutter implementations)

Other changes:

  • Separated lifecycle methods to mixins
    • AsyncInitialization and AsyncDisposal
      • Note: I think AsyncDisposal might not be written to correctly handle lifecycle, but I will change that when/if we need to.
  • Renamed any uppercase class name segments such as SSHKeyUtil or SSHNPBlahBlahImpl to SshKeyUtil or SshnpBlahBlahImpl
  • Removed the e2e installer tests since they are failing and we are going to be ditching that particular installer in the 4.0 release

- How I did it

- How to verify it

- Description for the changelog
refactor: SSHNPParams unit tests preparation

@XavierChanth XavierChanth changed the title feat(DRAFT): Noports core unit tests feat: SSHNPParams unit tests Oct 18, 2023
@XavierChanth XavierChanth changed the title feat: SSHNPParams unit tests test: SSHNPParams unit tests Oct 18, 2023
import 'package:noports_core/src/common/default_args.dart';
import 'package:noports_core/src/sshnp/sshnp_params/sshnp_params.dart';

class ConfigKeyRepository {
static const String _keyPrefix = 'profile_';
static const String _configNamespace = 'profiles.${DefaultArgs.namespace}';
@visibleForTesting
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made visible for testing in the unit tests

@@ -325,7 +325,7 @@ class SSHNPArg {
allowed: SupportedSshClient.values.map((c) => c.toString()).toList(),
parseWhen: ParseWhen.commandLine,
);
static final ssHAlgorithmArg = SSHNPArg(
static final sshAlgorithmArg = SSHNPArg(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed ssH -> ssh

@@ -0,0 +1 @@
void main() {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are to be written in a later PR

run: dart analyze
- name: dart test
working-directory: packages/noports_core
run: dart test
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup dart, dart analyze, dart test noports_core

@XavierChanth
Copy link
Member Author

I just have to call it out... I was prepared to rip my hair out over a billion merge conflicts with 4ca6441. The git renames have saved this PR!

@XavierChanth XavierChanth requested a review from gkc November 6, 2023 18:04
@XavierChanth XavierChanth requested review from VJag and cconstab November 6, 2023 18:04
@XavierChanth XavierChanth changed the title test: SSHNPParams unit tests refactor: SSHNPParams unit tests preparation Nov 6, 2023
@@ -192,172 +192,6 @@ jobs:
docker compose down

# Test suite 2
# Installer tests (local vs installer)
e2e_installer_test:
# Don't run on forks (cause no secrets), don't run if dependebot (cause no secrets)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these tests, since we don't need them for the next release

@XavierChanth XavierChanth marked this pull request as ready for review November 6, 2023 18:24
@XavierChanth XavierChanth force-pushed the noports_core_unit_tests branch from d580e1a to 6f068b0 Compare November 8, 2023 16:04
@XavierChanth
Copy link
Member Author

@gkc the trunk tests are not building (as expected) but local-local is now building, so I think it is safe for us to review.

Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @XavierChanth ... I think there's an opportunity to refactor some duplicated code in the various SshnpCore subclasses but that can come in a follow-up PR

@gkc gkc merged commit ba56ff7 into trunk Nov 10, 2023
10 checks passed
@gkc gkc deleted the noports_core_unit_tests branch November 10, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants