gds_zendesk 2.3.0 → 3.2.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
- SHA1:
3
- metadata.gz: 9868cd71f7e7f7db163baebab52b2a1a78eb3c21
4
- data.tar.gz: bbb1d2436fccc42943c5d32ef8c5cdde477e5c19
2
+ SHA256:
3
+ metadata.gz: c2ce09664299a6802632a0dc10966d37c4adf67d53efbf2368240a4d96401139
4
+ data.tar.gz: fe832fb5483d5d9363614b984f2d89903742be31175b5839ab9bf515a7164b62
5
5
  SHA512:
6
- metadata.gz: 111f1600d6434633aaf532d60814bb59a9b735f0a0a81fb3f0e83168a10b5ca62013d16eef8ba9dcf8b9f57befba5362aeee40b5be15bef5234a179a8d79f4d7
7
- data.tar.gz: 9deb85d0d021845a89f7bad383fa77a0dcd68ad8b208e07e6679fe7d66e6a9fd4ab856ccf054f16935064eb4d376be9e5070eca813762c242548e8ceba616900
6
+ metadata.gz: 20a8002750b0376ba9ec27ed501cf91f84372259918cb3aff80571e375bb8a1a81121d303da41cbd6f2ad5f175006871cbda40e43b5d332ff50cf64239fee619
7
+ data.tar.gz: 3d68d792fa0e783e96761d04ca23c17d9b4b96ac71bb5d72e6f2a5a57177eef8fe3ed8466b572feca0dc2383b0163813a13146c331bee3269e77be19b322c49d
@@ -1 +1 @@
1
- 2.2
1
+ 2.6.6
@@ -1,3 +1,31 @@
1
+ # 3.2.0
2
+
3
+ * Allow use of a token instead of password
4
+
5
+ # 3.1.0
6
+
7
+ * Update `zendesk_api` library to v1.27
8
+
9
+ # 3.0.0
10
+
11
+ * Update the `webmock` library to version v2.3.2 to be compatible with Ruby
12
+ 2.4.2
13
+ * Update the `test_helpers` to be compatible with `webmock` v2.3.2
14
+
15
+ # 2.4.0
16
+
17
+ * Update the `zendesk_api` library to v1.14.4 to silence warnings from
18
+ Hashie about setting a key called `class`.
19
+
20
+ # 2.3.1
21
+
22
+ * Patch release as the previous upgrade didn't include the required
23
+ feature due to rapid successive merges.
24
+
25
+ # 2.3.0
26
+
27
+ * Add a test helper to stub Zendesk returning a 302
28
+
1
29
  # 2.2.0
2
30
 
3
31
  * Allow the zendesk URL to be specified in the configuration
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env groovy
2
+
3
+ library("govuk")
4
+
5
+ node {
6
+ govuk.buildProject()
7
+ }
data/README.md CHANGED
@@ -32,7 +32,7 @@ This generates an initializer at `config/initializers/gds_zendesk.rb`.
32
32
 
33
33
  #### Mandatory settings
34
34
 
35
- This gem needs to be configured with a Zendesk username and password before it can be used.
35
+ This gem needs to be configured with a Zendesk username and password (or token) before it can be used.
36
36
  These are set in `config/initializers/gds_zendesk.rb`
37
37
 
38
38
  #### Enabling development mode
data/Rakefile CHANGED
@@ -1,14 +1,7 @@
1
1
  require "rake"
2
2
  require "bundler/gem_tasks"
3
3
  require 'rspec/core/rake_task'
4
- require "gem_publisher"
5
4
 
6
5
  RSpec::Core::RakeTask.new(:spec)
7
6
 
8
7
  task :default => :spec
9
-
10
- desc "Publish the gem"
11
- task :publish_gem do |t|
12
- gem = GemPublisher.publish_if_updated("gds_zendesk.gemspec", :rubygems)
13
- puts "Published #{gem}" if gem
14
- end
@@ -6,8 +6,8 @@ require 'gds_zendesk/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "gds_zendesk"
8
8
  gem.version = GDSZendesk::VERSION
9
- gem.authors = ["Jake Benilov"]
10
- gem.email = ["benilov@gmail.com"]
9
+ gem.authors = ["GOV.UK Dev"]
10
+ gem.email = ["govuk-dev@digital.cabinet-office.gov.uk"]
11
11
  gem.description = %q{Client and models for communicating with Zendesk}
