summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-03-19 21:54:37 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-03-19 22:47:14 +0100
commit0c12e43d1ef5173630b882c2a49e30f3a6413bff (patch)
treec159f6befb3c7a4968a13a744525df44b422084a
parent7b301d401b69b23ab7ec8ce768980ebebb0cae5a (diff)
nat: Add a testcase for authentication to the nat
-rw-r--r--nat_auth/NATAuthTest.st87
-rw-r--r--nat_auth/README9
-rw-r--r--nat_auth/osmo-bsc_nat.cfg6
3 files changed, 102 insertions, 0 deletions
diff --git a/nat_auth/NATAuthTest.st b/nat_auth/NATAuthTest.st
new file mode 100644
index 0000000..34b1b5a
--- /dev/null
+++ b/nat_auth/NATAuthTest.st
@@ -0,0 +1,87 @@
+PackageLoader
+ fileInPackage: #OsmoNetwork;
+ fileInPackage: #SUnit.
+
+TestCase subclass: NATAuthTest [
+ | socket demuxer mux queue |
+ <comment: 'I test the authentication/by-passing of auth on the NAT.'>
+ <import: Osmo>
+
+ connect [
+ | msg |
+
+ socket ifNotNil: [socket close].
+ socket := Sockets.Socket remote: '127.0.0.1' port: 5000.
+ queue := SharedQueue new.
+ demuxer := IPADemuxer initOn: socket.
+ mux := IPAMuxer initOn: queue.
+
+ "ID ACK"
+ msg := demuxer next.
+ self assert: msg = (Array with: 254 with: $<6> asString).
+
+ "ID Req"
+ msg := demuxer next.
+ self assert: msg first = IPAConstants protocolIPA.
+ self assert: msg second first asInteger = IPAConstants msgIdGet.
+
+ "RSIP for MGCP.."
+ msg := demuxer next.
+ self assert: msg first = IPAConstants protocolMGCP.
+ ]
+
+ run [
+ self
+ testByPass;
+ testShort.
+ ]
+
+ verifyNotConnected [
+ [ | msg |
+ msg := demuxer next.
+ self assert: false.
+ ] on: SystemExceptions.EndOfStream do: [^true].
+ ]
+
+ testByPass [
+ | resp |
+ Transcript nextPutAll: 'Testing by-pass'; nl.
+ self connect.
+
+ "Now construct a response.."
+ resp := MessageBuffer new
+ putByte: IPAConstants msgIdResp;
+ putLen16: 0;
+ putByte: IPAConstants idtagUnitName;
+ yourself.
+ mux nextPut: resp asByteArray with: IPAConstants protocolIPA.
+ socket nextPutAllFlush: queue next.
+
+ self verifyNotConnected.
+ ]
+
+ testShort [
+ | resp |
+ Transcript nextPutAll: 'Testing short'; nl.
+
+ self connect.
+
+ "Now construct a short message..."
+ resp := MessageBuffer new
+ putByte: IPAConstants msgIdResp;
+ putLen16: 3;
+ putByte: IPAConstants idtagUnitName;
+ putByteArray: 'tes' asByteArray;
+ yourself.
+ mux nextPut: resp asByteArray with: IPAConstants protocolIPA.
+ socket nextPutAllFlush: queue next.
+
+ self verifyNotConnected.
+ ]
+]
+
+Eval [
+ | test |
+ test := NATAuthTest new
+ run.
+]
diff --git a/nat_auth/README b/nat_auth/README
new file mode 100644
index 0000000..89251a4
--- /dev/null
+++ b/nat_auth/README
@@ -0,0 +1,9 @@
+Some sanity checking with the auth..
+
+1.) Listen on port 5002
+$ nc -l 5002
+
+2.) Start the nat with local cfg file
+
+3.) Start the test.
+
diff --git a/nat_auth/osmo-bsc_nat.cfg b/nat_auth/osmo-bsc_nat.cfg
new file mode 100644
index 0000000..a159414
--- /dev/null
+++ b/nat_auth/osmo-bsc_nat.cfg
@@ -0,0 +1,6 @@
+nat
+ msc port 5002
+bsc 0
+ token test
+mgcp
+ call agent ip 127.0.0.1