20862: Update dependencies, disable some Faraday usage.
[arvados.git] / spec / google / api_client / auth / storages / file_store_spec.rb
1 require 'spec_helper'
2
3 require 'google/api_client'
4 require 'google/api_client/version'
5
6 describe Google::APIClient::FileStore do
7   let(:root_path) { File.expand_path(File.join(__FILE__, '..','..','..', '..','..')) }
8   let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
9
10   let(:credentials_hash) {{
11       "access_token"=>"my_access_token",
12       "authorization_uri"=>"https://accounts.google.com/o/oauth2/auth",
13       "client_id"=>"123456_test_client_id@.apps.googleusercontent.com",
14       "client_secret"=>"123456_client_secret",
15       "expires_in"=>3600,
16       "refresh_token"=>"my_refresh_token",
17       "token_credential_uri"=>"https://accounts.google.com/o/oauth2/token",
18       "issued_at"=>1384440275
19   }}
20
21   subject{Google::APIClient::FileStore.new('a file path')}
22
23   it 'should have a path' do
24     expect(subject.path).to be == 'a file path'
25     subject.path = 'an other file path'
26     expect(subject.path).to be == 'an other file path'
27   end
28
29   it 'should load credentials' do
30     subject.path = json_file
31     credentials = subject.load_credentials
32     expect(credentials).to include('access_token', 'authorization_uri', 'refresh_token')
33   end
34
35   it 'should write credentials' do
36     io_stub = StringIO.new
37     expect(subject).to receive(:open).and_return(io_stub)
38     subject.write_credentials(credentials_hash)
39   end
40 end