Skip to content

Commit

Permalink
replaced test snmpsim layer with an updated one which supports SHA256…
Browse files Browse the repository at this point in the history
…, and added the necessary test user
  • Loading branch information
c29m committed Jul 21, 2021
1 parent 7c4ffb9 commit 78fcd2b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 69 deletions.
12 changes: 7 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ services:
/home/spec/support/specs.sh

snmp-server-emulator:
image: honeyryderchuck/snmp-server-emulator:latest
image: tandrup/snmpsim:latest
ports:
- 1161:1161/udp
volumes:
- ./spec/support/snmpsim/:/home/snmp_server/.snmpsim
command:
- /usr/local/bin/snmpsimd.py
- --process-user=snmpsim
- --process-group=nogroup
- --v3-engine-id=000000000000000000000002
- --agent-udpv4-endpoint=0.0.0.0:1161
- --agent-udpv6-endpoint=[::0]:1161
Expand All @@ -31,11 +34,12 @@ services:
- --v3-user=authmd5
- --v3-auth-key=maplesyrup
- --v3-auth-proto=MD5
- --v3-priv-proto=NONE
- --v3-user=authsha
- --v3-auth-key=maplesyrup
- --v3-auth-proto=SHA
- --v3-priv-proto=NONE
- --v3-user=authsha256
- --v3-auth-key=maplesyrup
- --v3-auth-proto=SHA256
- --v3-user=authprivshaaes
- --v3-auth-key=maplesyrup
- --v3-auth-proto=SHA
Expand All @@ -57,5 +61,3 @@ services:
- --v3-priv-key=maplesyrup
- --v3-priv-proto=DES
- --v3-user=unsafe
- --v3-auth-proto=NONE
- --v3-priv-proto=NONE
70 changes: 35 additions & 35 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
let(:next_oid) { "1.3.6.1.2.1.1.6.0" }
let(:walk_oid) { "1.3.6.1.2.1.1" }
let(:set_oid) { "sysUpTime.0" } # sysUpTimeInstance
let(:get_result) { "DEVICE-192.168.1.1" }
let(:next_result) { "The Cloud" }
let(:get_result) { "zeus.snmplabs.com (you can change this!)" }
let(:next_result) { "San Francisco, California, United States" }
let(:walk_result) do
<<-WALK
1.3.6.1.2.1.1.1.0: Device description
1.3.6.1.2.1.1.2.0: 1.3.6.1.4.1.3454
1.3.6.1.2.1.1.3.0: Timeticks: (78171676) 9 days, 1:8:36.76
1.3.6.1.2.1.1.4.0: The Owner
1.3.6.1.2.1.1.5.0: DEVICE-192.168.1.1
1.3.6.1.2.1.1.6.0: The Cloud
1.3.6.1.2.1.1.7.0: 72
1.3.6.1.2.1.1.8.0: Timeticks: (0) 0 days, 0:0:0.0
WALK
{
"1.3.6.1.2.1.1.1.0" => "Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686",
"1.3.6.1.2.1.1.2.0" => "1.3.6.1.4.1.8072.3.2.10",
"1.3.6.1.2.1.1.3.0" => /Timeticks: \(\d+\) \d+ days, \d+:\d+:\d+\.\d+/,
"1.3.6.1.2.1.1.4.0" => "SNMP Laboratories, [email protected]",
"1.3.6.1.2.1.1.5.0" => "zeus.snmplabs.com (you can change this!)",
"1.3.6.1.2.1.1.6.0" => "San Francisco, California, United States",
"1.3.6.1.2.1.1.7.0" => "72",
"1.3.6.1.2.1.1.8.0" => /Timeticks: \(\d+\) \d+ days, \d+:\d+:\d+\.\d+/
}
end
let(:set_oid_result) { 43 }
end
Expand All @@ -52,19 +52,19 @@
let(:next_oid) { "1.3.6.1.2.1.1.6.0" }
let(:walk_oid) { "system" }
let(:set_oid) { "sysUpTime.0" }
let(:get_result) { "DEVICE-192.168.1.1" }
let(:next_result) { "The Cloud" }
let(:get_result) { "zeus.snmplabs.com (you can change this!)" }
let(:next_result) { "San Francisco, California, United States" }
let(:walk_result) do
<<-WALK
1.3.6.1.2.1.1.1.0: Device description
1.3.6.1.2.1.1.2.0: 1.3.6.1.4.1.3454
1.3.6.1.2.1.1.3.0: Timeticks: (78171676) 9 days, 1:8:36.76
1.3.6.1.2.1.1.4.0: The Owner
1.3.6.1.2.1.1.5.0: DEVICE-192.168.1.1
1.3.6.1.2.1.1.6.0: The Cloud
1.3.6.1.2.1.1.7.0: 72
1.3.6.1.2.1.1.8.0: Timeticks: (0) 0 days, 0:0:0.0
WALK
{
"1.3.6.1.2.1.1.1.0" => "Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686",
"1.3.6.1.2.1.1.2.0" => "1.3.6.1.4.1.8072.3.2.10",
"1.3.6.1.2.1.1.3.0" => /Timeticks: \(\d+\) \d+ days, \d+:\d+:\d+\.\d+/,
"1.3.6.1.2.1.1.4.0" => "SNMP Laboratories, [email protected]",
"1.3.6.1.2.1.1.5.0" => "zeus.snmplabs.com (you can change this!)",
"1.3.6.1.2.1.1.6.0" => "San Francisco, California, United States",
"1.3.6.1.2.1.1.7.0" => "72",
"1.3.6.1.2.1.1.8.0" => /Timeticks: \(\d+\) \d+ days, \d+:\d+:\d+\.\d+/
}
end
let(:set_oid_result) { 43 }

