Sha256: 18f6707552ea2a1a35543fa2931eadb5d25290ed0297ccad702379b6fc6fa516

Contents?: true

Size: 906 Bytes

Versions: 33

Compression:

Stored size: 906 Bytes

Contents

# frozen_string_literal: true

require "minitest/autorun"
require "argon2id"

class TestVerify < Minitest::Test
  def test_returns_true_with_correct_password
    assert Argon2id.verify(
      "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4",
      "password"
    )
  end

  def test_returns_false_with_incorrect_password
    refute Argon2id.verify(
      "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4",
      "not password"
    )
  end

  def test_raises_if_given_invalid_encoded
    assert_raises(ArgumentError) do
      Argon2id.verify("", "opensesame")
    end
  end

  def test_raises_if_given_encoded_with_null_byte
    assert_raises(ArgumentError) do
      Argon2id.verify(
        "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4\x00foo",
        "password"
      )
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
argon2id-0.5.0 test/test_verify.rb
argon2id-0.5.0-x86_64-linux test/test_verify.rb
argon2id-0.5.0-x86_64-darwin test/test_verify.rb
argon2id-0.5.0-x86-mingw32 test/test_verify.rb
argon2id-0.5.0-x86-linux test/test_verify.rb
argon2id-0.5.0-x64-mingw32 test/test_verify.rb
argon2id-0.5.0-x64-mingw-ucrt test/test_verify.rb
argon2id-0.5.0-java test/test_verify.rb
argon2id-0.5.0-arm64-darwin test/test_verify.rb
argon2id-0.5.0-arm-linux test/test_verify.rb
argon2id-0.5.0-aarch64-linux test/test_verify.rb
argon2id-0.4.1 test/test_verify.rb
argon2id-0.4.1-x86_64-linux test/test_verify.rb
argon2id-0.4.1-x86_64-darwin test/test_verify.rb
argon2id-0.4.1-x86-mingw32 test/test_verify.rb
argon2id-0.4.1-x86-linux test/test_verify.rb
argon2id-0.4.1-x64-mingw32 test/test_verify.rb
argon2id-0.4.1-x64-mingw-ucrt test/test_verify.rb
argon2id-0.4.1-java test/test_verify.rb
argon2id-0.4.1-arm64-darwin test/test_verify.rb