Skip to content

Commit

Permalink
Enable shielding (#25)
Browse files Browse the repository at this point in the history
* feat: enable setting up of shielding in Fastly

* test: update tests
  • Loading branch information
herschel666 authored and boris-jarkowicz committed Jul 24, 2017
1 parent afac1ce commit 0f6800a
Show file tree
Hide file tree
Showing 28 changed files with 1,640 additions and 1,593 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ $ ansible-galaxy install Jimdo.fastly

[Fastly documentation](https://docs.fastly.com/api/config#backend)

| Field | Required | Type | Default |
|:--------------|:---------|:--------------------------------------------------------|:--------|
| name | true | string | |
| port | false | integer | 80 |
| address | true | string | |
| ssl_hostname | false | string | |
| ssl_ca_cert | false | string | |
| Field | Required | Type | Default |
|:------------------|:---------|:--------------------------------------------------------|:--------|
| name | true | string | |
| port | false | integer | 80 |
| address | true | string | |
| ssl_hostname | false | string | |
| ssl_ca_cert | false | string | |
| ssl_cert_hostname | false | string | |
| shield | false | string | |

### Cache Settings

Expand Down
6 changes: 5 additions & 1 deletion library/fastly_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ class FastlyBackend(FastlyObject):
'address': dict(required=True, type='str', default=None),
'request_condition': dict(required=False, type='str', default=''),
'ssl_hostname': dict(required=False, type='str', default=None),
'ssl_ca_cert': dict(required=False, type='str', default=None, exclude_empty_str=True)
'ssl_ca_cert': dict(required=False, type='str', default=None, exclude_empty_str=True),
'ssl_cert_hostname': dict(required=False, type='str', default=None, exclude_empty_str=True),
'shield': dict(required=False, type='str', default=None, exclude_empty_str=True)
}
sort_key = lambda f: f.name

Expand All @@ -220,6 +222,8 @@ def __init__(self, config, validate_choices):
self.request_condition = self.read_config(config, validate_choices, 'request_condition')
self.ssl_hostname = self.read_config(config, validate_choices, 'ssl_hostname')
self.ssl_ca_cert = self.read_config(config, validate_choices, 'ssl_ca_cert')
self.ssl_cert_hostname = self.read_config(config, validate_choices, 'ssl_cert_hostname')
self.shield = self.read_config(config, validate_choices, 'shield')


class FastlyCacheSettings(FastlyObject):
Expand Down
50 changes: 25 additions & 25 deletions tests/fixtures/cassettes/TestFastlyCacheSettings_tearDown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,82 @@ interactions:
method: GET
uri: https://api.fastly.com/service/search?name=Fastly%20Ansible%20Module%20Test
response:
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"created_at":"2017-07-03T14:35:33+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-03T14:35:33+00:00","deployed":false},{"testing":false,"locked":true,"number":2,"active":false,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"created_at":"2017-07-03T14:35:34+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-03T14:38:31+00:00","deployed":false},{"testing":false,"number":3,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"deployed":false,"locked":true,"active":true,"comment":""}],"created_at":"2017-07-03T14:35:33+00:00","customer_id":"15DqjG1ON0S28gluYrATvC","comment":"","updated_at":"2017-07-03T14:35:33+00:00","id":"6mun9U5GzoAQjhLkBaWLfs"}'}
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"4fQRV22wi5eS4BaodeS5Cg","staging":false,"created_at":"2017-07-19T11:29:59+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-19T11:29:59+00:00","deployed":false},{"testing":false,"number":2,"service_id":"4fQRV22wi5eS4BaodeS5Cg","staging":false,"deployed":false,"locked":true,"active":true,"comment":""}],"created_at":"2017-07-19T11:29:59+00:00","customer_id":"31RPDMBpiruA1yfGA2djLm","comment":"","updated_at":"2017-07-19T11:29:59+00:00","id":"4fQRV22wi5eS4BaodeS5Cg"}'}
headers:
accept-ranges: [bytes]
age: ['0']
cache-control: [no-cache]
connection: [keep-alive]
content-length: ['858']
content-length: ['616']
content-type: [application/json]
date: ['Mon, 03 Jul 2017 14:38:33 GMT']
date: ['Wed, 19 Jul 2017 11:30:07 GMT']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9050-SL, cache-fra1236-FRA']
x-timer: ['S1499092713.877957,VS0,VE527']
x-served-by: ['app-slwdc9051-SL, cache-fra1224-FRA']
x-timer: ['S1500463807.910718,VS0,VE478']
status: {code: 200, message: OK}
- request:
body: null
headers:
Content-Type: [application/json]
method: GET
uri: https://api.fastly.com/service/6mun9U5GzoAQjhLkBaWLfs/details
uri: https://api.fastly.com/service/4fQRV22wi5eS4BaodeS5Cg/details
response:
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"created_at":"2017-07-03T14:35:33+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-03T14:35:33+00:00","deployed":false},{"testing":false,"locked":true,"number":2,"active":false,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"created_at":"2017-07-03T14:35:34+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-03T14:38:31+00:00","deployed":false},{"testing":false,"locked":true,"number":3,"active":true,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"created_at":"2017-07-03T14:38:27+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-03T14:38:31+00:00","deployed":false}],"created_at":"2017-07-03T14:35:33+00:00","customer_id":"15DqjG1ON0S28gluYrATvC","comment":"","updated_at":"2017-07-03T14:35:33+00:00","id":"6mun9U5GzoAQjhLkBaWLfs","version":{"testing":false,"number":3,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"updated_at":"2017-07-03T14:38:31+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-07-03T14:38:27+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[{"stale_ttl":"10","ttl":null,"name":"cache-settings-config-name","action":null,"cache_condition":""}],"conditions":[],"dictionaries":[],"directors":[],"domains":[{"comment":"","name":"example7000.com"}],"gzips":[],"headers":[{"priority":"100","src":"\"https://u.jimcdn.com\"
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"4fQRV22wi5eS4BaodeS5Cg","staging":false,"created_at":"2017-07-19T11:29:59+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-19T11:29:59+00:00","deployed":false},{"testing":false,"locked":true,"number":2,"active":true,"service_id":"4fQRV22wi5eS4BaodeS5Cg","staging":false,"created_at":"2017-07-19T11:30:01+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-19T11:30:05+00:00","deployed":false}],"created_at":"2017-07-19T11:29:59+00:00","customer_id":"31RPDMBpiruA1yfGA2djLm","comment":"","updated_at":"2017-07-19T11:29:59+00:00","id":"4fQRV22wi5eS4BaodeS5Cg","version":{"testing":false,"number":2,"service_id":"4fQRV22wi5eS4BaodeS5Cg","staging":false,"updated_at":"2017-07-19T11:30:05+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-07-19T11:30:01+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[{"stale_ttl":"10","ttl":null,"name":"cache-settings-config-name","action":null,"cache_condition":""}],"conditions":[],"dictionaries":[],"directors":[],"domains":[{"comment":"","name":"example7000.com"}],"gzips":[],"headers":[{"priority":"100","src":"\"https://u.jimcdn.com\"
req.url.path","name":"Set Location header","substitution":"","ignore_if_set":"0","cache_condition":null,"request_condition":null,"regex":"","response_condition":null,"action":"set","type":"response","dst":"http.Location"}],"healthchecks":[],"request_settings":[],"response_objects":[{"request_condition":"","content_type":null,"status":"200","response":"Ok","name":"Set
200 status code","content":null,"cache_condition":""}],"snippets":[],"vcls":[],"wordpress":[],"settings":{"general.default_ttl":3600,"general.default_host":"","general.default_pci":0}},"active_version":{"testing":false,"number":3,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"updated_at":"2017-07-03T14:38:31+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-07-03T14:38:27+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[{"stale_ttl":"10","ttl":null,"name":"cache-settings-config-name","action":null,"cache_condition":""}],"conditions":[],"dictionaries":[],"directors":[],"domains":[{"comment":"","name":"example7000.com"}],"gzips":[],"headers":[{"priority":"100","src":"\"https://u.jimcdn.com\"
200 status code","content":null,"cache_condition":""}],"snippets":[],"vcls":[],"wordpress":[],"settings":{"general.default_ttl":3600,"general.default_host":"","general.default_pci":0}},"active_version":{"testing":false,"number":2,"service_id":"4fQRV22wi5eS4BaodeS5Cg","staging":false,"updated_at":"2017-07-19T11:30:05+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-07-19T11:30:01+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[{"stale_ttl":"10","ttl":null,"name":"cache-settings-config-name","action":null,"cache_condition":""}],"conditions":[],"dictionaries":[],"directors":[],"domains":[{"comment":"","name":"example7000.com"}],"gzips":[],"headers":[{"priority":"100","src":"\"https://u.jimcdn.com\"
req.url.path","name":"Set Location header","substitution":"","ignore_if_set":"0","cache_condition":null,"request_condition":null,"regex":"","response_condition":null,"action":"set","type":"response","dst":"http.Location"}],"healthchecks":[],"request_settings":[],"response_objects":[{"request_condition":"","content_type":null,"status":"200","response":"Ok","name":"Set
200 status code","content":null,"cache_condition":""}],"snippets":[],"vcls":[],"wordpress":[],"settings":{"general.default_ttl":3600,"general.default_host":"","general.default_pci":0}}}'}
headers:
accept-ranges: [bytes]
age: ['0']
cache-control: [no-cache]
connection: [keep-alive]
content-length: ['4361']
content-length: ['4119']
content-type: [application/json]
date: ['Mon, 03 Jul 2017 14:38:33 GMT']
date: ['Wed, 19 Jul 2017 11:30:07 GMT']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9050-SL, cache-fra1224-FRA']
x-timer: ['S1499092714.596287,VS0,VE129']
x-served-by: ['app-slwdc9051-SL, cache-fra1231-FRA']
x-timer: ['S1500463807.448077,VS0,VE205']
status: {code: 200, message: OK}
- request:
body: null
headers:
Content-Type: [application/json]
method: PUT
uri: https://api.fastly.com/service/6mun9U5GzoAQjhLkBaWLfs/version/3/deactivate
uri: https://api.fastly.com/service/4fQRV22wi5eS4BaodeS5Cg/version/2/deactivate
response:
body: {string: !!python/unicode '{"testing":false,"locked":true,"number":3,"active":false,"service_id":"6mun9U5GzoAQjhLkBaWLfs","staging":false,"created_at":"2017-07-03T14:38:27+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-03T14:38:31+00:00","deployed":false}'}
body: {string: !!python/unicode '{"testing":false,"locked":true,"number":2,"active":false,"service_id":"4fQRV22wi5eS4BaodeS5Cg","staging":false,"created_at":"2017-07-19T11:30:01+00:00","deleted_at":null,"comment":"","updated_at":"2017-07-19T11:30:05+00:00","deployed":false}'}
headers:
accept-ranges: [bytes]
cache-control: [no-cache]
connection: [keep-alive]
content-length: ['241']
content-type: [application/json]
date: ['Mon, 03 Jul 2017 14:38:34 GMT']
fastly-ratelimit-remaining: ['362']
fastly-ratelimit-reset: ['1499094000']
date: ['Wed, 19 Jul 2017 11:30:07 GMT']
fastly-ratelimit-remaining: ['694']
fastly-ratelimit-reset: ['1500465600']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9051-SL, cache-fra1250-FRA']
x-timer: ['S1499092714.760754,VS0,VE463']
x-served-by: ['app-slwdc9050-SL, cache-fra1232-FRA']
x-timer: ['S1500463808.723168,VS0,VE258']
status: {code: 200, message: OK}
- request:
body: null
headers:
Content-Type: [application/json]
method: DELETE
uri: https://api.fastly.com/service/6mun9U5GzoAQjhLkBaWLfs
uri: https://api.fastly.com/service/4fQRV22wi5eS4BaodeS5Cg
response:
body: {string: !!python/unicode '{"status":"ok"}'}
headers:
Expand All @@ -90,15 +90,15 @@ interactions:
connection: [keep-alive]
content-length: ['15']
content-type: [application/json]
date: ['Mon, 03 Jul 2017 14:38:34 GMT']
fastly-ratelimit-remaining: ['361']
fastly-ratelimit-reset: ['1499094000']
date: ['Wed, 19 Jul 2017 11:30:09 GMT']
fastly-ratelimit-remaining: ['693']
fastly-ratelimit-reset: ['1500465600']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9050-SL, cache-fra1245-FRA']
x-timer: ['S1499092714.279362,VS0,VE460']
x-served-by: ['app-slwdc9051-SL, cache-fra1247-FRA']
x-timer: ['S1500463809.655601,VS0,VE496']
status: {code: 200, message: OK}
version: 1
Loading

0 comments on commit 0f6800a

Please sign in to comment.