fastly 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 303ad518137e3776d1eb3d3c8f01248428cb9cae
4
- data.tar.gz: 4eb4cceb4e98c19e9da337df56ab520b271cdb8c
3
+ metadata.gz: 10d1ee5f00e5a54a06df32a4dbc1e41ce8f8cdb0
4
+ data.tar.gz: 3f71dd70500900ccc6f9441f527942460e65c370
5
5
  SHA512:
6
- metadata.gz: efe685e5ffb5ed74d0817ee3fda2a4e9e4239685e817c20df42a56fa6ac7ae5d53d8f21c2a52a05fb6a4a9454a59121c8b6d8cbaa3a311cd7f632f629dcf1551
7
- data.tar.gz: e6156561472906f58a67ccd7e6da2586836b6926397371b31732516f05675f32632126d60268d7aa642a2919fcce314af44d2543cb7d841e3ade9b86cf0af288
6
+ metadata.gz: 0ac1c20ca21c3105213e374d01544053cacccbb5d5f2e04bc39705b005c8f21fd1093c1534db32c043bf7ada317d1315e135be0651316260626bd84f16a66f53
7
+ data.tar.gz: 70ad854b592e01a1d068cc622c44d351269638de477652cfec6b25d955a2a535cc67c192c340953c04a0fe573a990c29d495781a19facce49edf5b7880574e53
@@ -22,7 +22,6 @@ require 'fastly/healthcheck'
22
22
  require 'fastly/gzip'
23
23
  require 'fastly/invoice'
24
24
  require 'fastly/match'
25
- require 'fastly/origin'
26
25
  require 'fastly/request_setting'
27
26
  require 'fastly/response_object'
28
27
  require 'fastly/service'
@@ -143,7 +142,7 @@ class Fastly
143
142
  client.get_stats('/stats/regions')
144
143
  end
145
144
 
146
- [User, Customer, Backend, CacheSetting, Condition, Dictionary, DictionaryItem, Director, Domain, Header, Healthcheck, Gzip, Match, Origin, RequestSetting, ResponseObject, Service, S3Logging, Syslog, VCL, Version].each do |klass|
145
+ [User, Customer, Backend, CacheSetting, Condition, Dictionary, DictionaryItem, Director, Domain, Header, Healthcheck, Gzip, Match, RequestSetting, ResponseObject, Service, S3Logging, Syslog, VCL, Version].each do |klass|
147
146
  type = Util.class_to_path(klass)
148
147
 
149
148
  if klass.respond_to?(:pluralize)
@@ -203,10 +202,6 @@ class Fastly
203
202
  # :method: create_match(opts)
204
203
  # opts must contain service_id, version and name params
205
204
 
206
- ##
207
- # :method: create_origin(opts)
208
- # opts must contain service_id, version and name params
209
-
210
205
  ##
211
206
  # :method: create_healthcheck(opts)
212
207
  # opts must contain service_id, version and name params
@@ -291,10 +286,6 @@ class Fastly
291
286
  # :method: get_match(service_id, number, name)
292
287
  # Get a Match
293
288
 
294
- ##
295
- # :method: get_origin(service_id, number, name)
296
- # Get an Origin
297
-
298
289
  ##
299
290
  # :method: get_s3_logging(service_id, number, name)
300
291
  # Get a S3 logging
@@ -394,11 +385,6 @@ class Fastly
394
385
  # You can also call
395
386
  # match.save!
396
387
 
397
- ##
398
- # :method: update_origin(origin)
399
- # You can also call
400
- # origin.save!
401
-
402
388
  ##
403
389
  # :method: update_settings(settings)
404
390
  # You can also call
@@ -509,11 +495,6 @@ class Fastly
509
495
  # You can also call
510
496
  # match.delete!(match)
511
497
 
512
- ##
513
- # :method: delete_origin(origin)
514
- # You can also call
515
- # origin.delete!
516
-
517
498
  ##
518
499
  # :method: delete_s3_logging(s3_logging)
519
500
  # You can also call
@@ -608,10 +589,6 @@ class Fastly
608
589
  #
609
590
  # Get a list of all matches
610
591
 
