Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f committed Aug 29, 2024
1 parent bcc2960 commit fc3069b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/src/SSH.purs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ printParsePrivateKeyError = case _ of
RequiresPassphrase -> "Encrypted private key requires a passphrase"
OtherParseError message -> message

-- | Parse a password-protected private SSH key
parsePrivateKey :: { key :: String, passphrase :: Maybe String } -> Either ParsePrivateKeyError PrivateKey
parsePrivateKey { key, passphrase } =
case runFn4 parseKeyImpl (Left <<< Exception.message) Right key (Nullable.toNullable passphrase) of
Expand Down Expand Up @@ -103,7 +102,7 @@ foreign import equalsImpl :: Fn2 ParsedKey ParsedKey Boolean

foreign import publicToOwnerImpl :: Fn1 PublicKey { keytype :: String, public :: String, id :: Nullable String }

publicToOwner :: PublicKey -> Owner
publicToOwner key = do
publicKeyToOwner :: PublicKey -> Owner
publicKeyToOwner key = do
let { id: nullableId, keytype, public } = runFn1 publicToOwnerImpl key
Owner { keytype, public, id: Nullable.toMaybe nullableId }
2 changes: 1 addition & 1 deletion lib/test/Registry/SSH.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec = do
Spec.it "Parses a password-protected RSA private key" do
case SSH.parsePrivateKey { key: id_rsa, passphrase: Nothing } of
Left err1@SSH.RequiresPassphrase -> do
SSH.printParsePrivateKeyError err1 `Assert.shouldEqual` "Encrypted private OpenSSH key detected, but no passphrase given"
SSH.printParsePrivateKeyError err1 `Assert.shouldEqual` "Encrypted private key requires a passphrase"
case SSH.parsePrivateKey { key: id_rsa, passphrase: Just id_rsa_password } of
Left err2 -> Assert.fail $ "Failed to parse id_rsa private key with password: " <> SSH.printParsePrivateKeyError err2
Right _ -> pure unit
Expand Down

0 comments on commit fc3069b

Please sign in to comment.