fastly 2.5.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +3 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +6 -1
- data/README.md +20 -9
- data/RELEASE.md +15 -0
- data/lib/fastly.rb +30 -3
- data/lib/fastly/belongs_to_service_and_version.rb +3 -3
- data/lib/fastly/client.rb +3 -15
- data/lib/fastly/gem_version.rb +1 -1
- data/lib/fastly/service.rb +2 -1
- data/lib/fastly/token.rb +10 -6
- data/test/api_key_test.rb +1 -21
- data/test/fastly/client_test.rb +10 -16
- data/test/fastly/customer_test.rb +1 -1
- data/test/fastly/dictionary_test.rb +2 -2
- data/test/fastly/sumologic_logging_test.rb +44 -0
- data/test/fastly/syslog_test.rb +2 -2
- data/test/fastly/token_test.rb +5 -9
- data/test/full_login_test.rb +1 -1
- data/test/helper.rb +1 -0
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a8a72b52675780f42dfcb7638e5992d1cbda77b4e1b826d73c2230404efbad8
|
4
|
+
data.tar.gz: '0878ef856b74957ea849a2337234e107d81bca5f7865e7ad5ce7d4e325b671f8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1d289d047370ea5933e0d3dbd510f7253395e4c2b0bbb047972d9dd12323c0c73efbc221351ad7681815e98c4353ce2892d9bb9e9f04a2d9fc3a1dbe007cc07
|
7
|
+
data.tar.gz: 4c2493a600ad80631d598bee61ef773550149b14d8f1685ea55925ef997ef96669990748c5e935d61983d73267cef19ae78176c857b046faf9794db007dae859
|
data/.env.example
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,31 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v3.0.2](https://github.com/fastly/fastly-ruby/tree/v3.0.2) (2021-06-30)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/fastly/fastly-ruby/compare/v3.0.1...v3.0.2)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Fix SumoLogic Logging [\#180](https://github.com/fastly/fastly-ruby/pull/180) ([integralist](https://github.com/integralist))
|
10
|
+
|
11
|
+
## [v3.0.1](https://github.com/fastly/fastly-ruby/tree/v3.0.1) (2021-02-03)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/fastly/fastly-ruby/compare/v3.0.0...v3.0.1)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- Remove deprecation warning [\#174](https://github.com/fastly/fastly-ruby/pull/174) ([conniechu929](https://github.com/conniechu929))
|
18
|
+
|
19
|
+
## [v3.0.0](https://github.com/fastly/fastly-ruby/tree/v3.0.0) (2021-02-03)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/fastly/fastly-ruby/compare/v2.5.3...v3.0.0)
|
22
|
+
|
23
|
+
**Merged pull requests:**
|
24
|
+
|
25
|
+
- Removes session authentication [\#170](https://github.com/fastly/fastly-ruby/pull/170) ([conniechu929](https://github.com/conniechu929))
|
26
|
+
|
3
27
|
## [v2.5.0](https://github.com/fastly/fastly-ruby/tree/v2.5.0) (2020-01-16)
|
28
|
+
|
4
29
|
[Full Changelog](https://github.com/fastly/fastly-ruby/compare/v2.4.0...v2.5.0)
|
5
30
|
|
6
31
|
**Merged pull requests:**
|
data/Gemfile
CHANGED
@@ -4,10 +4,15 @@ gemspec
|
|
4
4
|
|
5
5
|
group :development, :test do
|
6
6
|
gem 'appraisal', '~> 2.1'
|
7
|
-
gem '
|
7
|
+
gem 'byebug'
|
8
|
+
gem 'rake', '>= 12.3.3'
|
8
9
|
gem 'rdoc', '~> 4.1.1'
|
9
10
|
gem 'minitest', '~> 5.3.4'
|
10
11
|
gem 'pry'
|
11
12
|
gem 'rubocop', '~> 0.57.2', require: false
|
12
13
|
gem 'webmock'
|
13
14
|
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem 'dotenv'
|
18
|
+
end
|
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
Client library for interacting with the Fastly web acceleration service [API](http://docs.fastly.com/api)
|
4
4
|
|
5
|
+
### A Note About Authentication
|
6
|
+
|
7
|
+
Authenticating with a username/password is deprecated and will no longer be available starting September 2020.
|
8
|
+
|
9
|
+
Authenticating with an API Token is shown in the example section below. For more information on API Tokens, please see [Fastly's API Token documentation](https://developer.fastly.com/reference/api/auth/). For more information about authenticating to our API, please see our [Authentication section](https://developer.fastly.com/reference/api/#authentication).
|
10
|
+
|
5
11
|
## Examples
|
6
12
|
|
7
13
|
Add fastly to your Gemfile:
|
@@ -13,7 +19,8 @@ Create a fastly client:
|
|
13
19
|
|
14
20
|
```ruby
|
15
21
|
# some_file.rb
|
16
|
-
#
|
22
|
+
# username/password authentication is deprecated and will not be available
|
23
|
+
# starting September 2020; use {api_key: 'your-key'} as the login option
|
17
24
|
fastly = Fastly.new(login_opts)
|
18
25
|
|
19
26
|
current_user = fastly.current_user
|
@@ -202,19 +209,23 @@ This option should not be used in a production setting as all HTTP headers, requ
|
|
202
209
|
|
203
210
|
### Notes for testing
|
204
211
|
|
205
|
-
The test suite
|
212
|
+
The test suite tests create and delete three services in sequence, so you may want to create an account just for these tests.
|
213
|
+
|
214
|
+
To run the test suite:
|
215
|
+
|
216
|
+
1. Generate a personal token for these tests: https://manage.fastly.com/account/personal/tokens
|
217
|
+
|
218
|
+
2. Copy `.env.example` to `.env` and add the values for the variables:
|
206
219
|
|
207
|
-
* `FASTLY_TEST_USER` - Your user email
|
208
|
-
* `FASTLY_TEST_PASSWORD` - Your account password
|
209
|
-
* `FASTLY_TEST_API_KEY` - Your
|
220
|
+
* `FASTLY_TEST_USER` - Your user email
|
221
|
+
* `FASTLY_TEST_PASSWORD` - Your account password
|
222
|
+
* `FASTLY_TEST_API_KEY` - Your personal token
|
210
223
|
|
211
|
-
|
212
|
-
data, the tests will create and delete 3 services in sequence so you may want
|
213
|
-
to create an account just for tests.
|
224
|
+
3. Run the tests via `bundle exec rake test:unit`
|
214
225
|
|
215
226
|
## Copyright
|
216
227
|
|
217
|
-
Copyright 2011-
|
228
|
+
Copyright 2011-2020 - Fastly, Inc.
|
218
229
|
|
219
230
|
## Redistribution
|
220
231
|
|
data/RELEASE.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
**Release Process**
|
2
|
+
|
3
|
+
1. Sign up for an account on Ruby Gems (https://rubygems.org/sign_up)
|
4
|
+
2. Go to the `#app-eng-backends` channel and get added to the ruby gem (https://rubygems.org/gems/fastly)
|
5
|
+
3. Merge PR after CI passes
|
6
|
+
4. Open new PR to update `CHANGELOG.md`
|
7
|
+
5. Merge `CHANGELOG.md` PR
|
8
|
+
6. Rebase latest remote master branch locally (`git pull --rebase origin master`).
|
9
|
+
7. Tag a new release (`git tag vX.Y.Z && git push origin vX.Y.Z`)
|
10
|
+
8. Copy and paste `CHANGELOG.md` into the draft release
|
11
|
+
9. Publish draft release
|
12
|
+
10. Publish the gem to RubyGems.org (you will need your username and password on Ruby Gems)
|
13
|
+
|
14
|
+
- generate a new gem spec file with the new version `gem build fastly.gemspec`
|
15
|
+
- update RubyGems.org `gem push fastly-{VERSION}.gem`
|
data/lib/fastly.rb
CHANGED
@@ -55,8 +55,8 @@ class Fastly
|
|
55
55
|
#
|
56
56
|
# Some methods require full username and password rather than just auth token.
|
57
57
|
def initialize(opts)
|
58
|
-
if opts[:api_key].nil?
|
59
|
-
raise ArgumentError, "Required
|
58
|
+
if opts[:api_key].nil?
|
59
|
+
raise ArgumentError, "Required option missing. Please pass ':api_key'."
|
60
60
|
end
|
61
61
|
|
62
62
|
client(opts)
|
@@ -152,7 +152,34 @@ class Fastly
|
|
152
152
|
client.get_stats('/stats/regions')
|
153
153
|
end
|
154
154
|
|
155
|
-
[
|
155
|
+
[
|
156
|
+
ACL,
|
157
|
+
ACLEntry,
|
158
|
+
Backend,
|
159
|
+
CacheSetting,
|
160
|
+
Condition,
|
161
|
+
Customer,
|
162
|
+
Dictionary,
|
163
|
+
DictionaryItem,
|
164
|
+
Director,
|
165
|
+
Domain,
|
166
|
+
Gzip,
|
167
|
+
Header,
|
168
|
+
Healthcheck,
|
169
|
+
Match,
|
170
|
+
PapertrailLogging,
|
171
|
+
RequestSetting,
|
172
|
+
ResponseObject,
|
173
|
+
S3Logging,
|
174
|
+
Service,
|
175
|
+
Snippet,
|
176
|
+
SumologicLogging,
|
177
|
+
Syslog,
|
178
|
+
Token,
|
179
|
+
User,
|
180
|
+
VCL,
|
181
|
+
Version,
|
182
|
+
].each do |klass|
|
156
183
|
type = Util.class_to_path(klass)
|
157
184
|
|
158
185
|
if klass.respond_to?(:pluralize)
|
data/lib/fastly/client.rb
CHANGED
@@ -11,7 +11,7 @@ class Fastly
|
|
11
11
|
|
12
12
|
DEFAULT_URL = 'https://api.fastly.com'.freeze
|
13
13
|
|
14
|
-
attr_accessor :api_key, :base_url, :debug, :user, :password, :
|
14
|
+
attr_accessor :api_key, :base_url, :debug, :user, :password, :customer
|
15
15
|
|
16
16
|
def initialize(opts)
|
17
17
|
@api_key = opts.fetch(:api_key, nil)
|
@@ -25,18 +25,8 @@ class Fastly
|
|
25
25
|
Concurrent::ThreadLocalVar.new { build_http_client }
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
# If full auth creds (user/pass) then log in and set a cookie
|
31
|
-
resp = http.post(
|
32
|
-
'/login',
|
33
|
-
make_params(user: user, password: password),
|
34
|
-
{'Content-Type' => 'application/x-www-form-urlencoded'}
|
35
|
-
)
|
36
|
-
if resp.kind_of?(Net::HTTPSuccess)
|
37
|
-
@cookie = resp['Set-Cookie']
|
38
|
-
else
|
39
|
-
fail Unauthorized, "Invalid auth credentials. Check username/password."
|
28
|
+
if api_key.nil?
|
29
|
+
fail Unauthorized, "Invalid auth credentials. Check api_key."
|
40
30
|
end
|
41
31
|
|
42
32
|
self
|
@@ -146,9 +136,7 @@ class Fastly
|
|
146
136
|
|
147
137
|
def headers(extras={}, include_auth=true)
|
148
138
|
headers = {}
|
149
|
-
# Some endpoints (POST /tokens) break if any auth headers including cookies are sent
|
150
139
|
if include_auth
|
151
|
-
headers['Cookie'] = cookie if fully_authed?
|
152
140
|
headers['Fastly-Key'] = api_key if api_key
|
153
141
|
end
|
154
142
|
headers.merge('Content-Accept' => 'application/json', 'User-Agent' => "fastly-ruby-v#{Fastly::VERSION}").merge(extras.keep_if {|k,v| !v.nil? })
|
data/lib/fastly/gem_version.rb
CHANGED
data/lib/fastly/service.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
class Fastly
|
3
3
|
# Represents something you want to serve - this can be, for example, a whole web site, a Wordpress site, or just your image servers
|
4
4
|
class Service < Base
|
5
|
-
attr_accessor :id, :customer_id, :name, :comment
|
5
|
+
attr_accessor :id, :customer_id, :name, :comment
|
6
|
+
attr_writer :versions
|
6
7
|
|
7
8
|
@versions = []
|
8
9
|
|
data/lib/fastly/token.rb
CHANGED
@@ -21,12 +21,16 @@ class Fastly
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def new_token(opts)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
if client.fully_authed?
|
25
|
+
opts[:username] = client.user
|
26
|
+
opts[:password] = client.password
|
27
|
+
opts[:include_auth] = false
|
28
|
+
|
29
|
+
token = create(Token, opts)
|
30
|
+
token.nil? ? nil : token
|
31
|
+
else
|
32
|
+
raise ArgumentError, "Required options missing. Please pass :api_key, :user and :password."
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
def customer_tokens(opts)
|
data/test/api_key_test.rb
CHANGED
@@ -50,7 +50,7 @@ class Fastly
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
describe 'with
|
53
|
+
describe 'with username/password and api key' do
|
54
54
|
before do
|
55
55
|
@opts = login_opts(:both)
|
56
56
|
@client = Fastly::Client.new(@opts)
|
@@ -75,26 +75,6 @@ class Fastly
|
|
75
75
|
assert_equal 'ok', response['status']
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
79
|
-
describe 'with cookie only' do
|
80
|
-
before do
|
81
|
-
@opts = login_opts(:full)
|
82
|
-
@client = Fastly::Client.new(@opts)
|
83
|
-
@fastly = Fastly.new(@opts)
|
84
|
-
service_name = "fastly-test-service-#{random_string}"
|
85
|
-
@service = @fastly.create_service(:name => service_name)
|
86
|
-
end
|
87
|
-
|
88
|
-
after do
|
89
|
-
@fastly.delete_service(@service)
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'does not allow purging' do
|
93
|
-
assert_raises Fastly::KeyAuthRequired do
|
94
|
-
@service.purge_by_key('somekey')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
78
|
end
|
99
79
|
end
|
100
80
|
end
|
data/test/fastly/client_test.rb
CHANGED
@@ -12,7 +12,7 @@ describe Fastly::Client do
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'does not
|
15
|
+
it 'does not set the user/pass if they are not provided' do
|
16
16
|
client = Fastly::Client.new(api_key: api_key)
|
17
17
|
|
18
18
|
assert_equal api_key, client.api_key
|
@@ -20,13 +20,17 @@ describe Fastly::Client do
|
|
20
20
|
assert_equal nil, client.password
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'raises Unauthorized if api_key is not passed in the options' do
|
24
|
+
assert_raises(Fastly::Unauthorized) { Fastly::Client.new(user: user, password: password)}
|
25
|
+
end
|
26
|
+
|
23
27
|
it 'raises Unauthorized if user/pass provided but are invalid' do
|
24
28
|
stub_request(:any, /api.fastly.com/).to_return(status: 400)
|
25
29
|
|
26
30
|
e = assert_raises(Fastly::Unauthorized) {
|
27
|
-
Fastly::Client.new(user: user, password:
|
31
|
+
Fastly::Client.new(user: user, password: password)
|
28
32
|
}
|
29
|
-
assert_equal "Invalid auth credentials. Check
|
33
|
+
assert_equal "Invalid auth credentials. Check api_key.", e.message
|
30
34
|
end
|
31
35
|
|
32
36
|
it 'initializes an http client' do
|
@@ -38,23 +42,13 @@ describe Fastly::Client do
|
|
38
42
|
assert client.http.use_ssl?
|
39
43
|
end
|
40
44
|
|
41
|
-
it 'sets a cookie when auth with valid user/pass' do
|
42
|
-
stub_request(:any, /api.fastly.com/).
|
43
|
-
to_return(body: JSON.generate(i: "dont care"), status: 200, headers: { 'Set-Cookie' => 'tasty!' })
|
44
|
-
|
45
|
-
client = Fastly::Client.new(user: user, password: pass)
|
46
|
-
assert_equal "tasty!", client.cookie
|
47
|
-
end
|
48
|
-
|
49
45
|
it 'raises an Error if username is used in place of user as an option' do
|
50
46
|
stub_request(:any, /api.fastly.com/).
|
51
|
-
to_return(body: JSON.generate(i: "dont care"), status: 200
|
47
|
+
to_return(body: JSON.generate(i: "dont care"), status: 200)
|
52
48
|
|
53
|
-
assert_raises(ArgumentError) { Fastly.new(username: user, password:
|
49
|
+
assert_raises(ArgumentError) { Fastly.new(username: user, password: password) }
|
54
50
|
|
55
|
-
Fastly.new(user: user, password:
|
56
|
-
Fastly.new(api_key: api_key)
|
57
|
-
Fastly.new(api_key: api_key, user: user, password: pass)
|
51
|
+
Fastly.new(api_key: api_key, user: user, password: password)
|
58
52
|
end
|
59
53
|
end
|
60
54
|
|
@@ -7,7 +7,7 @@ describe Fastly::Customer do
|
|
7
7
|
let(:owner_id) { SecureRandom.hex(6) }
|
8
8
|
|
9
9
|
let(:customer) do
|
10
|
-
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200
|
10
|
+
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200)
|
11
11
|
|
12
12
|
customer_body = JSON.dump(
|
13
13
|
'id' => customer_id,
|
@@ -2,13 +2,13 @@ require_relative '../test_helper'
|
|
2
2
|
|
3
3
|
describe Fastly::Dictionary do
|
4
4
|
|
5
|
-
let(:client) { Fastly.new(
|
5
|
+
let(:client) { Fastly.new(api_key: 'notasecrettestkey') }
|
6
6
|
let(:service_id) { SecureRandom.hex(6) }
|
7
7
|
let(:version) { 1 }
|
8
8
|
let(:dictionary) { Fastly::Dictionary.new({id: SecureRandom.hex(6), service_id: service_id, version: 1}, client) }
|
9
9
|
|
10
10
|
before {
|
11
|
-
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200
|
11
|
+
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200)
|
12
12
|
}
|
13
13
|
|
14
14
|
describe '#item' do
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
describe Fastly::SumologicLogging do
|
4
|
+
let(:client) { Fastly.new(api_key: 'notasecrettestkey', user: 'test@example.com', password: 'password') }
|
5
|
+
let(:service_id) { SecureRandom.hex(6) }
|
6
|
+
let(:version) { 1 }
|
7
|
+
let(:sumo) { Fastly::SumologicLogging.new({ name: 'test_syslog', service_id: service_id, version: 1 }, client) }
|
8
|
+
|
9
|
+
before do
|
10
|
+
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#list' do
|
14
|
+
it 'lists sumologic endpoints' do
|
15
|
+
response_body = JSON.dump(
|
16
|
+
[
|
17
|
+
{
|
18
|
+
'created_at' => '2020-07-15T19:34:48Z',
|
19
|
+
'format_version' => '2',
|
20
|
+
'message_type' => 'blank',
|
21
|
+
'placement' => 'none',
|
22
|
+
'response_condition' => '',
|
23
|
+
'deleted_at' => nil,
|
24
|
+
'version' => '74',
|
25
|
+
'url' => 'https://endpoint1.collection.us2.sumologic.com/stuff',
|
26
|
+
'updated_at' => '2021-06-15T21:56:35Z',
|
27
|
+
'format' => 'fake',
|
28
|
+
'name' => 'Sumo Logic',
|
29
|
+
'service_id' => service_id
|
30
|
+
}
|
31
|
+
]
|
32
|
+
)
|
33
|
+
|
34
|
+
list_url = "#{Fastly::Client::DEFAULT_URL}/service/#{service_id}/version/#{version}/#{Fastly::SumologicLogging.path}"
|
35
|
+
stub_request(:get, list_url).to_return(body: response_body, status: 200)
|
36
|
+
|
37
|
+
get_service_url = "#{Fastly::Client::DEFAULT_URL}/service/#{service_id}/version/#{version}"
|
38
|
+
stub_request(:get, get_service_url).to_return(status: 200, body: '{}', headers: {})
|
39
|
+
|
40
|
+
sumos = client.list_sumologic_loggings(service_id: service_id, version: version)
|
41
|
+
assert_equal sumos.map {|s| [s.name, s.format]}, [['Sumo Logic', 'fake']]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/test/fastly/syslog_test.rb
CHANGED
@@ -2,13 +2,13 @@ require_relative '../test_helper'
|
|
2
2
|
|
3
3
|
describe Fastly::Syslog do
|
4
4
|
|
5
|
-
let(:client) { Fastly.new(user: 'test@example.com', password: 'password') }
|
5
|
+
let(:client) { Fastly.new(api_key: 'notasecrettestkey', user: 'test@example.com', password: 'password') }
|
6
6
|
let(:service_id) { SecureRandom.hex(6) }
|
7
7
|
let(:version) { 1 }
|
8
8
|
let(:syslog) { Fastly::Syslog.new({ name: 'test_syslog', service_id: service_id, version: 1 }, client) }
|
9
9
|
|
10
10
|
before {
|
11
|
-
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200
|
11
|
+
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200)
|
12
12
|
}
|
13
13
|
|
14
14
|
describe '#item' do
|
data/test/fastly/token_test.rb
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
3
|
describe Fastly::Token do
|
4
|
-
|
5
|
-
let(:elevated_fastly) { Fastly.new(user: 'test@example.com', password: 'password') }
|
6
|
-
let(:fastly) { Fastly.new(api_key:'my_api_key') }
|
4
|
+
let(:fastly) { Fastly.new(api_key:'my_api_key', user: 'test@example.com', password: 'password') }
|
7
5
|
|
8
6
|
before {
|
9
|
-
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200
|
7
|
+
stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200)
|
10
8
|
}
|
11
9
|
|
12
10
|
describe '#fastly' do
|
13
|
-
|
14
|
-
it 'cannot create itself because POST /tokens must have no auth headers)' do
|
11
|
+
it 'cannot create itself because POST /tokens must have no auth headers' do
|
15
12
|
stub_request(:post, "https://api.fastly.com/tokens").
|
16
13
|
with(
|
17
14
|
body: {"name"=>"name_of_token", "scope"=>"token_scope such_as purge_all purge_select", "services"=>"service_id_that_token_can_access"},
|
@@ -20,13 +17,12 @@ describe Fastly::Token do
|
|
20
17
|
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
21
18
|
'Content-Accept'=>'application/json',
|
22
19
|
'Content-Type'=>'application/x-www-form-urlencoded',
|
23
|
-
'Cookie'=>'tasty!',
|
24
20
|
'User-Agent'=> /fastly-ruby/
|
25
21
|
}).
|
26
22
|
to_return(status: 403, body: '{"msg":"You must POST /sudo to access this endpoint"}', headers: {})
|
27
23
|
|
28
24
|
assert_raises(Fastly::Error,'{"msg":"You must POST /sudo to access this endpoint"}') do
|
29
|
-
|
25
|
+
fastly.create_token(
|
30
26
|
name: 'name_of_token',
|
31
27
|
services: 'service_id_that_token_can_access',
|
32
28
|
scope: 'token_scope such_as purge_all purge_select'
|
@@ -63,7 +59,7 @@ describe Fastly::Token do
|
|
63
59
|
}).
|
64
60
|
to_return(status: 200, body: response_body, headers: {})
|
65
61
|
|
66
|
-
token =
|
62
|
+
token = fastly.new_token(
|
67
63
|
name: 'name_of_token',
|
68
64
|
services: 'service_id_that_token_can_access',
|
69
65
|
scope: 'optional token_scope such_as purge_all purge_select'
|
data/test/full_login_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'helper'
|
|
3
3
|
# Test username/password login access to user and customer objects
|
4
4
|
class Fastly
|
5
5
|
describe 'FullLoginTest' do
|
6
|
-
let(:opts) { login_opts(:
|
6
|
+
let(:opts) { login_opts(:both) }
|
7
7
|
let(:client) { Client.new(opts) }
|
8
8
|
let(:fastly) { Fastly.new(opts) }
|
9
9
|
let(:current_user) { fastly.current_user }
|
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fastly
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Client library for the Fastly acceleration system
|
14
14
|
email:
|
@@ -21,6 +21,7 @@ executables:
|
|
21
21
|
extensions: []
|
22
22
|
extra_rdoc_files: []
|
23
23
|
files:
|
24
|
+
- ".env.example"
|
24
25
|
- ".gitignore"
|
25
26
|
- ".rubocop.yml"
|
26
27
|
- ".travis.yml"
|
@@ -30,6 +31,7 @@ files:
|
|
30
31
|
- HISTORY.md
|
31
32
|
- LICENSE
|
32
33
|
- README.md
|
34
|
+
- RELEASE.md
|
33
35
|
- Rakefile
|
34
36
|
- bin/fastly_create_domain
|
35
37
|
- bin/fastly_upload_vcl
|
@@ -81,6 +83,7 @@ files:
|
|
81
83
|
- test/fastly/client_test.rb
|
82
84
|
- test/fastly/customer_test.rb
|
83
85
|
- test/fastly/dictionary_test.rb
|
86
|
+
- test/fastly/sumologic_logging_test.rb
|
84
87
|
- test/fastly/syslog_test.rb
|
85
88
|
- test/fastly/token_test.rb
|
86
89
|
- test/fastly/util_test.rb
|
@@ -94,7 +97,7 @@ homepage: http://github.com/fastly/fastly-ruby
|
|
94
97
|
licenses:
|
95
98
|
- MIT
|
96
99
|
metadata: {}
|
97
|
-
post_install_message:
|
100
|
+
post_install_message:
|
98
101
|
rdoc_options: []
|
99
102
|
require_paths:
|
100
103
|
- lib
|
@@ -109,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
112
|
- !ruby/object:Gem::Version
|
110
113
|
version: '0'
|
111
114
|
requirements: []
|
112
|
-
|
113
|
-
|
114
|
-
signing_key:
|
115
|
+
rubygems_version: 3.0.8
|
116
|
+
signing_key:
|
115
117
|
specification_version: 4
|
116
118
|
summary: Client library for the Fastly acceleration system
|
117
119
|
test_files:
|
@@ -123,6 +125,7 @@ test_files:
|
|
123
125
|
- test/fastly/client_test.rb
|
124
126
|
- test/fastly/customer_test.rb
|
125
127
|
- test/fastly/dictionary_test.rb
|
128
|
+
- test/fastly/sumologic_logging_test.rb
|
126
129
|
- test/fastly/syslog_test.rb
|
127
130
|
- test/fastly/token_test.rb
|
128
131
|
- test/fastly/util_test.rb
|