611
- # :method: list_origins(:service_id => service.id, :version => version.number)
612
- #
613
- # Get a list of all origins
614
-
615
592
  # :method: list_syslogs(:service_id => service.id, :version => version.number)
616
593
  #
617
594
  # Get a list of all syslogs
@@ -119,7 +119,9 @@ class Fastly
119
119
  end
120
120
 
121
121
  def headers(extras={})
122
- headers = fully_authed? ? { 'Cookie' => cookie } : { 'Fastly-Key' => api_key }
122
+ headers = fully_authed? ? { 'Cookie' => cookie } : {}
123
+ headers['Fastly-Key'] = api_key if api_key
124
+
123
125
  headers.merge('Content-Accept' => 'application/json', 'User-Agent' => "fastly-ruby-v#{Fastly::VERSION}").merge(extras.keep_if {|k,v| !v.nil? })
124
126
  end
125
127
 
@@ -1,4 +1,4 @@
1
1
  # The current version of the library
2
2
  class Fastly
3
- VERSION = "1.5.0"
3
+ VERSION = "1.6.0"
4
4
  end
@@ -24,28 +24,76 @@ class Fastly
24
24
  end
25
25
 
26
26
  describe 'purging' do
27
- before do
28
- @opts = login_opts(:api_key)
27
+ describe 'with only api key' do
28
+ before do
29
+ @opts = login_opts(:api_key)
29
30
  @client = Fastly::Client.new(@opts)
30
31
  @fastly = Fastly.new(@opts)
31
- service_name = "fastly-test-service-#{random_string}"
32
- @service = @fastly.create_service(:name => service_name)
33
- end
32
+ service_name = "fastly-test-service-#{random_string}"
33
+ @service = @fastly.create_service(:name => service_name)
34
+ end
35
+
36
+ after do
37
+ @fastly.delete_service(@service)
38
+ end
39
+
40
+ it 'allows purging' do
41
+ response = @service.purge_by_key('somekey')
42
+
43
+ assert_equal 'ok', response['status']
44
+ end
34
45
 
35
- after do
36
- @fastly.delete_service(@service)
46
+ it 'allows soft purging' do
47
+ response = @service.purge_by_key('somekey', soft: true)
48
+
49
+ assert_equal 'ok', response['status']
50
+ end
37
51
  end
38
52
 
39
- it 'allows purging' do
40
- response = @service.purge_by_key('somekey')
53
+ describe 'with cookie and api key' do
54
+ before do
55
+ @opts = login_opts(:both)
56
+ @client = Fastly::Client.new(@opts)
57
+ @fastly = Fastly.new(@opts)
58
+ service_name = "fastly-test-service-#{random_string}"
59
+ @service = @fastly.create_service(:name => service_name)
60
+ end
61
+
62
+ after do
63
+ @fastly.delete_service(@service)
64
+ end
65
+
66
+ it 'allows purging' do
67
+ response = @service.purge_by_key('somekey')
68
+
69
+ assert_equal 'ok', response['status']
70
+ end
71
+
72
+ it 'allows soft purging' do
73
+ response = @service.purge_by_key('somekey', soft: true)
41
74
 
42
- assert_equal 'ok', response['status']
75
+ assert_equal 'ok', response['status']
76
+ end
43
77
  end
44
78
 
45
- it 'allows soft purging' do
46
- response = @service.purge_by_key('somekey', soft: true)
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
47
91
 
48
- assert_equal 'ok', response['status']
92
+ it 'does not allow purging' do
93
+ assert_raises Fastly::KeyAuthRequired do
94
+ @service.purge_by_key('somekey')
95
+ end
96
+ end
49
97
  end
50
98
  end
51
99
  end
@@ -101,14 +101,6 @@ module CommonTests
101
101
  assert director.add_backend(backend)
102
102
  # generated2 = version3.generated_vcl
103
103
 
104
- origin_name = "fastly-test-origin-#{random_string}"
105
- origin = @fastly.create_origin(:service_id => service.id, :version => number, :name => origin_name)
106
- assert origin
107
- assert_equal origin_name, origin.name
108
- assert_equal service.id, origin.service.id
109
- assert_equal number.to_s, origin.version_number.to_s
110
- # assert_equal origin.version.number.to_s, number.to_s
111
-
112
104
  condition_name = "fastly-test-condition-#{random_string}"
