cloudflare 4.2.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/cloudflare/accounts.rb +8 -26
- data/lib/cloudflare/connection.rb +23 -31
- data/lib/cloudflare/custom_hostname/ssl_attribute/settings.rb +10 -4
- data/lib/cloudflare/custom_hostname/ssl_attribute.rb +8 -3
- data/lib/cloudflare/custom_hostnames.rb +64 -41
- data/lib/cloudflare/dns.rb +50 -52
- data/lib/cloudflare/firewall.rb +31 -42
- data/lib/cloudflare/kv/namespaces.rb +65 -29
- data/lib/cloudflare/kv/wrapper.rb +38 -0
- data/lib/cloudflare/logs.rb +7 -23
- data/lib/cloudflare/paginate.rb +21 -33
- data/lib/cloudflare/representation.rb +62 -86
- data/lib/cloudflare/user.rb +6 -23
- data/lib/cloudflare/version.rb +7 -21
- data/lib/cloudflare/zones.rb +46 -40
- data/lib/cloudflare.rb +18 -34
- data/license.md +41 -0
- data/readme.md +108 -0
- data.tar.gz.sig +0 -0
- metadata +61 -66
- metadata.gz.sig +2 -0
- data/lib/cloudflare/rspec/connection.rb +0 -57
data/lib/cloudflare.rb
CHANGED
@@ -1,47 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright,
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2016, by Marcin Prokop.
|
5
|
+
# Copyright, 2013, by Eric McKay.
|
6
|
+
# Copyright, 2014, by Jason Green.
|
7
|
+
# Copyright, 2014-2024, by Samuel Williams.
|
8
|
+
# Copyright, 2014, by Greg Retkowski.
|
9
|
+
# Copyright, 2018, by Leonhardt Wille.
|
10
|
+
# Copyright, 2019, by Akinori Musha.
|
23
11
|
|
24
|
-
require
|
25
|
-
require_relative
|
12
|
+
require "async"
|
13
|
+
require_relative "cloudflare/connection"
|
26
14
|
|
27
15
|
module Cloudflare
|
28
|
-
|
29
|
-
|
30
|
-
def self.connect(endpoint = DEFAULT_ENDPOINT, **auth_info)
|
31
|
-
representation = Connection.for(endpoint)
|
16
|
+
def self.connect(*arguments, **auth_info)
|
17
|
+
connection = Connection.open(*arguments)
|
32
18
|
|
33
19
|
if !auth_info.empty?
|
34
|
-
|
20
|
+
connection = connection.authenticated(**auth_info)
|
35
21
|
end
|
36
22
|
|
37
|
-
return
|
23
|
+
return connection unless block_given?
|
38
24
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
representation.close
|
44
|
-
end
|
25
|
+
Sync do
|
26
|
+
yield connection
|
27
|
+
ensure
|
28
|
+
connection.close
|
45
29
|
end
|
46
30
|
end
|
47
31
|
end
|
data/license.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2012-2017, by Marcin Prokop.
|
4
|
+
Copyright, 2013, by Eric McKay.
|
5
|
+
Copyright, 2014, by Jason Green.
|
6
|
+
Copyright, 2014-2024, by Samuel Williams.
|
7
|
+
Copyright, 2014, by Greg Retkowski.
|
8
|
+
Copyright, 2015, by Kyle Corbitt.
|
9
|
+
Copyright, 2015, by Guillaume Leseur.
|
10
|
+
Copyright, 2017, by Denis Sadomowski.
|
11
|
+
Copyright, 2017, by 莫粒.
|
12
|
+
Copyright, 2018, by Leonhardt Wille.
|
13
|
+
Copyright, 2018, by Mike Perham.
|
14
|
+
Copyright, 2018, by Michael Kalygin.
|
15
|
+
Copyright, 2018, by Sherman Koa.
|
16
|
+
Copyright, 2018, by Kugayama Nana.
|
17
|
+
Copyright, 2018, by Casey Lopez.
|
18
|
+
Copyright, 2019, by Akinori Musha.
|
19
|
+
Copyright, 2019, by Rob Widmer.
|
20
|
+
Copyright, 2019, by Fedishin Nazar.
|
21
|
+
Copyright, 2019, by David Wegman.
|
22
|
+
Copyright, 2020, by Olle Jonsson.
|
23
|
+
Copyright, 2021, by Terry Kerr.
|
24
|
+
|
25
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
26
|
+
of this software and associated documentation files (the "Software"), to deal
|
27
|
+
in the Software without restriction, including without limitation the rights
|
28
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
29
|
+
copies of the Software, and to permit persons to whom the Software is
|
30
|
+
furnished to do so, subject to the following conditions:
|
31
|
+
|
32
|
+
The above copyright notice and this permission notice shall be included in all
|
33
|
+
copies or substantial portions of the Software.
|
34
|
+
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
36
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
37
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
38
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
39
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
40
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
41
|
+
SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# Cloudflare
|
2
|
+
|
3
|
+
It is a Ruby wrapper for the Cloudflare V4 API. It provides a light weight wrapper using `RestClient::Resource`. The wrapper functionality is limited to zones and DNS records at this time, *PRs welcome*.
|
4
|
+
|
5
|
+
[![Development Status](https://github.com/socketry/cloudflare/workflows/Test/badge.svg)](https://github.com/socketry/cloudflare/actions?workflow=Test)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
gem 'cloudflare'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install cloudflare
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Here are some basic examples. For more details, refer to the code and specs.
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
require 'cloudflare'
|
29
|
+
|
30
|
+
# Grab some details from somewhere:
|
31
|
+
email = ENV['CLOUDFLARE_EMAIL']
|
32
|
+
key = ENV['CLOUDFLARE_KEY']
|
33
|
+
|
34
|
+
Cloudflare.connect(key: key, email: email) do |connection|
|
35
|
+
# Get all available zones:
|
36
|
+
zones = connection.zones
|
37
|
+
|
38
|
+
# Get a specific zone:
|
39
|
+
zone = connection.zones.find_by_id("...")
|
40
|
+
zone = connection.zones.find_by_name("example.com")
|
41
|
+
|
42
|
+
# Get DNS records for a given zone:
|
43
|
+
dns_records = zone.dns_records
|
44
|
+
|
45
|
+
# Show some details of the DNS record:
|
46
|
+
dns_record = dns_records.first
|
47
|
+
puts dns_record.name
|
48
|
+
|
49
|
+
# Add a DNS record. Here we add an A record for `batman.example.com`:
|
50
|
+
zone = zones.find_by_name("example.com")
|
51
|
+
zone.dns_records.create('A', 'batman', '1.2.3.4', proxied: false)
|
52
|
+
|
53
|
+
# Get firewall rules:
|
54
|
+
all_rules = zone.firewall_rules
|
55
|
+
|
56
|
+
# Block an ip:
|
57
|
+
rule = zone.firewall_rules.set('block', '1.2.3.4', notes: "ssh dictionary attack")
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
### Using a Bearer Token
|
62
|
+
|
63
|
+
You can read more about [bearer tokens here](https://blog.cloudflare.com/api-tokens-general-availability/). This allows you to limit priviledges.
|
64
|
+
|
65
|
+
``` ruby
|
66
|
+
require 'cloudflare'
|
67
|
+
|
68
|
+
token = 'a_generated_api_token'
|
69
|
+
|
70
|
+
Cloudflare.connect(token: token) do |connection|
|
71
|
+
# ...
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
### Using with Async
|
76
|
+
|
77
|
+
``` ruby
|
78
|
+
Async do
|
79
|
+
connection = Cloudflare.connect(...)
|
80
|
+
|
81
|
+
# ... do something with connection ...
|
82
|
+
ensure
|
83
|
+
connection.close
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
We welcome contributions to this project.
|
90
|
+
|
91
|
+
1. Fork it.
|
92
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
93
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
94
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
95
|
+
5. Create new Pull Request.
|
96
|
+
|
97
|
+
### Developer Certificate of Origin
|
98
|
+
|
99
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
100
|
+
|
101
|
+
### Community Guidelines
|
102
|
+
|
103
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
104
|
+
|
105
|
+
## See Also
|
106
|
+
|
107
|
+
- [Cloudflare::DNS::Update](https://github.com/ioquatix/cloudflare-dns-update) - A dynamic DNS updater based on this gem.
|
108
|
+
- [Rubyflare](https://github.com/trev/rubyflare) - Another implementation.
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,15 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudflare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Marcin Prokop
|
8
7
|
- Samuel Williams
|
8
|
+
- Marcin Prokop
|
9
|
+
- Leonhardt Wille
|
10
|
+
- Rob Widmer
|
11
|
+
- Akinori Musha
|
12
|
+
- Sherman Koa
|
13
|
+
- Michael Kalygin
|
14
|
+
- Denis Sadomowski
|
15
|
+
- Eric McKay
|
16
|
+
- Fedishin Nazar
|
17
|
+
- Casey Lopez
|
18
|
+
- David Wegman
|
19
|
+
- Greg Retkowski
|
20
|
+
- Guillaume Leseur
|
21
|
+
- Jason Green
|
22
|
+
- Kugayama Nana
|
23
|
+
- Kyle Corbitt
|
24
|
+
- Mike Perham
|
25
|
+
- Olle Jonsson
|
26
|
+
- Terry Kerr
|
27
|
+
- 莫粒
|
9
28
|
autorequire:
|
10
29
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
30
|
+
cert_chain:
|
31
|
+
- |
|
32
|
+
-----BEGIN CERTIFICATE-----
|
33
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
34
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
35
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
36
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
37
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
38
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
39
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
40
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
41
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
42
|
+
e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
|
43
|
+
XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
|
44
|
+
RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
|
45
|
+
tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
|
46
|
+
zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
|
47
|
+
xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
48
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
49
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
50
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
|
51
|
+
cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
|
52
|
+
xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
|
53
|
+
c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
|
54
|
+
8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
|
55
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
56
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
57
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
58
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
59
|
+
-----END CERTIFICATE-----
|
60
|
+
date: 2024-09-13 00:00:00.000000000 Z
|
13
61
|
dependencies:
|
14
62
|
- !ruby/object:Gem::Dependency
|
15
63
|
name: async-rest
|
@@ -17,70 +65,14 @@ dependencies:
|
|
17
65
|
requirements:
|
18
66
|
- - "~>"
|
19
67
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
68
|
+
version: '0.18'
|
21
69
|
type: :runtime
|
22
70
|
prerelease: false
|
23
71
|
version_requirements: !ruby/object:Gem::Requirement
|
24
72
|
requirements:
|
25
73
|
- - "~>"
|
26
74
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: async-rspec
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: bundler
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: covered
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rspec
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '3.6'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '3.6'
|
75
|
+
version: '0.18'
|
84
76
|
description:
|
85
77
|
email:
|
86
78
|
executables: []
|
@@ -96,17 +88,20 @@ files:
|
|
96
88
|
- lib/cloudflare/dns.rb
|
97
89
|
- lib/cloudflare/firewall.rb
|
98
90
|
- lib/cloudflare/kv/namespaces.rb
|
91
|
+
- lib/cloudflare/kv/wrapper.rb
|
99
92
|
- lib/cloudflare/logs.rb
|
100
93
|
- lib/cloudflare/paginate.rb
|
101
94
|
- lib/cloudflare/representation.rb
|
102
|
-
- lib/cloudflare/rspec/connection.rb
|
103
95
|
- lib/cloudflare/user.rb
|
104
96
|
- lib/cloudflare/version.rb
|
105
97
|
- lib/cloudflare/zones.rb
|
98
|
+
- license.md
|
99
|
+
- readme.md
|
106
100
|
homepage: https://github.com/socketry/cloudflare
|
107
101
|
licenses:
|
108
102
|
- MIT
|
109
|
-
metadata:
|
103
|
+
metadata:
|
104
|
+
source_code_uri: https://github.com/socketry/cloudflare.git
|
110
105
|
post_install_message:
|
111
106
|
rdoc_options: []
|
112
107
|
require_paths:
|
@@ -115,14 +110,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
110
|
requirements:
|
116
111
|
- - ">="
|
117
112
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
113
|
+
version: '3.1'
|
119
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
115
|
requirements:
|
121
116
|
- - ">="
|
122
117
|
- !ruby/object:Gem::Version
|
123
118
|
version: '0'
|
124
119
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.5.11
|
126
121
|
signing_key:
|
127
122
|
specification_version: 4
|
128
123
|
summary: A Ruby wrapper for the Cloudflare API.
|
metadata.gz.sig
ADDED
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'async/rspec'
|
24
|
-
require 'async/http/proxy'
|
25
|
-
|
26
|
-
require_relative '../../cloudflare'
|
27
|
-
|
28
|
-
module Cloudflare
|
29
|
-
module RSpec
|
30
|
-
module Connection
|
31
|
-
end
|
32
|
-
|
33
|
-
RSpec.shared_context Connection do
|
34
|
-
include_context Async::RSpec::Reactor
|
35
|
-
|
36
|
-
# You must specify these in order for the tests to run.
|
37
|
-
let(:email) {ENV['CLOUDFLARE_EMAIL']}
|
38
|
-
let(:key) {ENV['CLOUDFLARE_KEY']}
|
39
|
-
|
40
|
-
let(:connection) do
|
41
|
-
if proxy_url = ENV['CLOUDFLARE_PROXY']
|
42
|
-
proxy_endpoint = Async::HTTP::Endpoint.parse(proxy_url)
|
43
|
-
@client = Async::HTTP::Client.new(proxy_endpoint)
|
44
|
-
@connection = Cloudflare.connect(@client.proxied_endpoint(DEFAULT_ENDPOINT), key: key, email: email)
|
45
|
-
else
|
46
|
-
@client = nil
|
47
|
-
@connection = Cloudflare.connect(key: key, email: email)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
after do
|
52
|
-
@connection&.close
|
53
|
-
@client&.close
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|