Commit 7ba65d05 authored by Stan Hu's avatar Stan Hu

Fix Bitbucket callback spec

parent 2747e515
...@@ -6,11 +6,11 @@ describe Import::BitbucketController do ...@@ -6,11 +6,11 @@ describe Import::BitbucketController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:token) { "asdasd12345" } let(:token) { "asdasd12345" }
let(:secret) { "sekrettt" } let(:secret) { "sekrettt" }
let(:refresh_token) { SecureRandom.hex(15) }
let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } } let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } }
def assign_session_tokens def assign_session_tokens
session[:bitbucket_access_token] = token session[:bitbucket_token] = token
session[:bitbucket_access_token_secret] = secret
end end
before do before do
...@@ -24,15 +24,23 @@ describe Import::BitbucketController do ...@@ -24,15 +24,23 @@ describe Import::BitbucketController do
end end
it "updates access token" do it "updates access token" do
access_token = double(token: token, secret: secret) expires_at = Time.now + 1.day
allow_any_instance_of(Gitlab::BitbucketImport::Client). expires_in = 1.day
access_token = double(token: token,
secret: secret,
expires_at: expires_at,
expires_in: expires_in,
refresh_token: refresh_token)
allow_any_instance_of(OAuth2::Client).
to receive(:get_token).and_return(access_token) to receive(:get_token).and_return(access_token)
stub_omniauth_provider('bitbucket') stub_omniauth_provider('bitbucket')
get :callback get :callback
expect(session[:bitbucket_access_token]).to eq(token) expect(session[:bitbucket_token]).to eq(token)
expect(session[:bitbucket_access_token_secret]).to eq(secret) expect(session[:bitbucket_refresh_token]).to eq(refresh_token)
expect(session[:bitbucket_expires_at]).to eq(expires_at)
expect(session[:bitbucket_expires_in]).to eq(expires_in)
expect(controller).to redirect_to(status_import_bitbucket_url) expect(controller).to redirect_to(status_import_bitbucket_url)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment