Skip to content

Commit

Permalink
Fix OAuth2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Oct 29, 2024
1 parent c01041a commit 7a54118
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/integration/oauth2_test.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
require "test_helper"
require "oauth2"

class OAuth2Test < ActiveSupport::TestCase
class OAuth2Test < ActionDispatch::IntegrationTest
attr_accessor :password, :user, :app, :client

setup do
@password = "123123"
@user = FactoryBot.create(:user, password: password, password_confirmation: password)
@app = FactoryBot.create(:application)
@client = OAuth2::Client.new(@app.uid, @app.secret) do |b|
@password = "password"
@user = create(:user, password: password, password_confirmation: password)
@app = create(:application)
@client = OAuth2::Client.new(@app.uid, @app.secret, site: "http://localhost") do |b|
b.request :url_encoded
b.adapter :rack, Rails.application
end
end

test "auth_code" do
test_url = "/api/v3/hello.json"
grant = FactoryBot.create(:access_grant, application: app, redirect_uri: "#{app.redirect_uri}/callback")
grant = create(:access_grant, application: app, redirect_uri: "#{app.redirect_uri}/callback")

assert_changes -> { Doorkeeper::AccessToken.count }, 1 do
@access_token = client.auth_code.get_token(grant.token, redirect_uri: grant.redirect_uri)
Expand All @@ -34,7 +34,7 @@ class OAuth2Test < ActiveSupport::TestCase
assert_not_equal @access_token.token, @new_token.token

# Revoke a new access_token, old access_token will invalid
grant = FactoryBot.create(:access_grant, application: app, redirect_uri: "#{app.redirect_uri}/callback")
grant = create(:access_grant, application: app, redirect_uri: "#{app.redirect_uri}/callback")
@access_token1 = client.auth_code.get_token(grant.token, redirect_uri: grant.redirect_uri)

assert_raise OAuth2::Error do
Expand Down

0 comments on commit 7a54118

Please sign in to comment.