From 09df2ad2d04dfded3bfa6d479043f4f11685d590 Mon Sep 17 00:00:00 2001 From: Chris Tran Date: Thu, 2 Jan 2025 14:38:35 -0600 Subject: [PATCH 1/2] test: removes e2e tests in favor of the sdk-test suite --- tests/auth_test.rb | 23 -------- tests/errors_test.rb | 1 - tests/user_test.rb | 122 ------------------------------------------- 3 files changed, 146 deletions(-) delete mode 100644 tests/auth_test.rb delete mode 100644 tests/user_test.rb diff --git a/tests/auth_test.rb b/tests/auth_test.rb deleted file mode 100644 index bcd8acc..0000000 --- a/tests/auth_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require_relative '../lib/passageidentity/client' -require 'dotenv' -require 'test/unit' - -Dotenv.load('.env') - -# This is a test suite for the Passage Auth API using the Test::Unit framework. -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(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(jwt: 'invalid_token') - end - end -end diff --git a/tests/errors_test.rb b/tests/errors_test.rb index 10b8c07..ed31b76 100644 --- a/tests/errors_test.rb +++ b/tests/errors_test.rb @@ -2,7 +2,6 @@ require_relative '../lib/passageidentity/error' require 'test/unit' -require 'net/http' # This is a test suite for the PassageError class using the Test::Unit framework. class ErrorTest < Test::Unit::TestCase diff --git a/tests/user_test.rb b/tests/user_test.rb deleted file mode 100644 index a5ca6ee..0000000 --- a/tests/user_test.rb +++ /dev/null @@ -1,122 +0,0 @@ -# frozen_string_literal: true - -require_relative '../lib/passageidentity/client' -require 'dotenv' -require 'faraday' -require 'test/unit' - -Dotenv.load('.env') - -# This is a test suite for the Passage User using the Test::Unit framework. -class TestUser < Test::Unit::TestCase - PassageClient = Passage::Client.new(app_id: ENV['APP_ID'], api_key: ENV['API_KEY']) - - def setup - args = { - 'email' => 'passage+test-ruby@passage.id', - 'user_metadata' => { - 'example1' => 'cool' - } - } - @test_user = PassageClient.user.create(args: args) - end - - def test_create_delete_user - args = { - 'email' => 'passage+test-create-delete@passage.id', - 'user_metadata' => { - 'example1' => 'cool' - } - } - user = PassageClient.user.create(args: args) - assert_equal 'passage+test-create-delete@passage.id', user.email - assert_equal 'cool', user.user_metadata[:example1] - - deleted = PassageClient.user.delete(user_id: user.id) - assert_equal true, deleted - end - - def test_get_user - user = PassageClient.user.get(user_id: @test_user.id) - assert_equal @test_user.id, user.id - end - - 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(identifier: @test_user.email) - assert_equal @test_user.id, user_by_identifier.id - - assert_equal user, user_by_identifier - end - - 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(identifier: @test_user.email.upcase) - assert_equal @test_user.id, user_by_identifier.id - - assert_equal user, user_by_identifier - end - - def test_get_user_by_identifier_phone - phone = '+15005550007' - args = { - 'phone' => phone - } - create_user = PassageClient.user.create(args: args) - user = PassageClient.user.get(user_id: create_user.id) - assert_equal create_user.id, user.id - - 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 - user = PassageClient.user.get(user_id: @test_user.id) - assert_equal @test_user.id, user.id - - assert_raise Passage::PassageError do - PassageClient.user.get_by_identifier(identifier: 'error@passage.id') - end - end - - def test_deactivate_user - user = PassageClient.user.deactivate(user_id: @test_user.id) - assert_equal @test_user.id, user.id - assert_equal 'inactive', user.status - end - - def test_activate_user - user = PassageClient.user.activate(user_id: @test_user.id) - assert_equal @test_user.id, user.id - assert_equal 'active', user.status - end - - def test_update_user - new_email = 'passage+update_test-ruby@passage.id' - opts = { - 'email' => new_email, - 'user_metadata' => { - 'example1' => 'lame' - } - } - user = PassageClient.user.update(user_id: @test_user.id, options: opts) - assert_equal @test_user.id, user.id - assert_equal new_email, user.email - assert_equal 'lame', user.user_metadata[:example1] - end - - def test_list_devices - devices = PassageClient.user.list_devices(user_id: @test_user.id) - assert_equal [], devices - end - - def teardown - PassageClient.user.delete(user_id: @test_user.id) - end -end From f67646150e2c5d26ad52c787a78aec113f346a0a Mon Sep 17 00:00:00 2001 From: Chris Tran Date: Thu, 2 Jan 2025 14:59:15 -0600 Subject: [PATCH 2/2] feat!: return void instead of boolean (#156) --- lib/passageidentity/user.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/passageidentity/user.rb b/lib/passageidentity/user.rb index 8ac8c1a..50abf74 100644 --- a/lib/passageidentity/user.rb +++ b/lib/passageidentity/user.rb @@ -102,7 +102,6 @@ def delete(user_id:) begin @user_client.delete_user(@app_id, user_id, @req_opts) - true rescue Faraday::Error => e raise PassageError.new( 'failed to delete Passage User',