113
105
  condition_statement = 'req.url ~ "^/foo"'
114
106
  condition = @fastly.create_condition(:service_id => service.id, :version => number, :name => condition_name, :statement => condition_statement, :type => 'REQUEST')
@@ -149,7 +141,7 @@ module CommonTests
149
141
  response_condition_name = "fastly-response-condition-#{random_string}"
150
142
  response_condition = @fastly.create_condition(:service_id => service.id, :version => number, :name => response_condition_name, :statement => condition_statement, :type => 'RESPONSE')
151
143
  header_name = "fastly-header-test-#{random_string}"
152
- header = @fastly.create_header(:service_id => service.id, :version => number, :name => header_name, :response_condition => response_condition.name, :ignore_if_set => 1, :type => 'response', :dst => 'http.Cache-Control', :src => '"max-age=301"', :priority => 10, :action => 'set', :regex => /foo/)
144
+ header = @fastly.create_header(:service_id => service.id, :version => number, :name => header_name, :response_condition => response_condition.name, :ignore_if_set => 1, :type => 'response', :dst => 'http.Cache-Control', :src => '"max-age=301"', :priority => 10, :action => 'set', :regex => 'foo')
153
145
  assert header
154
146
  assert_equal header_name, header.name
155
147
  assert_equal response_condition.name, header.response_condition
@@ -157,7 +149,7 @@ module CommonTests
157
149
  assert_equal 'http.Cache-Control', header.dst
158
150
  assert_equal '"max-age=301"', header.src
159
151
  assert_equal 'set', header.action
160
- assert_equal(/foo/, header.regex)
152
+ assert_equal('foo', header.regex)
161
153
 
162
154
  assert version3.activate!
163
155
  assert version3.deactivate!
@@ -14,7 +14,15 @@ def login_opts(mode = :full)
14
14
  opts["base_#{what}".to_sym] = ENV[key] if ENV.key?(key)
15
15
  end
16
16
 
17
- required = :full == mode ? [:user, :password] : [:api_key]
17
+ required = case mode
18
+ when :full
19
+ [:user, :password]
20
+ when :both
21
+ [:user, :password, :api_key]
22
+ else
23
+ [:api_key]
24
+ end
25
+
18
26
  required.each do |what|
19
27
  key = "FASTLY_TEST_#{what.to_s.upcase}"
20
28
  unless ENV.key?(key)
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: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fastly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Client library for the Fastly acceleration system
14
14
  email:
@@ -52,7 +52,6 @@ files:
52
52
  - lib/fastly/healthcheck.rb
53
53
  - lib/fastly/invoice.rb
54
54
  - lib/fastly/match.rb
55
- - lib/fastly/origin.rb
56
55
  - lib/fastly/request_setting.rb
57
56
  - lib/fastly/response_object.rb
58
57
  - lib/fastly/s3_logging.rb
@@ -1,39 +0,0 @@
1
- class Fastly
2
- # A logical group of directors - for example the asset server directors from all your DCNs
3
- class Origin < BelongsToServiceAndVersion
4
- attr_accessor :service_id, :name, :comment
5
-
6
- ##
7
- # :attr: service_id
8
- #
9
- # The id of the service this belongs to.
10
- #
11
-
12
- ##
13
- # :attr: version
14
- #
15
- # The number of the version this belongs to.
16
- #
17
-
18
- ##
19
- # :attr: name
20
- #
21
- # The domain name of this domain
22
-
23
- # Add a Director object to an Origin
24
- #
25
- # Return true on success and false on failure
26
- def add_director(director)
27
- hash = fetcher.client.post("#{Origin.put_path(self)}/director/#{director.name}")
28
- !hash.nil?
29
- end
30
-
31
- # Delete a Director object from an Origin
32
- #
33
- # Return true on success and false on failure
34
- def delete_director(director)
35
- hash = fetcher.client.delete("#{Origin.put_path(self)}/director/#{director.name}")
36
- !hash.nil?
37
- end
38
- end
39
- end