Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Hubspot::Config.reset! to clear oauth header - fix issue #234 #233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/hubspot/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def reset!
@portal_id = nil
@logger = DEFAULT_LOGGER
@access_token = nil
Hubspot::Connection.headers({})
@client_id = nil
@client_secret = nil
@redirect_uri = nil

Hubspot::Connection.headers.clear
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could alternatively be more selective via:

Hubspot::Connection.headers.delete("Authorization")

end

def ensure!(*params)
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/hubspot/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@
expect(Hubspot::Config.hapikey).to be nil
expect(Hubspot::Config.portal_id).to be nil
end

it "clears oauth token" do
Hubspot::Config.configure(client_id: "123abc", client_secret: "456def", redirect_uri: "https://example.com", access_token: "789ghi")

expect(Hubspot::Connection.headers.size).to be 1

Hubspot::Config.reset!

expect(Hubspot::Config.hapikey).to be nil
expect(Hubspot::Config.client_id).to be nil
expect(Hubspot::Config.client_secret).to be nil
expect(Hubspot::Config.redirect_uri).to be nil
expect(Hubspot::Config.access_token).to be nil

expect(Hubspot::Connection.headers.empty?).to be true

end
end

describe ".ensure!" do
Expand Down