Expand Down Expand Up @@ -101,18 +101,18 @@
let(:set_oid) { "sysUpTime.0" } # sysUpTimeInstance
let(:walk_oid) { "1.3.6.1.2.1.1.9.1.3" }
let(:get_result) { "tt" }
let(:next_result) { "KK12" }
let(:next_result) { "KK12 (edit /etc/snmp/snmpd.conf)" }
let(:walk_result) do
<<-WALK
1.3.6.1.2.1.1.9.1.3.1: The SNMP Management Architecture MIB.
1.3.6.1.2.1.1.9.1.3.2: The MIB for Message Processing and Dispatching.
1.3.6.1.2.1.1.9.1.3.3: The management information definitions for the SNMP User-based Security Model.
1.3.6.1.2.1.1.9.1.3.4: The MIB module for SNMPv2 entities
1.3.6.1.2.1.1.9.1.3.5: The MIB module for managing TCP implementations
1.3.6.1.2.1.1.9.1.3.6: The MIB module for managing IP and ICMP implementations
1.3.6.1.2.1.1.9.1.3.7: The MIB module for managing UDP implementations
1.3.6.1.2.1.1.9.1.3.8: View-based Access Control Model for SNMP.
WALK
{
"1.3.6.1.2.1.1.9.1.3.1" => "The SNMP Management Architecture MIB.",
"1.3.6.1.2.1.1.9.1.3.2" => "The MIB for Message Processing and Dispatching.",
"1.3.6.1.2.1.1.9.1.3.3" => "The management information definitions for the SNMP User-based Security Model.",
"1.3.6.1.2.1.1.9.1.3.4" => "The MIB module for SNMPv2 entities",
"1.3.6.1.2.1.1.9.1.3.5" => "The MIB module for managing TCP implementations",
"1.3.6.1.2.1.1.9.1.3.6" => "The MIB module for managing IP and ICMP implementations",
"1.3.6.1.2.1.1.9.1.3.7" => "The MIB module for managing UDP implementations",
"1.3.6.1.2.1.1.9.1.3.8" => "View-based Access Control Model for SNMP."
}
end
let(:set_oid_result) { 43 }
context "with a no auth no priv policy" do
Expand Down
22 changes: 11 additions & 11 deletions spec/handlers/celluloid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
let(:set_oid) { "1.3.6.1.2.1.1.3.0" } # sysUpTimeInstance
let(:walk_oid) { "1.3.6.1.2.1.1.9.1.3" }
let(:get_result) { "tt" }
let(:next_result) { "KK12" }
let(:next_result) { "KK12 (edit /etc/snmp/snmpd.conf)" }
let(:walk_result) do
<<-WALK
1.3.6.1.2.1.1.9.1.3.1: The SNMP Management Architecture MIB.
1.3.6.1.2.1.1.9.1.3.2: The MIB for Message Processing and Dispatching.
1.3.6.1.2.1.1.9.1.3.3: The management information definitions for the SNMP User-based Security Model.
1.3.6.1.2.1.1.9.1.3.4: The MIB module for SNMPv2 entities
1.3.6.1.2.1.1.9.1.3.5: The MIB module for managing TCP implementations
1.3.6.1.2.1.1.9.1.3.6: The MIB module for managing IP and ICMP implementations
1.3.6.1.2.1.1.9.1.3.7: The MIB module for managing UDP implementations
1.3.6.1.2.1.1.9.1.3.8: View-based Access Control Model for SNMP.
WALK
{
"1.3.6.1.2.1.1.9.1.3.1" => "The SNMP Management Architecture MIB.",
"1.3.6.1.2.1.1.9.1.3.2" => "The MIB for Message Processing and Dispatching.",
"1.3.6.1.2.1.1.9.1.3.3" => "The management information definitions for the SNMP User-based Security Model.",
"1.3.6.1.2.1.1.9.1.3.4" => "The MIB module for SNMPv2 entities",
"1.3.6.1.2.1.1.9.1.3.5" => "The MIB module for managing TCP implementations",
"1.3.6.1.2.1.1.9.1.3.6" => "The MIB module for managing IP and ICMP implementations",
"1.3.6.1.2.1.1.9.1.3.7" => "The MIB module for managing UDP implementations",
"1.3.6.1.2.1.1.9.1.3.8" => "View-based Access Control Model for SNMP."
}
end

before(:all) { Celluloid.boot }
Expand Down
14 changes: 0 additions & 14 deletions spec/support/Dockerfile

This file was deleted.

17 changes: 13 additions & 4 deletions spec/support/request_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
let(:value) { subject.get({ oid: get_oid }, oid: next_oid) }
it "returns the values for both" do
expect(value).to be_a(Array)
expect(value).to include(/#{get_result}/)
expect(value).to include(/#{next_result}/)
expect(value).to include(get_result)
expect(value).to include(next_result)
end
end
end
Expand All @@ -40,8 +40,17 @@
describe "#walk" do
let(:value) { subject.walk(oid: walk_oid) }
it "fetches the varbinds for the next oid" do
values = value.map { |oid, val| "#{oid}: #{val}" }.join("\n") << "\n"
expect(values).to eq(walk_result)
value.each do |oid, val|
match = walk_result[oid]
case match
when String
expect(val.to_s).to eq(match)
when Regexp
expect(val.to_s).to match(match)
else
next
end
end
end
end
end

0 comments on commit 78fcd2b

Please sign in to comment.