-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
208 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
spec/cassettes/GraphQL_Client_Aws/execute/when_authorized/1_3_1_1.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
spec/cassettes/GraphQL_Client_Aws/execute/when_not_authorized/1_3_2_1.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,55 @@ | ||
require 'spec_helper' | ||
|
||
Query = GraphQL.parse <<-'GRAPHQL' | ||
query list { | ||
listMyCustomTypes { | ||
items { | ||
id | ||
title | ||
content | ||
} | ||
} | ||
} | ||
GRAPHQL | ||
|
||
describe GraphQL::Client::Aws do | ||
let(:region) { 'ap-northeast-1' } | ||
let(:access_key_id) { ENV.fetch('AWS_ACCESS_KEY_ID') { 'access_key_id' } } | ||
let(:secret_access_key) { ENV.fetch('AWS_SECRET_ACCESS_KEY') { 'secret_access_key' } } | ||
let(:signer_opts) { | ||
{ | ||
region: region, | ||
access_key_id: access_key_id, | ||
secret_access_key: secret_access_key | ||
access_key_id: 'hoge', | ||
secret_access_key: 'secret_access_key' | ||
} | ||
} | ||
let(:uri) { 'https://fmcrcnckrndolhucaegjfdqt54.appsync-api.ap-northeast-1.amazonaws.com/graphql' } | ||
let(:instance) { described_class.new(uri,signer_opts) } | ||
|
||
subject { described_class.new(uri,signer_opts) } | ||
let(:uri) { 'https://hoge.appsync-api.ap-northeast-1.amazonaws.com/graphql' } | ||
let(:instance) { described_class.new(uri, signer_opts) } | ||
|
||
describe 'class' do | ||
subject { instance } | ||
it { is_expected.to be_a_kind_of GraphQL::Client::HTTP } | ||
it { is_expected.to be_an_instance_of GraphQL::Client::Aws } | ||
end | ||
|
||
describe 'uri attribute' do | ||
subject { instance.uri.to_s } | ||
it { is_expected.to eq uri } | ||
end | ||
|
||
describe 'connection' do | ||
subject { instance.connection } | ||
it { is_expected.to be_an_instance_of GraphQL::Client::SignedHTTP } | ||
describe 'execute', :vcr do | ||
context 'when authorized' do | ||
subject do | ||
res = instance.execute(document: Query, operation_name: 'list') | ||
res['data']['listMyCustomTypes']['items'].first | ||
end | ||
it { is_expected.to match({ 'title' => 'テストタイトル', 'content' => 'テストです', 'id' => '12345' }) } | ||
end | ||
|
||
describe 'signer' do | ||
subject { instance.connection.signer } | ||
it { is_expected.to be_an_instance_of Aws::Sigv4::Signer } | ||
context 'when not authorized' do | ||
subject do | ||
res = instance.execute(document: Query, operation_name: 'list') | ||
res['errors'].first | ||
end | ||
it { is_expected.to match({ 'message' => '403 Forbidden' }) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'spec_helper' | ||
require 'graphql' | ||
|
||
Query = GraphQL.parse <<-'GRAPHQL' | ||
query list { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters