dogapi 1.38.0 → 1.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.azure-pipelines/all.yml +7 -4
  3. data/.github/CODEOWNERS +10 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +77 -0
  7. data/.github/labeler.yml +5 -0
  8. data/.github/workflows/labeler.yml +11 -0
  9. data/.github/workflows/stale.yml +39 -0
  10. data/.rubocop_todo.yml +27 -32
  11. data/CHANGELOG.md +11 -0
  12. data/CONTRIBUTING.md +111 -0
  13. data/DEVELOPMENT.md +11 -0
  14. data/LICENSE +21 -20
  15. data/LICENSE-3rdparty.csv +6 -0
  16. data/README.rdoc +7 -0
  17. data/RELEASING.md +46 -0
  18. data/SUPPORT.md +9 -0
  19. data/examples/custom_metric.rb +1 -1
  20. data/lib/capistrano/README.md +4 -1
  21. data/lib/capistrano/datadog.rb +8 -4
  22. data/lib/capistrano/datadog/v2.rb +9 -1
  23. data/lib/capistrano/datadog/v3.rb +10 -1
  24. data/lib/dogapi.rb +4 -0
  25. data/lib/dogapi/common.rb +44 -9
  26. data/lib/dogapi/event.rb +4 -0
  27. data/lib/dogapi/facade.rb +56 -8
  28. data/lib/dogapi/metric.rb +4 -0
  29. data/lib/dogapi/v1.rb +5 -0
  30. data/lib/dogapi/v1/alert.rb +4 -0
  31. data/lib/dogapi/v1/aws_integration.rb +4 -0
  32. data/lib/dogapi/v1/aws_logs.rb +4 -0
  33. data/lib/dogapi/v1/azure_integration.rb +4 -0
  34. data/lib/dogapi/v1/comment.rb +4 -0
  35. data/lib/dogapi/v1/dash.rb +10 -4
  36. data/lib/dogapi/v1/dashboard.rb +4 -0
  37. data/lib/dogapi/v1/dashboard_list.rb +4 -0
  38. data/lib/dogapi/v1/embed.rb +4 -0
  39. data/lib/dogapi/v1/event.rb +4 -0
  40. data/lib/dogapi/v1/gcp_integration.rb +4 -0
  41. data/lib/dogapi/v1/hosts.rb +4 -0
  42. data/lib/dogapi/v1/integration.rb +4 -0
  43. data/lib/dogapi/v1/metadata.rb +4 -0
  44. data/lib/dogapi/v1/metric.rb +4 -0
  45. data/lib/dogapi/v1/monitor.rb +6 -2
  46. data/lib/dogapi/v1/screenboard.rb +4 -0
  47. data/lib/dogapi/v1/search.rb +4 -0
  48. data/lib/dogapi/v1/service_check.rb +4 -0
  49. data/lib/dogapi/v1/snapshot.rb +4 -0
  50. data/lib/dogapi/v1/synthetics.rb +80 -0
  51. data/lib/dogapi/v1/tag.rb +4 -0
  52. data/lib/dogapi/v1/usage.rb +4 -0
  53. data/lib/dogapi/v1/user.rb +4 -0
  54. data/lib/dogapi/v2.rb +4 -0
  55. data/lib/dogapi/v2/dashboard_list.rb +4 -0
  56. data/lib/dogapi/version.rb +5 -1
  57. data/spec/integration/alert_spec.rb +4 -0
  58. data/spec/integration/aws_integration_spec.rb +4 -0
  59. data/spec/integration/aws_logs_spec.rb +4 -0
  60. data/spec/integration/azure_integration_spec.rb +4 -0
  61. data/spec/integration/comment_spec.rb +5 -0
  62. data/spec/integration/common_spec.rb +4 -0
  63. data/spec/integration/dash_spec.rb +7 -1
  64. data/spec/integration/dashboard_list_spec.rb +4 -0
  65. data/spec/integration/dashboard_spec.rb +4 -0
  66. data/spec/integration/embed_spec.rb +4 -0
  67. data/spec/integration/event_spec.rb +5 -0
  68. data/spec/integration/gcp_integration_spec.rb +4 -0
  69. data/spec/integration/integration_spec.rb +4 -0
  70. data/spec/integration/metadata_spec.rb +4 -0
  71. data/spec/integration/metric_spec.rb +4 -0
  72. data/spec/integration/monitor_spec.rb +15 -0
  73. data/spec/integration/screenboard_spec.rb +4 -0
  74. data/spec/integration/search_spec.rb +4 -0
  75. data/spec/integration/service_check_spec.rb +4 -0
  76. data/spec/integration/snapshot_spec.rb +4 -0
  77. data/spec/integration/synthetics_spec.rb +131 -0
  78. data/spec/integration/tag_spec.rb +4 -0
  79. data/spec/integration/usage_spec.rb +4 -0
  80. data/spec/integration/user_spec.rb +4 -0
  81. data/spec/spec_helper.rb +4 -0
  82. data/spec/unit/capistrano_spec.rb +4 -0
  83. data/spec/unit/common_spec.rb +41 -0
  84. data/spec/unit/facade_spec.rb +4 -0
  85. metadata +18 -4
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'dogapi'
2
6
 
