Skip to content

Commit

Permalink
[wip] spec for clearing tokens
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
dacook committed Jan 22, 2025
1 parent 9497e77 commit 4e15a6e
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 0 deletions.
29 changes: 29 additions & 0 deletions engines/dfc_provider/spec/services/dfc_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,34 @@
products = graph.select { |s| s.semanticType == "dfc-b:SuppliedProduct" }
expect(products).to be_present
end

context "with account tokens" do
before do
account.refresh_token = ENV.fetch("OPENID_REFRESH_TOKEN")
# TODO try to get a token. currently getting auth error! (invalid_client :: Invalid client or Invalid client credentials)
api.call(
"https://env-0105831.jcloud-ver-jpe.ik-server.com/api/dfc/Enterprises/test-hodmedod/SuppliedProducts"
)
expect(account.token).not_to be_nil
end

it "clears the token if authentication fails", vcr: true do
allow_any_instance_of(OpenIDConnect::Client).to receive(:access_token!).and_raise(
Rack::OAuth2::Client::Error.new(
1, { error: "invalid_grant", error_description: "session not active" }
)
)

expect {
api.call(
"https://env-0105831.jcloud-ver-jpe.ik-server.com/api/dfc/Enterprises/test-hodmedod/SuppliedProducts"
)
}.to raise_error(Rack::OAuth2::Client::Error).and change {
account.token
}.to(nil).and change {
account.refresh_token
}.to(nil)
end
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4e15a6e

Please sign in to comment.