12
12
  gem.summary = %q{Client and models for communicating with Zendesk}
13
13
  gem.homepage = "https://github.com/alphagov/gds_zendesk"
@@ -17,11 +17,10 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency 'null_logger', '0.0.1'
21
- gem.add_dependency 'zendesk_api', '1.8.0'
20
+ gem.add_dependency 'null_logger', '~> 0'
21
+ gem.add_dependency 'zendesk_api', '~> 1.27'
22
22
 
23
- gem.add_development_dependency 'rake', '10.0.3'
24
- gem.add_development_dependency 'rspec', '3.1.0'
25
- gem.add_development_dependency 'gem_publisher', '1.2.0'
26
- gem.add_development_dependency "webmock", '1.18.0'
23
+ gem.add_development_dependency 'rake', '~> 10'
24
+ gem.add_development_dependency 'rspec', '~> 3'
25
+ gem.add_development_dependency 'webmock', '~> 2'
27
26
  end
@@ -26,7 +26,8 @@ module GDSZendesk
26
26
  ZendeskAPI::Client.new { |config|
27
27
  config.url = url
28
28
  config.username = username
29
- config.password = password
29
+ config.token = token if token
30
+ config.password = password if password
30
31
  config.logger = logger
31
32
  }
32
33
  end
@@ -38,13 +39,18 @@ module GDSZendesk
38
39
 
39
40
  def check_that_username_and_password_are_provided
40
41
  raise ArgumentError, "Zendesk username not provided" if username.nil?
41
- raise ArgumentError, "Zendesk password not provided" if password.nil?
42
+ raise ArgumentError, "Zendesk password or token not provided" if password.nil? && token.nil?
43
+ raise ArgumentError, "Provide only one of token or password" unless password.nil? || token.nil?
42
44
  end
43
45
 
44
46
  def username
45
47
  @config_options[:username] || @config_options["username"]
46
48
  end
47
49
 
50
+ def token
51
+ @config_options[:token] || @config_options["token"]
52
+ end
53
+
48
54
  def password
49
55
  @config_options[:password] || @config_options["password"]
50
56
  end
@@ -4,44 +4,54 @@ module GDSZendesk
4
4
  module TestHelpers
5
5
  def zendesk_has_no_user_with_email(email)
6
6
  stub_request(:get, "#{zendesk_endpoint}/users/search?query=#{email}").
7
+ with(basic_auth: basic_auth_credentials).
7
8
  to_return(body: {users: [], previous_page: nil, next_page: nil, count: 0}.to_json,
8
9
  headers: {'Content-Type' => 'application/json'})
9
10
  end
10
11
 
11
12
  def zendesk_has_user(user_details)
12
13
  stub_request(:get, "#{zendesk_endpoint}/users/search?query=#{user_details[:email]}").
14
+ with(basic_auth: basic_auth_credentials).
13
15
  to_return(body: {users: [user_details], previous_page: nil, next_page: nil, count: 1}.to_json,
14
16
  headers: {'Content-Type' => 'application/json'})
15
17
  end
16
18
 
17
19
  def stub_zendesk_user_creation(user_properties = nil)
18
- stub = stub_http_request(:post, "#{zendesk_endpoint}/users")
20
+ stub = stub_request(:post, "#{zendesk_endpoint}/users")
19
21
  stub.with(body: {user: user_properties}) unless user_properties.nil?
22
+ stub.with(basic_auth: basic_auth_credentials)
20
23
  stub.to_return(status: 201, body: { user: { id: 12345, name: "abc" }}.to_json,
21
24
  headers: {'Content-Type' => 'application/json'})
22
25
  end
23
26
 
24
27
  def stub_zendesk_ticket_creation(ticket_properties = nil)
25
- stub = stub_http_request(:post, "#{zendesk_endpoint}/tickets")
28
+ stub = stub_request(:post, "#{zendesk_endpoint}/tickets")
26
29
  stub.with(body: {ticket: ticket_properties}) unless ticket_properties.nil?
30
+ stub.with(basic_auth: basic_auth_credentials)
27
31
  stub.to_return(status: 201, body: { ticket: { id: 12345 }}.to_json,
28
32
  headers: {'Content-Type' => 'application/json'})
29
33
  end
30
34
 
31
35
  def stub_zendesk_ticket_creation_with_body(body)
32
- stub_http_request(:post, "#{zendesk_endpoint}/tickets").
36
+ stub_request(:post, "#{zendesk_endpoint}/tickets").
33
37
  with(body: body).
38
+ with(basic_auth: basic_auth_credentials).
34
39
  to_return(status: 201, body: { ticket: { id: 12345 }}.to_json,
35
40
  headers: {'Content-Type' => 'application/json'})
36
41
  end
37
42
 
38
43
  def stub_zendesk_user_update(user_id, user_properties)
39
- stub_http_request(:put, "#{zendesk_endpoint}/users/#{user_id}").
44
+ stub_request(:put, "#{zendesk_endpoint}/users/#{user_id}").
40
45
  with(body: {user: user_properties}).
46
+ with(basic_auth: basic_auth_credentials).
41
47
  to_return(status: 201, body: { user: { id: 12345, name: "abc" }}.to_json,
42
48
  headers: {'Content-Type' => 'application/json'})
43
49
  end
44
50
 
51
+ def basic_auth_credentials
52
+ [valid_zendesk_credentials['username'], valid_zendesk_credentials['password']]
53
+ end
54
+
45
55
  def zendesk_is_unavailable