3
7
  module Dogapi
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'dogapi'
2
6
 
3
7
  module Dogapi
@@ -1 +1,5 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'dogapi/v2/dashboard_list'
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'dogapi'
2
6
 
3
7
  module Dogapi
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  module Dogapi
2
- VERSION = '1.38.0'
6
+ VERSION = '1.39.0'
3
7
  end
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,4 +1,9 @@
1
1
  # encoding: utf-8
2
+
3
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
4
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
5
+ # Copyright 2011-Present Datadog, Inc.
6
+
2
7
  require_relative '../spec_helper'
3
8
 
4
9
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::APIService do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -19,12 +23,14 @@ describe Dogapi::Client do
19
23
  'prefix' => 'host',
20
24
  'default' => 'host:my-host'
21
25
  }].freeze
26
+ READ_ONLY = false
22
27
 
23
28
  DASH_BODY = {
24
29
  title: TITLE,
25
30
  description: DESCRIPTION,
26
31
  graphs: GRAPHS,
27
- template_variables: TEMPLATE_VARIABLES
32
+ template_variables: TEMPLATE_VARIABLES,
33
+ read_only: READ_ONLY
28
34
  }.freeze
29
35
  DASH_ARGS = DASH_BODY.values
30
36
 
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,4 +1,9 @@
1
1
  # encoding: utf-8
2
+
3
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
4
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
5
+ # Copyright 2011-Present Datadog, Inc.
6
+
2
7
  require_relative '../spec_helper'
3
8
 
4
9
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -47,6 +51,17 @@ describe Dogapi::Client do
47
51
  :delete, "/monitor/#{MONITOR_ID}"
48
52
  end
49
53
 
54
+ describe '#delete_monitor with options' do
55
+ it 'queries the api with options' do
56
+ url = api_url + "/monitor/#{MONITOR_ID}?force=true"
57
+ options = { 'force' => true }
58
+ stub_request(:delete, url).to_return(body: '{}').then.to_raise(StandardError)
59
+ expect(dog.send(:delete_monitor, MONITOR_ID, options)).to eq ['200', {}]
60
+
61
+ expect(WebMock).to have_requested(:delete, url)
62
+ end
63
+ end
64
+
50
65
  describe '#get_all_monitors' do
51
66
  it_behaves_like 'an api method with optional params',
