Skip to content

Commit

Permalink
add test for invalid credentials in file storage (googleapis#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
rusikf authored and dazuma committed Dec 5, 2018
1 parent 3a1e54d commit dadb8e4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions spec/google/api_client/auth/storages/file_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
require 'google/api_client/auth/storages/file_store'

describe Google::APIClient::FileStore do
let(:root_path) { File.expand_path(File.join(__FILE__, '..','..','..', '..','..')) }
let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
let(:json_file) { File.join(FIXTURES_DIR, 'files', 'auth_stored_credentials.json') }

let(:credentials_hash) {{
"access_token"=>"my_access_token",
Expand Down Expand Up @@ -38,4 +37,12 @@
expect(subject).to receive(:open).and_return(io_stub)
subject.write_credentials(credentials_hash)
end

it 'should not load credentials' do
file = StringIO.new
file.write "{invalid_hash}"
invalid_subject = Google::APIClient::FileStore.new(file)
expect(invalid_subject.load_credentials).to be_nil
end

end

0 comments on commit dadb8e4

Please sign in to comment.