fastly 2.0.0 → 2.1.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: 157f02122af9a68df50590bc12a13d0d599fc6c1
4
- data.tar.gz: 2707b8264a8486d57b73680c35d886b8f257085e
3
+ metadata.gz: bdfb1410a5983996fdaab6611019b3c122f90c2a
4
+ data.tar.gz: 89083b0cda077826a976d285efa5af46b186183a
5
5
  SHA512:
6
- metadata.gz: c6f80a5791b94be1543fbf4ca796da8b072ad1a25a124bb1c2cdd3463061df8f6b4a9a576392be5157f5242b04e02a2429bd93ee48365e0f8cd954cae874ca56
7
- data.tar.gz: 7bc87a9ec25869021326398335cc1e3265027f2bc1abe49ca8ff2b9208710c529b94e67c5cb095e17819a217625148a7fd4b16378d9635d1d99707f2442988f8
6
+ metadata.gz: 34d4a4dc95364918761063fe691a517f32940f2eb0f8e42f5bb9511f46399aedab2366386a4cb64e69900a5bafed166150684e536d23022ad8dae20dabed51eb
7
+ data.tar.gz: 80401c0919ac37b87cb7c6cca8b2764bba6649a9d6fb05e91e565d8bb83d275996418c1a63c3fb9dcae0b2e90a1eab850a41a4a7793c3c7402e0051b1e17377b
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.1.0](https://github.com/fastly/fastly-ruby/tree/v2.0.0) (2018-06-18)
4
+ [Full Changelog](https://github.com/fastly/fastly-ruby/compare/v2.0.0...v2.1.0)
5
+
6
+ ** Merged pull requests:**
7
+
8
+ - Fix tests in continuous integration [\#134](https://github.com/fastly/fastly-ruby/pull/134) ([jamesarosen](https://github.com/jamesarosen))
9
+ - Add more user relationships to Fastly::Customer [\#133](https://github.com/fastly/fastly-ruby/pull/133) ([jamesarosen](https://github.com/jamesarosen))
10
+
3
11
  ## [v2.0.0](https://github.com/fastly/fastly-ruby/tree/v2.0.0) (2018-05-17)
4
12
  [Full Changelog](https://github.com/fastly/fastly-ruby/compare/v1.15.0...v2.0.0)
5
13
 
data/Gemfile CHANGED
@@ -8,5 +8,6 @@ group :development, :test do
8
8
  gem 'rdoc', '~> 4.1.1'
9
9
  gem 'minitest', '~> 5.3.4'
10
10
  gem 'pry'
11
+ gem 'rubocop', '~> 0.57.2', require: false
11
12
  gem 'webmock'
12
13
  end
data/Rakefile CHANGED
@@ -32,15 +32,17 @@ RDoc::Task.new do |rdoc|
32
32
  rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
33
33
  end
34
34
 
35
+ require 'rake/testtask'
36
+
35
37
  namespace :test do
36
38
  desc 'Run all unit tests'
37
- task :unit do
38
- sh 'bundle exec ruby -Itest -Ilib test/fastly/*_test.rb'
39
+ Rake::TestTask.new(:unit) do |t|
40
+ t.libs << 'test'
41
+ t.test_files = FileList['test/fastly/*_test.rb']
42
+ t.verbose = true
39
43
  end
40
44
  end
41
45
 
42
- require 'rake/testtask'
43
-
44
46
  Rake::TestTask.new do |t|
45
47
  t.libs << 'test'
46
48
  t.test_files = FileList['test/*test.rb']
@@ -1,13 +1,24 @@
1
1
  class Fastly
2
2
  # A Customer account
3
3
  class Customer < Base
4
- attr_accessor :id, :name, :owner_id
4
+ attr_accessor :billing_contact_id, :id, :legal_contact_id, :name,
5
+ :owner_id, :security_contact_id, :technical_contact_id
6
+
7
+ ##
8
+ # :attr: billing_contact_id
9
+ #
10
+ # The id of the user to be contacted for billing issues.
5
11
 
6
12
  ##
7
13
  # :attr: id
8
14
  #
9
15
  # The id of this customer
10
16
 
17
+ ##
18
+ # :attr: legal_contact_id
19
+ #
20
+ # The id of the user to be contacted for legal issues.
21
+
11
22
  ##
12
23
  # :attr: name
13
24
  #
@@ -18,9 +29,50 @@ class Fastly
18
29
  #
19
30
  # The id of the user that owns this customer
20
31
 
21
- # Return a user object representing the owner of this Customer
32
+ ##
33
+ # :attr: security_contact_id
34
+ #
35
+ # The id of the user to be contacted for security issues.
36
+
37
+ ##
38
+ # :attr: technical_contact_id
39
+ #
40
+ # The id of the user to be contacted for technical issues.
41
+
42
+ ##
43
+ # The billing contact as a Fastly::User
44
+ def billing_contact
45
+ get_user billing_contact_id
46
+ end
47
+
48
+ ##
49
+ # The legal contact as a Fastly::User
50
+ def legal_contact
51
+ get_user legal_contact_id
52
+ end
53
+
54
+ ##
55
+ # The account owner as a Fastly::User
22
56
  def owner
23
- fetcher.get(User, owner_id)
57
+ get_user owner_id
58
+ end
59
+
60
+ ##
61
+ # The security contact as a Fastly::User
62
+ def security_contact
63
+ get_user security_contact_id
64
+ end
65
+
66
+ ##
67
+ # The technical contact as a Fastly::User
68
+ def technical_contact
69
+ get_user technical_contact_id
70
+ end
71
+
72
+ private
73
+
74
+ def get_user(id)
75
+ id ? fetcher.get(User, id) : nil
24
76
  end
25
77
  end
26
78
  end
@@ -1,4 +1,4 @@
1
1
  # The current version of the library
2
2
  class Fastly
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
@@ -0,0 +1,48 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Fastly::Customer do
4
+
5
+ let(:fastly) { Fastly.new(api_key: 'secret') }
6
+ let(:customer_id) { SecureRandom.hex(6) }
7
+ let(:owner_id) { SecureRandom.hex(6) }
8
+
9
+ let(:customer) do
10
+ stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200, headers: { 'Set-Cookie' => 'tasty!' })
11
+
12
+ customer_body = JSON.dump(
13
+ 'id' => customer_id,
14
+ 'owner_id' => owner_id,
15
+ 'legal_contact_id' => owner_id,
16
+ )
17
+ stub_request(:get, "#{Fastly::Client::DEFAULT_URL}/customer/#{customer_id}").to_return(body: customer_body, status: 200)
18
+
19
+ owner_body = JSON.dump(
20
+ 'id' => owner_id,
21
+ 'name' => 'Sugar Watkins',
22
+ )
23
+ stub_request(:get, "#{Fastly::Client::DEFAULT_URL}/user/#{owner_id}").to_return(body: owner_body, status: 200)
24
+
25
+ fastly.get_customer(customer_id)
26
+ end
27
+
28
+ describe '#legal_contact' do
29
+ it 'returns the legal contact as a Fastly::User' do
30
+ assert customer.legal_contact.is_a?(Fastly::User)
31
+ assert_equal 'Sugar Watkins', customer.legal_contact.name
32
+ end
33
+ end
34
+
35
+ describe '#owner' do
36
+ it 'returns the owner as a Fastly::User' do
37
+ assert customer.owner.is_a?(Fastly::User)
38
+ assert_equal 'Sugar Watkins', customer.owner.name
39
+ end
40
+ end
41
+
42
+ describe '#technical_contact' do
43
+ it 'returns nil when the customer has no technical contact' do
44
+ assert_nil customer.technical_contact_id
45
+ assert_nil customer.technical_contact
46
+ end
47
+ end
48
+ end
@@ -38,7 +38,7 @@ describe Fastly::Syslog do
38
38
  'format' => '%h %l %u %t \'%r\' %>s %b',
39
39
  )
40
40
 
41
- get_item_url = "#{Fastly::Client::DEFAULT_URL}/service/#{service_id}/version/#{version}/syslog/#{syslog.name}"
41
+ get_item_url = "#{Fastly::Client::DEFAULT_URL}/service/#{service_id}/version/#{version}/logging/syslog/#{syslog.name}"
42
42
  get_service_url = "#{Fastly::Client::DEFAULT_URL}/service/#{service_id}/version/#{version}"
43
43
 
44
44
  stub_request(:get, get_service_url).to_return(status: 200, body: '{}', headers: {})
@@ -1,3 +1,4 @@
1
1
  require 'minitest/autorun'
2
+ require 'securerandom'
2
3
  require 'webmock/minitest'
3
4
  require 'fastly'
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: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fastly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2018-06-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Client library for the Fastly acceleration system
14
14
  email:
@@ -77,6 +77,7 @@ files:
77
77
  - test/fastly/acl_entry_test.rb
78
78
  - test/fastly/acl_test.rb
79
79
  - test/fastly/client_test.rb
80
+ - test/fastly/customer_test.rb
80
81
  - test/fastly/dictionary_test.rb
81
82
  - test/fastly/syslog_test.rb
82
83
  - test/fastly/util_test.rb
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  version: '0'
106
107
  requirements: []
107
108
  rubyforge_project:
108
- rubygems_version: 2.6.14
109
+ rubygems_version: 2.5.2
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: Client library for the Fastly acceleration system
@@ -116,6 +117,7 @@ test_files:
116
117
  - test/fastly/acl_entry_test.rb
117
118
  - test/fastly/acl_test.rb
118
119
  - test/fastly/client_test.rb
120
+ - test/fastly/customer_test.rb
119
121
  - test/fastly/dictionary_test.rb
120
122
  - test/fastly/syslog_test.rb
121
123
  - test/fastly/util_test.rb