Skip to content

Commit

Permalink
feat!: requires kwargs and renames arg for validate_jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran88 committed Jan 2, 2025
1 parent 30b0cd5 commit 540c9be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/passageidentity/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ def initialize(app_id:, req_opts:)
@magic_links_client = OpenapiClient::MagicLinksApi.new
end

def validate_jwt(token)
raise ArgumentError, 'jwt is required.' unless token && !token.empty?
def validate_jwt(jwt:)
raise ArgumentError, 'jwt is required.' unless jwt && !jwt.empty?

claims =
JWT.decode(
token,
jwt,
nil,
true,
{
Expand Down
4 changes: 2 additions & 2 deletions tests/auth_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class TestAuthAPI < Test::Unit::TestCase
PassageClient = Passage::Client.new(app_id: ENV['APP_ID'], api_key: ENV['API_KEY'])

def test_valid_jwt
user_id = PassageClient.auth.validate_jwt(ENV['PSG_JWT'])
user_id = PassageClient.auth.validate_jwt(jwt: ENV['PSG_JWT'])
assert_equal ENV['TEST_USER_ID'], user_id
end

def test_invalid_jwt
assert_raises JWT::DecodeError do
PassageClient.auth.validate_jwt('invalid_token')
PassageClient.auth.validate_jwt(jwt: 'invalid_token')
end
end
end

0 comments on commit 540c9be

Please sign in to comment.