mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-07 22:46:06 +00:00
[wip] spec for clearing tokens
But the test session isn't active! [skip ci]
This commit is contained in:
@@ -88,5 +88,33 @@ RSpec.describe DfcRequest do
|
||||
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")
|
||||
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
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user