test/fastly/token_test.rb in fastly-2.5.3 vs test/fastly/token_test.rb in fastly-3.0.0
- old
+ new
@@ -1,34 +1,30 @@
require_relative '../test_helper'
describe Fastly::Token do
+ let(:fastly) { Fastly.new(api_key:'my_api_key', user: 'test@example.com', password: 'password') }
- let(:elevated_fastly) { Fastly.new(user: 'test@example.com', password: 'password') }
- let(:fastly) { Fastly.new(api_key:'my_api_key') }
-
before {
- stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200, headers: { 'Set-Cookie' => 'tasty!' })
+ stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200)
}
describe '#fastly' do
-
- it 'cannot create itself because POST /tokens must have no auth headers)' do
+ it 'cannot create itself because POST /tokens must have no auth headers' do
stub_request(:post, "https://api.fastly.com/tokens").
with(
body: {"name"=>"name_of_token", "scope"=>"token_scope such_as purge_all purge_select", "services"=>"service_id_that_token_can_access"},
headers: {
'Accept'=>'*/*',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Content-Accept'=>'application/json',
'Content-Type'=>'application/x-www-form-urlencoded',
- 'Cookie'=>'tasty!',
'User-Agent'=> /fastly-ruby/
}).
to_return(status: 403, body: '{"msg":"You must POST /sudo to access this endpoint"}', headers: {})
assert_raises(Fastly::Error,'{"msg":"You must POST /sudo to access this endpoint"}') do
- elevated_fastly.create_token(
+ fastly.create_token(
name: 'name_of_token',
services: 'service_id_that_token_can_access',
scope: 'token_scope such_as purge_all purge_select'
)
end
@@ -61,10 +57,10 @@
'Content-Type'=>'application/x-www-form-urlencoded',
'User-Agent'=> /fastly-ruby/
}).
to_return(status: 200, body: response_body, headers: {})
- token = elevated_fastly.new_token(
+ token = fastly.new_token(
name: 'name_of_token',
services: 'service_id_that_token_can_access',
scope: 'optional token_scope such_as purge_all purge_select'
)
assert_equal token.id, '5Yo3XXnrQpjc20u0ybrf2g'