46
56
  stub_request(:any, /#{zendesk_endpoint}\/.*/).to_return(status: 503)
47
57
  end
@@ -50,8 +60,12 @@ module GDSZendesk
50
60
  stub_request(:any, /#{zendesk_endpoint}\/.*/).to_return(status: 409)
51
61
  end
52
62
 
63
+ def zendesk_returns_redirect
64
+ stub_request(:any, /#{zendesk_endpoint}\/.*/).to_return(status: 302)
65
+ end
66
+
53
67
  def zendesk_endpoint
54
- "https://#{valid_zendesk_credentials["username"]}:#{valid_zendesk_credentials["password"]}@govuk.zendesk.com/api/v2"
68
+ "https://govuk.zendesk.com/api/v2"
55
69
  end
56
70
 
57
71
  def valid_zendesk_credentials=(credentials)
@@ -1,3 +1,3 @@
1
1
  module GDSZendesk
2
- VERSION = "2.3.0"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -8,7 +8,7 @@ GDS_ZENDESK_CLIENT = if Rails.env.development? || Rails.env.test?
8
8
  else
9
9
  config_yaml_file = File.join(Rails.root, 'config', 'zendesk.yml')
10
10
  config = YAML.load_file(config_yaml_file)[Rails.env]
11
- GDSZendesk::Client.new(username: config['username'], password: config['password'], logger: Rails.logger)
11
+ GDSZendesk::Client.new(username: config['username'], password: config['password'], token: config['token'], logger: Rails.logger)
12
12
  end
13
13
  END
14
14
 
@@ -20,9 +20,24 @@ module GDSZendesk
20
20
  /username not provided/)
21
21
  end
22
22
 
23
- it "should raise an error if no password is provided" do
23
+ it "should raise an error if no password or token is provided" do
24
24
  expect { Client.new(username: "abc") }.to raise_error(ArgumentError,
25
- /password not provided/)
25
+ /password or token not provided/)
26
+ end
27
+
28
+ it "should raise an error if token and password are provided" do
29
+ expect { Client.new(username: "abc", token: "def", password: "ghi") }.to raise_error(ArgumentError,
30
+ /Provide only one of token or password/)
31
+ end
32
+
33
+ it "should not raise an error if token is provided without password" do
34
+ expect { Client.new(username: "abc", token: "def") }.not_to raise_error(ArgumentError,
35
+ /password or token not provided/)
36
+ end
37
+
38
+ it "should not raise an error if password is provided without token" do
39
+ expect { Client.new(username: "abc", password: "def") }.not_to raise_error(ArgumentError,
40
+ /password or token not provided/)
26
41
  end
27
42
 
28
43
  it "should use a null logger if no logger has been provided" do
@@ -39,6 +54,14 @@ module GDSZendesk
39
54
  expect(client.config_options[:url]).to eq "https://govuk.zendesk.com/api/v2/"
40
55
  end
41
56
 
57
+ it "should use the token if provided" do
58
+ expect(Client.new(username: "test_user", token: "test_token").config_options[:token]).to eq "test_token"
59
+ end
60
+
61
+ it "should use the password if provided" do
62
+ expect(Client.new(username: "test_user", password: "test_password").config_options[:password]).to eq "test_password"
63
+ end
64
+
42
65
  it "should use the configured url if provided" do
43
66
  expect(Client.new(username: "test_user", password: "test_pass", url: "https://example.com").config_options[:url]).to eq "https://example.com"
44
67
  end
@@ -54,7 +77,7 @@ module GDSZendesk
54
77
 
55
78
  it "raises an exception if the ticket creation wasn't successful" do
56
79
  self.valid_zendesk_credentials = valid_credentials
57
- post_stub = stub_http_request(:post, "#{zendesk_endpoint}/tickets").to_return(status: 302)
80
+ post_stub = stub_request(:post, "#{zendesk_endpoint}/tickets").to_return(status: 302)
58
81
 
59
82
  expect { client.ticket.create!(some: "data") }.to raise_error
60
83
  expect(post_stub).to have_been_requested
metadata CHANGED
@@ -1,102 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds_zendesk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jake Benilov
7
+ - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: null_logger
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.1
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.1
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zendesk_api
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.0
33
+ version: '1.27'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.8.0
40
+ version: '1.27'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 10.0.3
47
+ version: '10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 10.0.3
54
+ version: '10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.1.0
61
+ version: '3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.1.0
69
- - !ruby/object:Gem::Dependency
70
- name: gem_publisher
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 1.2.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 1.2.0
68
+ version: '3'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: webmock
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - '='
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 1.18.0
75
+ version: '2'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - '='
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 1.18.0
82
+ version: '2'
97
83
  description: Client and models for communicating with Zendesk
98
84
  email:
99
- - benilov@gmail.com
85
+ - govuk-dev@digital.cabinet-office.gov.uk
100
86
  executables: []
101
87
  extensions: []
102
88
  extra_rdoc_files: []
@@ -105,12 +91,11 @@ files:
105
91
  - ".ruby-version"
106
92
  - CHANGELOG.md
107
93
  - Gemfile
94
+ - Jenkinsfile
108
95
  - LICENCE.txt
109
96
  - README.md
110
97
  - Rakefile
111
98
  - gds_zendesk.gemspec
112
- - jenkins.sh
113
- - jenkins_branches.sh
114
99
  - lib/gds_zendesk.rb
115
100
  - lib/gds_zendesk/client.rb
116
101
  - lib/gds_zendesk/dummy_client.rb
@@ -140,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
125
  - !ruby/object:Gem::Version
141
126
  version: '0'
142
127
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.4.5.1
128
+ rubygems_version: 3.1.2
145
129
  signing_key:
146
130
  specification_version: 4
147
131
  summary: Client and models for communicating with Zendesk
data/jenkins.sh DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
- set -e
3
- rm -f Gemfile.lock
4
- bundle install --path "${HOME}/bundles/${JOB_NAME}"
5
- bundle exec rake
6
- bundle exec rake publish_gem
@@ -1,20 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- VENV_PATH="${HOME}/venv/${JOB_NAME}"
5
-
6
- [ -x ${VENV_PATH}/bin/pip ] || virtualenv ${VENV_PATH}
7
- . ${VENV_PATH}/bin/activate
8
-
9
- pip install -q ghtools
10
-
11
- REPO="alphagov/gds_zendesk"
12
- gh-status "$REPO" "$GIT_COMMIT" pending -d "\"Build #${BUILD_NUMBER} is running on Jenkins\"" -u "$BUILD_URL" >/dev/null
13
-
14
- if ./jenkins.sh; then
15
- gh-status "$REPO" "$GIT_COMMIT" success -d "\"Build #${BUILD_NUMBER} succeeded on Jenkins\"" -u "$BUILD_URL" >/dev/null
16
- exit 0
17
- else
18
- gh-status "$REPO" "$GIT_COMMIT" failure -d "\"Build #${BUILD_NUMBER} failed on Jenkins\"" -u "$BUILD_URL" >/dev/null
19
- exit 1
20
- fi