Skip to content

Decrypting a phoney value breaks when testing #3

Closed
@suprafly

Description

@suprafly

A simple test:

    test "decrypt something phoney" do
      {resp, _} = Cipher.decrypt("nonsense")    
      assert resp == :error
    end

Returns this error:

    ** (ArgumentError) argument error
         stacktrace:
           (crypto) :crypto.aes_cbc_crypt("f501bc2316ae38b1", "33G<I0WWJiEn1{;Y", <<158, 137, 236, 122, 123, 30>>, false)
       lib/cipher.ex:39: Cipher.decrypt/1

I suspect that during testing, the helper functions to retrieve the :keyphrase and :ivphrase are not working correctly: https://github.com/rubencaro/cipher/blob/master/lib/cipher/helpers.ex

You can see this by extracting the definition and trying it in a test. When I add this line to my test:
IO.inspect Application.get_env(Mix.Project.get!.project[:app], :keyphrase, nil)
...the outut is: nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions