capistrano2-zabbix 0.1.2 → 0.1.3

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: 40bb07fb11b83db26ea99ab1d6d585a926738fbb
4
- data.tar.gz: e52966615eda20f05695fbdd07f0b11e4dae40b0
3
+ metadata.gz: 5ff5eb345ec9879e64d547b161f3115e7fb05027
4
+ data.tar.gz: 88b40acbf5f0a59c1a441793a5e763f42772927b
5
5
  SHA512:
6
- metadata.gz: 4c56384f0342832ad59cd5985cde5a794c01abb5cab32da2fb88adec0edbcc7334f0b19b91939496b6f40af11f8d63887c4a7834ca239bd78c3f4d7ee91f8480
7
- data.tar.gz: 482f88799b86020281cd364c873f1ba4752d9e0c77fdb92023f86b9062a472b254fcb7babee9e4bf9def17dd57f98457d2302ba37e6c8f243d6eb90d92593160
6
+ metadata.gz: 54e357c547e20c32a323e34faf11b59fe9a463d3d4c4315472c1369c3f4ccd60bcafdd8431ab1bb7e153fff21742aa82b67861b288398e3819ecbbf5a43903b4
7
+ data.tar.gz: 31a9c2eb46ca7108ea87a91f25be877572174282d39fd48a40fd4f0eef884546725e4a01919cabc56c92c3e4fe69e281ea88544ee04aa300c596cb7fdf03ca36
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: capistrano2-zabbix 0.1.2 ruby lib
5
+ # stub: capistrano2-zabbix 0.1.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "capistrano2-zabbix"
9
- s.version = "0.1.2"
9
+ s.version = "0.1.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  "spec/cassettes/ZabbixMaintenance/_exists_/when_maintenance_exists_on_remote_server/.yml",
44
44
  "spec/cassettes/ZabbixMaintenance/_maint_id/when_maintenance_exsts/returns_correct_ID.yml",
45
45
  "spec/cassettes/ZabbixMaintenance/_new/authenticates_with_correct_credentials.yml",
46
+ "spec/cassettes/ZabbixMaintenance/_new/password_is_incorrect/raises_an_exception.yml",
46
47
  "spec/spec_helper.rb",
47
48
  "spec/zabbix_maintenance_spec.rb"
48
49
  ]
@@ -8,8 +8,12 @@ class ZabbixMaintenance
8
8
  def initialize(url, user, password, title: 'capistrano auto maintenance')
9
9
  begin
10
10
  @zbx = ZabbixApi.connect(url: url, user: user, password: password)
11
- rescue RuntimeError
12
- @zbx = nil
11
+ rescue RuntimeError => e
12
+ if e.message =~ /password is incorrect/
13
+ fail 'Login failed - incorrect password.'
14
+ else
15
+ fail "Error while connecting to Zabbix: #{e}"
16
+ end
13
17
  end
14
18
 
15
19
  @maint_title = title
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://192.168.56.2/zabbix/api_jsonrpc.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"method":"user.authenticate","params":{"user":"wronglogin","password":"wrongpw"},"auth":null,"id":47116,"jsonrpc":"2.0"}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/json-rpc
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Fri, 15 May 2015 15:55:36 GMT
25
+ Server:
26
+ - Apache/2.2.22 (Linux/SUSE)
27
+ X-Powered-By:
28
+ - PHP/5.3.17
29
+ Content-Length:
30
+ - '126'
31
+ Content-Type:
32
+ - application/json
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Login
36
+ name or password is incorrect."},"id":47116}'
37
+ http_version:
38
+ recorded_at: Thu, 14 May 2015 16:15:26 GMT
39
+ recorded_with: VCR 2.9.3
@@ -20,6 +20,15 @@ describe ZabbixMaintenance do
20
20
  expect(lzbx).to be_a ZabbixMaintenance
21
21
  expect(lzbx.authenticated?).to eq(true)
22
22
  end
23
+
24
+ context 'password is incorrect', :vcr do
25
+ it 'raises an exception' do
26
+ expect do ZabbixMaintenance.new('http://192.168.56.2/zabbix/api_jsonrpc.php',
27
+ 'wronglogin',
28
+ 'wrongpw')
29
+ end.to raise_error(/incorrect password/)
30
+ end
31
+ end
23
32
  end
24
33
 
25
34
  describe '.create' do
@@ -58,15 +67,6 @@ describe ZabbixMaintenance do
58
67
  subject { zbx.authenticated? }
59
68
  it { is_expected.to eq(true) }
60
69
  end
61
-
62
- context 'when not authenticated', :vcr do
63
- it 'returns false' do
64
- wrong_pw_zbx = ZabbixMaintenance.new('http://192.168.56.2/zabbix/api_jsonrpc.php',
65
- 'wronglogin',
66
- 'wrongpw')
67
- expect(wrong_pw_zbx.authenticated?).to eq(false)
68
- end
69
- end
70
70
  end
71
71
 
72
72
  describe '.maint_id' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano2-zabbix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Skrobacki
@@ -247,6 +247,7 @@ files:
247
247
  - spec/cassettes/ZabbixMaintenance/_exists_/when_maintenance_exists_on_remote_server/.yml
248
248
  - spec/cassettes/ZabbixMaintenance/_maint_id/when_maintenance_exsts/returns_correct_ID.yml
249
249
  - spec/cassettes/ZabbixMaintenance/_new/authenticates_with_correct_credentials.yml
250
+ - spec/cassettes/ZabbixMaintenance/_new/password_is_incorrect/raises_an_exception.yml
250
251
  - spec/spec_helper.rb
251
252
  - spec/zabbix_maintenance_spec.rb
252
253
  homepage: http://github.com/skrobul/capistrano2-zabbix