netsnmp 0.1.6 → 0.1.7

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
  SHA256:
3
- metadata.gz: f6e597be5bb67ffec6821029f1f7f8dc94532c4a9c1398bfef974922c3f0f6cf
4
- data.tar.gz: 3ddbf95ad3c480e8960e7501511c7ddd3c43b38386226783e8bb110811041a9c
3
+ metadata.gz: 9997bb4fe95f94302f02a8fe7e416806b366e90b68ef9367b17076cbdc8ed3f7
4
+ data.tar.gz: 74657115cb07003ba4a62187b0a7970866c6afaab882c667aa4c16f2ed84e931
5
5
  SHA512:
6
- metadata.gz: bff2dc9d8641545bebce2fafc68ded21f282ca5fe68eb07fbeb0aac66333a25c50f871468b6a442a90777c0eacccd3145426bc2c1c7c4cd23ff8f409e80f6135
7
- data.tar.gz: 6643a5b5c3275ad9db55cad071b42b7cd423b5896786718ad4cfc8ac224e3c1b56e8c8c36b803db7b60e906d3981502e92256d8b63ba692d60333f026147754b
6
+ metadata.gz: a6e3ea974eef0239bbd8aafdde6930f7696920057f768e968f69c88695513d12518104e2eebf5ab6cb417bdb302184518b7150214a318eab10e157ef39503805
7
+ data.tar.gz: a150cc09fd0d6d7dcf6a1117fab67ba7680cdf6c0df7c4f44bd4b4004bc27a3d89483977cf45df13495d6e5d801ff7dd2b624749717b9c7e820624e36097cab2
@@ -2,11 +2,6 @@ sudo: required
2
2
  services:
3
3
  - docker
4
4
 
5
- before_install:
6
- - sudo apt-add-repository multiverse
7
- - sudo apt-get update
8
- - sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-ce
9
-
10
5
  install:
11
6
  - gem i rubygems-update -v '<3' && update_rubygems
12
7
  - bundle install --path .bundle
@@ -24,10 +19,10 @@ rvm:
24
19
  - 2.6
25
20
  - ruby-head
26
21
  - jruby-head
27
- - rbx-2
22
+ - truffleruby
28
23
  matrix:
29
24
  allow_failures:
30
25
  - rvm: ruby-head
31
26
  - rvm: jruby-head
32
27
  # to figure out later
33
- - rvm: rbx-2
28
+ - rvm: truffleruby
@@ -81,11 +81,11 @@ module NETSNMP
81
81
  when :ipaddress then 0
82
82
  when :counter32
83
83
  asn_val = [value].pack("N*")
84
- asn_val = asn_val[1..-1] while asn_val.start_with?("\x00")
84
+ asn_val = asn_val[1..-1] while asn_val[0] == "\x00".b && asn_val[1].unpack("B").first != "1"
85
85
  1
86
86
  when :gauge
87
87
  asn_val = [value].pack("N*")
88
- asn_val = asn_val[1..-1] while asn_val.start_with?("\x00")
88
+ asn_val = asn_val[1..-1] while asn_val[0] == "\x00".b && asn_val[1].unpack("B").first != "1"
89
89
  2
90
90
  when :timetick
91
91
  return Timetick.new(value).to_asn
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NETSNMP
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
@@ -19,14 +19,76 @@ RSpec.describe NETSNMP::Varbind do
19
19
  asn = varbind.to_asn.value.last
20
20
  expect(varbind.convert_application_asn(asn)).to eq(timetick)
21
21
  end
22
+
22
23
  context "when passed a type" do
24
+ it "converts gauge32 without a leading byte" do
25
+ gauge = 127
26
+ varbind = described_class.new(".1.3.6.1.2.1.1.3.0", type: :gauge, value: gauge)
27
+ value_str = varbind.to_der[12..-1]
28
+ header = value_str[0].unpack("B8").first
29
+
30
+ # Class: Primitive Application
31
+ expect(header[0..1]).to eq("01")
32
+ expect(header[2]).to eq("0")
33
+ # Type: Integer
34
+ expect(header[3..-1].to_i(2)).to eq(2)
35
+ # Length & Value
36
+ expect(varbind.to_der).to end_with("\x01\x7F".b) # 2 Bytes
37
+
38
+ # Original Value
39
+ asn = varbind.to_asn.value.last
40
+ expect(varbind.convert_application_asn(asn)).to eq(gauge)
41
+ end
42
+ it "converts gauge32 with a leading byte" do
43
+ gauge = 128
44
+ varbind = described_class.new(".1.3.6.1.2.1.1.3.0", type: :gauge, value: gauge)
45
+ value_str = varbind.to_der[12..-1]
46
+ header = value_str[0].unpack("B8").first
47
+
48
+ # Class: Primitive Application
49
+ expect(header[0..1]).to eq("01")
50
+ expect(header[2]).to eq("0")
51
+ # Type: Integer
52
+ expect(header[3..-1].to_i(2)).to eq(2)
53
+ # Length & Value
54
+ expect(varbind.to_der).to end_with("\x02\x00\x80".b) # 4 Bytes, all FF
55
+
56
+ # Original Value
57
+ asn = varbind.to_asn.value.last
58
+ expect(varbind.convert_application_asn(asn)).to eq(gauge)
59
+ end
23
60
  it "converts gauge32" do
24
61
  gauge = 805
25
62
  varbind = described_class.new(".1.3.6.1.2.1.1.3.0", type: :gauge, value: gauge)
26
- expect(varbind.to_der).to end_with("B\x02\x03%".b)
63
+ value_str = varbind.to_der[12..-1]
64
+ header = value_str[0].unpack("B8").first
65
+
66
+ # Class: Primitive Application
67
+ expect(header[0..1]).to eq("01")
68
+ expect(header[2]).to eq("0")
69
+ # Type: Integer
70
+ expect(header[3..-1].to_i(2)).to eq(2)
71
+ # Length & Value
72
+ expect(varbind.to_der).to end_with("\x02\x03%".b)
73
+
74
+ # Original Value
27
75
  asn = varbind.to_asn.value.last
28
76
  expect(varbind.convert_application_asn(asn)).to eq(gauge)
29
77
  end
78
+ it "converts counter32 without a leading byte" do
79
+ counter = 127
80
+ varbind = described_class.new(".1.3.6.1.2.1.1.3.0", type: :counter32, value: counter)
81
+ expect(varbind.to_der).to end_with("\x01\x7F".b)
82
+ asn = varbind.to_asn.value.last
83
+ expect(varbind.convert_application_asn(asn)).to eq(counter)
84
+ end
85
+ it "converts counter32 with a leading byte" do
86
+ counter = 128
87
+ varbind = described_class.new(".1.3.6.1.2.1.1.3.0", type: :counter32, value: counter)
88
+ expect(varbind.to_der).to end_with("\x02\x00\x80".b)
89
+ asn = varbind.to_asn.value.last
90
+ expect(varbind.convert_application_asn(asn)).to eq(counter)
91
+ end
30
92
  it "converts counter32" do
31
93
  counter = 998932
32
94
  varbind = described_class.new(".1.3.6.1.2.1.1.3.0", type: :counter32, value: counter)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsnmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-03 00:00:00.000000000 Z
11
+ date: 2019-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -142,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements:
144
144
  - net-snmp
145
- rubyforge_project:
146
- rubygems_version: 2.7.8
145
+ rubygems_version: 3.0.1
147
146
  signing_key:
148
147
  specification_version: 4
149
148
  summary: SNMP Client library