Skip to content

Commit

Permalink
feat: rename function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran88 committed Dec 20, 2024
1 parent d66d646 commit 736b3c8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 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
6 changes: 3 additions & 3 deletions lib/passageidentity/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def get(user_id:)
end
end

def get_by_identifier(user_identifier:)
raise ArgumentError, 'identifier is required.' unless user_identifier && !user_identifier.empty?
def get_by_identifier(identifier:)
raise ArgumentError, 'identifier is required.' unless identifier && !identifier.empty?

begin
req_opts = set_get_by_identifier_query_params(identifier: user_identifier)
req_opts = set_get_by_identifier_query_params(identifier: identifier)
response = @user_client.list_paginated_users(@app_id, req_opts)
rescue Faraday::Error => e
raise PassageError.new(
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(token: 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(token: 'invalid_token')
PassageClient.auth.validate_jwt(jwt: 'invalid_token')
end
end
end
8 changes: 4 additions & 4 deletions tests/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_get_user_by_identifier
user = PassageClient.user.get(user_id: @test_user.id)
assert_equal @test_user.id, user.id

user_by_identifier = PassageClient.user.get_by_identifier(user_identifier: @test_user.email)
user_by_identifier = PassageClient.user.get_by_identifier(identifier: @test_user.email)
assert_equal @test_user.id, user_by_identifier.id

assert_equal user, user_by_identifier
Expand All @@ -55,7 +55,7 @@ def test_get_user_by_identifier_upper_case
user = PassageClient.user.get(user_id: @test_user.id)
assert_equal @test_user.id, user.id

user_by_identifier = PassageClient.user.get_by_identifier(user_identifier: @test_user.email.upcase)
user_by_identifier = PassageClient.user.get_by_identifier(identifier: @test_user.email.upcase)
assert_equal @test_user.id, user_by_identifier.id

assert_equal user, user_by_identifier
Expand All @@ -70,15 +70,15 @@ def test_get_user_by_identifier_phone
user = PassageClient.user.get(user_id: create_user.id)
assert_equal create_user.id, user.id

user_by_identifier = PassageClient.user.get_by_identifier(user_identifier: phone)
user_by_identifier = PassageClient.user.get_by_identifier(identifier: phone)
assert_equal create_user.id, user_by_identifier.id

assert_equal user, user_by_identifier
end

def test_invalid_get_by_identifier
assert_raise Passage::PassageError do
PassageClient.user.get_by_identifier(user_identifier: '[email protected]')
PassageClient.user.get_by_identifier(identifier: '[email protected]')
end
end

Expand Down

0 comments on commit 736b3c8

Please sign in to comment.