Skip to content

Commit 895e373

Browse files
committed
fix(spec): use a docker container with the original sim for testing
1 parent 1e94cef commit 895e373

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

.github/workflows/ci.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ jobs:
2222
# Label used to access the service container
2323
snmpd:
2424
# Docker Hub image
25-
image: polinux/snmpd
26-
options: >-
27-
-p 4000:161/udp
25+
image: tandrup/snmpsim
26+
# Not sure how to configure this correctly...
27+
# env:
28+
# EXTRA_FLAGS="--v3-user=usr-md5-none --v3-auth-key=authkey1 --v3-auth-proto=MD5"
2829

2930
steps:
3031
- uses: actions/checkout@v2

spec/client_spec.cr

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@ require "./helper"
22

33
describe SNMP::Client do
44
it "should perform a walk" do
5-
client = SNMP::Client.new(TEST_SNMP_SERVER, port: 4000)
5+
client = SNMP::Client.new(TEST_SNMP_SERVER)
66
client.should_not be_nil
77
messages = client.walk("1.3.6.1.2.1.1.9.1.3")
88
messages.should be_a(Array(SNMP::Message))
99
messages.empty?.should be_false
10-
messages.size.should eq 10
1110
end
1211

1312
it "should perform a walk using a block" do
14-
client = SNMP::Client.new(TEST_SNMP_SERVER, port: 4000)
13+
client = SNMP::Client.new(TEST_SNMP_SERVER)
1514
client.should_not be_nil
1615
messages = [] of SNMP::Message
1716
client.walk("1.3.6.1.2.1.1.9.1.3") do |message|
1817
messages << message
1918
end
2019
messages.empty?.should be_false
21-
messages.size.should eq 10
2220
end
2321
end

spec/snmp_spec.cr

+9-11
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ describe SNMP do
268268
end
269269

270270
it "should be able to query SNMPLabs with MD5 auth" do
271-
pending!("need a replacement for snmpsim https://github.com/inexio/snmpsim")
271+
pending!("not sure how to configure SNMPv3 on the simulator")
272272

273273
# Connect to server
274274
socket = UDPSocket.new
275-
socket.connect("demo.snmplabs.com", 161)
275+
socket.connect(TEST_SNMP_SERVER, 161)
276276
socket.sync = false
277277
socket.read_timeout = 3
278278

@@ -295,11 +295,11 @@ describe SNMP do
295295
end
296296

297297
it "should be able to query SNMPLabs with MD5 and AES auth" do
298-
pending!("need a replacement for snmpsim https://github.com/inexio/snmpsim")
298+
pending!("not sure how to configure SNMPv3 on the simulator")
299299

300300
# Connect to server
301301
socket = UDPSocket.new
302-
socket.connect("demo.snmplabs.com", 161)
302+
socket.connect(TEST_SNMP_SERVER, 161)
303303
socket.sync = false
304304
socket.read_timeout = 3
305305

@@ -322,11 +322,11 @@ describe SNMP do
322322
end
323323

324324
it "should be able to query SNMPLabs with MD5 and DES auth" do
325-
pending!("need a replacement for snmpsim https://github.com/inexio/snmpsim")
325+
pending!("not sure how to configure SNMPv3 on the simulator")
326326

327327
# Connect to server
328328
socket = UDPSocket.new
329-
socket.connect("demo.snmplabs.com", 161)
329+
socket.connect(TEST_SNMP_SERVER, 161)
330330
socket.sync = false
331331
socket.read_timeout = 3
332332

@@ -351,7 +351,7 @@ describe SNMP do
351351
it "should be able to query SNMPLabs with SNMPv2" do
352352
# Connect to server
353353
socket = UDPSocket.new
354-
socket.connect(TEST_SNMP_SERVER, 4000)
354+
socket.connect(TEST_SNMP_SERVER, 161)
355355
socket.sync = false
356356
socket.read_timeout = 3
357357

@@ -362,16 +362,14 @@ describe SNMP do
362362

363363
# Process response
364364
response = session.parse(socket.read_bytes(ASN1::BER))
365-
response.value.get_string.should start_with("Root <root@localhost>")
365+
response.value.get_string.should start_with("SNMP Laboratories")
366366
end
367367

368368
it "should be able to set an OID on SNMPLabs with SNMPv2" do
369-
pending!("need a replacement for snmpsim https://github.com/inexio/snmpsim")
370-
371369
# Connect to server
372370
socket = UDPSocket.new
373371
# socket.connect("localhost", 32771)
374-
socket.connect("demo.snmplabs.com", 161)
372+
socket.connect(TEST_SNMP_SERVER, 161)
375373
socket.sync = false
376374
socket.read_timeout = 3
377375

0 commit comments

Comments
 (0)