cloudflare 4.0.1 → 4.2.0
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/.gitignore +13 -5
- data/.travis.yml +13 -2
- data/Gemfile +20 -0
- data/README.md +15 -4
- data/cloudflare.gemspec +1 -1
- data/lib/cloudflare.rb +5 -5
- data/lib/cloudflare/accounts.rb +12 -16
- data/lib/cloudflare/connection.rb +14 -10
- data/lib/cloudflare/custom_hostname/ssl_attribute.rb +62 -0
- data/lib/cloudflare/custom_hostname/ssl_attribute/settings.rb +71 -0
- data/lib/cloudflare/custom_hostnames.rb +82 -0
- data/lib/cloudflare/dns.rb +16 -20
- data/lib/cloudflare/firewall.rb +9 -16
- data/lib/cloudflare/kv/namespaces.rb +78 -0
- data/lib/cloudflare/paginate.rb +19 -21
- data/lib/cloudflare/representation.rb +32 -15
- data/lib/cloudflare/rspec/connection.rb +13 -1
- data/lib/cloudflare/version.rb +1 -1
- data/lib/cloudflare/zones.rb +13 -17
- data/spec/cloudflare/accounts_spec.rb +24 -0
- data/spec/cloudflare/custom_hostname/ssl_attribute/settings_spec.rb +54 -0
- data/spec/cloudflare/custom_hostname/ssl_attribute_spec.rb +73 -0
- data/spec/cloudflare/custom_hostnames_spec.rb +213 -0
- data/spec/cloudflare/dns_spec.rb +24 -6
- data/spec/cloudflare/kv/namespaces_spec.rb +71 -0
- data/spec/cloudflare/zone_spec.rb +13 -11
- data/spec/spec_helper.rb +60 -9
- metadata +21 -7
@@ -1,23 +1,25 @@
|
|
1
1
|
|
2
2
|
RSpec.describe Cloudflare::Zones, order: :defined, timeout: 30 do
|
3
3
|
include_context Cloudflare::Zone
|
4
|
-
|
5
|
-
|
6
|
-
if
|
7
|
-
|
4
|
+
|
5
|
+
if ENV['CLOUDFLARE_TEST_ZONE_MANAGEMENT'] == 'true'
|
6
|
+
it "can delete existing domain if exists" do
|
7
|
+
if zone = zones.find_by_name(name)
|
8
|
+
expect(zone.delete).to be_success
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can create a zone" do
|
13
|
+
zone = zones.create(name, account)
|
14
|
+
expect(zone.value).to include(:id)
|
8
15
|
end
|
9
16
|
end
|
10
|
-
|
11
|
-
it "can create zone" do
|
12
|
-
zone = zones.create(name, account)
|
13
|
-
expect(zone.value).to include(:id)
|
14
|
-
end
|
15
|
-
|
17
|
+
|
16
18
|
it "can list zones" do
|
17
19
|
matching_zones = zones.select{|zone| zone.name == name}
|
18
20
|
expect(matching_zones).to_not be_empty
|
19
21
|
end
|
20
|
-
|
22
|
+
|
21
23
|
it "can get zone by name" do
|
22
24
|
found_zone = zones.find_by_name(name)
|
23
25
|
expect(found_zone.name).to be == name
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
AUTH_EMAIL = ENV['CLOUDFLARE_EMAIL']
|
4
|
+
AUTH_KEY = ENV['CLOUDFLARE_KEY']
|
5
|
+
|
6
|
+
if AUTH_EMAIL.nil? || AUTH_EMAIL.empty? || AUTH_KEY.nil? || AUTH_KEY.empty?
|
7
|
+
puts 'Please make sure you have defined CLOUDFLARE_EMAIL and CLOUDFLARE_KEY in your environment'
|
8
|
+
puts 'You can also specify CLOUDFLARE_ZONE_NAME to test with your own zone and'
|
9
|
+
puts 'CLOUDFLARE_ACCOUNT_ID to use a specific account'
|
10
|
+
exit(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
ACCOUNT_ID = ENV['CLOUDFLARE_ACCOUNT_ID']
|
14
|
+
NAMES = ['testing', 'horse', 'cat', 'dog', 'fish', 'dolphin', 'lion', 'tiger'].freeze
|
15
|
+
JOB_ID = ENV.fetch('TRAVIS_JOB_ID', 0).to_i
|
16
|
+
ZONE_NAME = ENV['CLOUDFLARE_ZONE_NAME'] || "#{NAMES[JOB_ID % NAMES.size]}.com"
|
1
17
|
|
2
18
|
require 'covered/rspec'
|
3
19
|
require 'async/rspec'
|
@@ -5,18 +21,30 @@ require 'async/rspec'
|
|
5
21
|
require 'cloudflare/rspec/connection'
|
6
22
|
require 'cloudflare/zones'
|
7
23
|
|
8
|
-
RSpec.shared_context Cloudflare::
|
24
|
+
RSpec.shared_context Cloudflare::Account do
|
9
25
|
include_context Cloudflare::RSpec::Connection
|
10
|
-
|
11
|
-
let(:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
26
|
+
|
27
|
+
let(:account) do
|
28
|
+
if ACCOUNT_ID
|
29
|
+
connection.accounts.find_by_id(ACCOUNT_ID)
|
30
|
+
else
|
31
|
+
connection.accounts.first
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.shared_context Cloudflare::Zone do
|
38
|
+
include_context Cloudflare::Account
|
39
|
+
|
40
|
+
let(:job_id) { JOB_ID }
|
41
|
+
let(:names) { NAMES.dup }
|
42
|
+
let(:name) { ZONE_NAME.dup }
|
43
|
+
|
16
44
|
let(:zones) {connection.zones}
|
17
|
-
|
45
|
+
|
18
46
|
let(:zone) {@zone = zones.find_by_name(name) || zones.create(name, account)}
|
19
|
-
|
47
|
+
|
20
48
|
# after do
|
21
49
|
# if defined? @zone
|
22
50
|
# @zone.delete
|
@@ -31,4 +59,27 @@ RSpec.configure do |config|
|
|
31
59
|
config.expect_with :rspec do |c|
|
32
60
|
c.syntax = :expect
|
33
61
|
end
|
62
|
+
|
63
|
+
disabled_specs = {}
|
64
|
+
|
65
|
+
# Check for features the current account has enabled
|
66
|
+
Cloudflare.connect(key: AUTH_KEY, email: AUTH_EMAIL) do |conn|
|
67
|
+
begin
|
68
|
+
account = if ACCOUNT_ID
|
69
|
+
conn.accounts.find_by_id(ACCOUNT_ID)
|
70
|
+
else
|
71
|
+
conn.accounts.first
|
72
|
+
end
|
73
|
+
account.kv_namespaces.to_a
|
74
|
+
rescue Cloudflare::RequestError => e
|
75
|
+
if e.message.include?('your account is not entitled')
|
76
|
+
puts 'Disabling KV specs due to no access'
|
77
|
+
disabled_specs[:kv_spec] = true
|
78
|
+
else
|
79
|
+
raise
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
config.filter_run_excluding disabled_specs unless disabled_specs.empty?
|
34
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudflare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Prokop
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: async-rest
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 0.10.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 0.10.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: async-rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,8 +113,12 @@ files:
|
|
113
113
|
- lib/cloudflare.rb
|
114
114
|
- lib/cloudflare/accounts.rb
|
115
115
|
- lib/cloudflare/connection.rb
|
116
|
+
- lib/cloudflare/custom_hostname/ssl_attribute.rb
|
117
|
+
- lib/cloudflare/custom_hostname/ssl_attribute/settings.rb
|
118
|
+
- lib/cloudflare/custom_hostnames.rb
|
116
119
|
- lib/cloudflare/dns.rb
|
117
120
|
- lib/cloudflare/firewall.rb
|
121
|
+
- lib/cloudflare/kv/namespaces.rb
|
118
122
|
- lib/cloudflare/logs.rb
|
119
123
|
- lib/cloudflare/paginate.rb
|
120
124
|
- lib/cloudflare/representation.rb
|
@@ -122,8 +126,13 @@ files:
|
|
122
126
|
- lib/cloudflare/user.rb
|
123
127
|
- lib/cloudflare/version.rb
|
124
128
|
- lib/cloudflare/zones.rb
|
129
|
+
- spec/cloudflare/accounts_spec.rb
|
130
|
+
- spec/cloudflare/custom_hostname/ssl_attribute/settings_spec.rb
|
131
|
+
- spec/cloudflare/custom_hostname/ssl_attribute_spec.rb
|
132
|
+
- spec/cloudflare/custom_hostnames_spec.rb
|
125
133
|
- spec/cloudflare/dns_spec.rb
|
126
134
|
- spec/cloudflare/firewall_spec.rb
|
135
|
+
- spec/cloudflare/kv/namespaces_spec.rb
|
127
136
|
- spec/cloudflare/zone_spec.rb
|
128
137
|
- spec/spec_helper.rb
|
129
138
|
homepage: https://github.com/b4k3r/cloudflare
|
@@ -145,12 +154,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
154
|
- !ruby/object:Gem::Version
|
146
155
|
version: '0'
|
147
156
|
requirements: []
|
148
|
-
rubygems_version: 3.0.
|
157
|
+
rubygems_version: 3.0.6
|
149
158
|
signing_key:
|
150
159
|
specification_version: 4
|
151
160
|
summary: A Ruby wrapper for the Cloudflare API.
|
152
161
|
test_files:
|
162
|
+
- spec/cloudflare/accounts_spec.rb
|
163
|
+
- spec/cloudflare/custom_hostname/ssl_attribute/settings_spec.rb
|
164
|
+
- spec/cloudflare/custom_hostname/ssl_attribute_spec.rb
|
165
|
+
- spec/cloudflare/custom_hostnames_spec.rb
|
153
166
|
- spec/cloudflare/dns_spec.rb
|
154
167
|
- spec/cloudflare/firewall_spec.rb
|
168
|
+
- spec/cloudflare/kv/namespaces_spec.rb
|
155
169
|
- spec/cloudflare/zone_spec.rb
|
156
170
|
- spec/spec_helper.rb
|