52
67
  :get_all_monitors, [],
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -0,0 +1,131 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ SYNTHETICS_TEST_PUBLIC_ID = '84r-szk-xpt'
5
+ SYNTHETICS_TESTS_PUBLIC_IDS = ['84r-szk-xpt', 'sti-s2m-ciz']
6
+ NEW_STATUS = 'paused'
7
+ SYNTHETICS_RESULT_ID = 123_456
8
+
9
+ SYNTHETICS_TEST_TYPE = 'api'.freeze
10
+ SYNTHETICS_TEST_CONFIG = {
11
+ 'assertions' => [
12
+ {
13
+ 'operator' => 'is',
14
+ 'type' => 'statusCode',
15
+ 'target' => 403
16
+ },
17
+ {
18
+ 'operator' => 'is',
19
+ 'property' => 'content-type',
20
+ 'type' => 'header',
21
+ 'target' => 'text/html'
22
+ },
23
+ {
24
+ 'operator' => 'lessThan',
25
+ 'type' => 'responseTime',
26
+ 'target' => 2000
27
+ }
28
+ ],
29
+ 'request' => {
30
+ 'method' => 'GET',
31
+ 'url' => 'https://datadoghq.com',
32
+ 'timeout' => 30,
33
+ 'headers' => {
34
+ 'header1' => 'value1',
35
+ 'header2' => 'value2'
36
+ },
37
+ 'body' => 'body to send with the request'
38
+ }
39
+ }.freeze
40
+
41
+ SYNTHETICS_TEST_OPTIONS = {
42
+ 'locations' => [
43
+ 'aws:us-east-2',
44
+ 'aws:eu-central-1',
45
+ 'aws:ca-central-1'
46
+ ],
47
+ 'options' => {
48
+ 'tick_every' => 60,
49
+ 'min_failure_duration' => 0,
50
+ 'min_location_failed' => 1,
51
+ 'follow_redirects' => true
52
+ },
53
+ 'message' => 'Test with API',
54
+ 'name' => 'Test with API',
55
+ 'tags' => ['key1:value1', 'key2:value2']
56
+ }.freeze
57
+
58
+ describe '#create_synthetics_test' do
59
+ it 'queries the api' do
60
+ url = api_url + '/synthetics/tests'
61
+ stub_request(:post, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
62
+ expect(dog.send(:create_synthetics_test, SYNTHETICS_TEST_TYPE, SYNTHETICS_TEST_CONFIG,
63
+ SYNTHETICS_TEST_OPTIONS)).to eq ['200', {}]
64
+
65
+ expect(WebMock).to have_requested(:post, url)
66
+ end
67
+ end
68
+
69
+ describe '#update_synthetics_test' do
70
+ it 'queries the api' do
71
+ url = api_url + "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}"
72
+ stub_request(:put, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
73
+ expect(dog.send(:update_synthetics_test, SYNTHETICS_TEST_PUBLIC_ID, SYNTHETICS_TEST_TYPE,
74
+ SYNTHETICS_TEST_CONFIG, SYNTHETICS_TEST_OPTIONS)).to eq ['200', {}]
75
+
76
+ expect(WebMock).to have_requested(:put, url)
77
+ end
78
+ end
79
+
80
+ describe '#delete_synthetics_tests' do
81
+ it_behaves_like 'an api method',
82
+ :delete_synthetics_tests, [SYNTHETICS_TESTS_PUBLIC_IDS],
83
+ :post, '/synthetics/tests/delete', 'public_ids' => SYNTHETICS_TESTS_PUBLIC_IDS
84
+ end
85
+
86
+ describe '#start_pause_synthetics_test' do
87
+ it_behaves_like 'an api method',
88
+ :start_pause_synthetics_test, [SYNTHETICS_TEST_PUBLIC_ID, NEW_STATUS],
89
+ :put, "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}/status", 'new_status' => NEW_STATUS
90
+ end
91
+
92
+ describe '#get_all_synthetics_tests' do
93
+ it_behaves_like 'an api method',
94
+ :get_all_synthetics_tests, [],
95
+ :get, '/synthetics/tests'
96
+ end
97
+
98
+ describe '#get_synthetics_test' do
99
+ it_behaves_like 'an api method',
100
+ :get_synthetics_test, [SYNTHETICS_TEST_PUBLIC_ID],
101
+ :get, "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}"
102
+ end
103
+
104
+ describe '#get_synthetics_results' do
105
+ it_behaves_like 'an api method',
106
+ :get_synthetics_results, [SYNTHETICS_TEST_PUBLIC_ID],
107
+ :get, "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}/results"
108
+ end
109
+
110
+ describe '#get_synthetics_result' do
111
+ it 'queries the api' do
112
+ url = api_url + "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}/results/#{SYNTHETICS_RESULT_ID}"
113
+ stub_request(:get, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
114
+ expect(dog.send(:get_synthetics_result, SYNTHETICS_TEST_PUBLIC_ID, SYNTHETICS_RESULT_ID)).to eq ['200', {}]
115
+
116
+ expect(WebMock).to have_requested(:get, url)
117
+ end
118
+ end
119
+
120
+ describe '#get_synthetics_devices' do
121
+ it_behaves_like 'an api method',
122
+ :get_synthetics_devices, [],
123
+ :get, '/synthetics/browser/devices'
124
+ end
125
+
126
+ describe '#get_synthetics_locations' do
127
+ it_behaves_like 'an api method',
128
+ :get_synthetics_locations, [],
129
+ :get, '/synthetics/locations'
130
+ end
131
+ end
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'rspec'
2
6
  require 'simplecov'
3
7
  require 'webmock/rspec'
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'spec_helper'
2
6
  require 'capistrano/datadog'
3
7
  require 'benchmark'
@@ -1,6 +1,27 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe 'Common' do
8
+ describe 'validate_tags' do
9
+ it 'raises if tags is not an array' do
10
+ tags = 'foo:bar'
11
+ expect { Dogapi.validate_tags(tags) }.to raise_error(ArgumentError)
12
+ tags = nil
13
+ expect { Dogapi.validate_tags(tags) }.to raise_error(ArgumentError)
14
+ end
15
+ it 'raises if elements of tags are not strings' do
16
+ tags = ['toto:tata', { foo: 'bar' }]
17
+ expect { Dogapi.validate_tags(tags) }.to raise_error(ArgumentError)
18
+ end
19
+ it 'passes if tags are correct' do
20
+ tags = ['foo:bar', 'baz']
21
+ Dogapi.validate_tags(tags)
22
+ end
23
+ end
24
+
4
25
  describe Dogapi.find_datadog_host do
5
26
  it 'gives precedence to DATADOG_HOST env var' do
6
27
  allow(ENV).to receive(:[]).with('DATADOG_HOST').and_return('example.com')
@@ -40,6 +61,26 @@ describe 'Common' do
40
61
  ENV['http_proxy'] = nil
41
62
  end
42
63
 
64
+ it 'uses-the dogapi specific proxy if set' do
65
+ service = Dogapi::APIService.new('api_key', 'app_key')
66
+
67
+ service.connect do |conn|
68
+ expect(conn.proxy_address).to be(nil)
69
+ expect(conn.proxy_port).to be(nil)
70
+ end
71
+
72
+ ENV['https_proxy'] = 'https://www.proxy.com:443'
73
+ ENV['dd_proxy_https'] = 'https://www.otherproxy.com:443'
74
+
75
+ service.connect do |conn|
76
+ expect(conn.proxy_address).to eq 'www.otherproxy.com'
77
+ expect(conn.proxy_port).to eq 443
78
+ end
79
+
80
+ ENV['https_proxy'] = nil
81
+ ENV['dd_proxy_https'] = nil
82
+ end
83
+
43
84
  it 'respects the endpoint configuration' do
44
85
  service = Dogapi::APIService.new('api_key', 'app_key', true, nil, 'https://app.example.com')
45
86