debug_control
-if (&REST-HTTP-Status-Code != 200) {
+if (!(&REST-HTTP-Status-Code == 200)) {
test_fail
}
-if (&control.Tmp-String-0 != "authorize") {
+if (!(&control.Tmp-String-0 == "authorize")) {
test_fail
}
-if (&control.Tmp-String-1 != "GET") {
+if (!(&control.Tmp-String-1 == "GET")) {
test_fail
}
-if (&control.Tmp-String-1[*] != "/user/<username>/mac/<client>") {
+if (!(&control.Tmp-String-1[*] == "/user/<username>/mac/<client>")) {
test_fail
}
-if (&control.User-Name != "Bob") {
+if (!(&control.User-Name == "Bob")) {
test_fail
}
# The "op" for setting Tmp-String-2 is ^=
-if ((&control.Tmp-String-2[0] != "Bob") || (&control.Tmp-String-2[1] != "foo")) {
+if (!(&control.Tmp-String-2[0] == "Bob") || !(&control.Tmp-String-2[1] == "foo")) {
test_fail
}
# Test "accounting" rest call. Uses https to a POST end point
rest.accounting
-if (&REST-HTTP-Status-Code != 200) {
+if (!(&REST-HTTP-Status-Code == 200)) {
test_fail
}
-if (&control.Tmp-String-0 != "accounting") {
+if (!(&control.Tmp-String-0 == "accounting")) {
test_fail
}
-if (&control.Tmp-String-1 != "POST") {
+if (!(&control.Tmp-String-1 == "POST")) {
test_fail
}
-if (&control.Tmp-String-1[*] != "/user/<username>/mac/<client>") {
+if (!(&control.Tmp-String-1[*] == "/user/<username>/mac/<client>")) {
test_fail
}
-if (&control.User-Name != "Bob") {
+if (!(&control.User-Name == "Bob")) {
test_fail
}
-if ((&control.Tmp-String-2[0] != "Bob") || (&control.Tmp-String-2[1] != "Bob") || (&control.Tmp-String-2[2] != "foo")) {
+if (!(&control.Tmp-String-2[0] == "Bob") || !(&control.Tmp-String-2[1] == "Bob") || !(&control.Tmp-String-2[2] == "foo")) {
test_fail
}
# NAS IP Address is passed in body data
-if ((&control.NAS-IP-Address[0] != "10.0.0.10") || (&control.NAS-IP-Address[1] != "192.168.1.1")) {
+if (!(&control.NAS-IP-Address[0] == "10.0.0.10") || !(&control.NAS-IP-Address[1] == "192.168.1.1")) {
test_fail
}
# Test "authenticate" rest call. Uses http basic authentication
rest.authenticate
-if (&REST-HTTP-Status-Code != 200) {
+if (!(&REST-HTTP-Status-Code == 200)) {
test_fail
}
-if (&REST-HTTP-Body != "Section: authenticate, User: Bob, Authenticated: true\n") {
+if (!(&REST-HTTP-Body == "Section: authenticate, User: Bob, Authenticated: true\n")) {
test_fail
}
# Retrieve a plain text file
&control.Tmp-String-1 := "%(rest:GET http://%{Tmp-String-0}:%{Tmp-Integer-0}/test.txt)"
-if (&REST-HTTP-Status-Code != 200) {
+if (!(&REST-HTTP-Status-Code == 200)) {
test_fail
}
-if (&control.Tmp-String-1 != "Sample text response\n") {
+if (!(&control.Tmp-String-1 == "Sample text response\n")) {
test_fail
}
# Take host from incomming packet
&control.Tmp-String-1 := "%(rest:http://%{Login-IP-Host}:%{Tmp-Integer-0}/test.txt)"
-if ((&REST-HTTP-Status-Code != 200) || (&control.Tmp-String-1 != "Sample text response\n")) {
+if (!(&REST-HTTP-Status-Code == 200) || !(&control.Tmp-String-1 == "Sample text response\n")) {
test_fail
}
# Port is not allowed from incomming packet
&control.Tmp-String-1 := "%(rest:http://%{Tmp-String-0}:%{NAS-Port}/test.txt)"
-if ((&Module-Failure-Message != "Failed escaping URI: Tainted value not allowed for port") || (&control.Tmp-String-1 != "")) {
+if (!(&Module-Failure-Message == "Failed escaping URI: Tainted value not allowed for port") || !(&control.Tmp-String-1 == "")) {
test_fail
}
# Check a "not found" gives a 404 status code
&control.Tmp-String-1 := "%(rest:GET http://%{Tmp-String-0}:%{Tmp-Integer-0}/%{Tmp-String-1})"
-if (&REST-HTTP-Status-Code != 404) {
+if (!(&REST-HTTP-Status-Code == 404)) {
test_fail
}
# GET with URL parameters
&Tmp-String-2 := "%(rest:GET http://%{Tmp-String-0}:%{Tmp-Integer-0}/user/%{User-Name}/mac/%{Called-Station-Id})"
-if (&REST-HTTP-Status-Code != 200) {
+if (!(&REST-HTTP-Status-Code == 200)) {
test_fail
}
&control.User-Name := '$.control\.User-Name.value'
}
-if (&control.Tmp-String-1 != "[ \"GET\", \"\\/user\\/<username>\\/mac\\/<client>\" ]") {
+if (!(&control.Tmp-String-1 == "[ \"GET\", \"\\/user\\/<username>\\/mac\\/<client>\" ]")) {
test_fail
}
-if (&control.User-Name != "Bob") {
+if (!(&control.User-Name == "Bob")) {
test_fail
}
&control.Tmp-String-3 ^= '$.control\.User-Name.value'
}
-if ((&control.Tmp-String-3[0] != 'Bob') || (&control.Tmp-String-3[1] != 'dummy')) {
+if (!(&control.Tmp-String-3[0] == 'Bob') || !(&control.Tmp-String-3[1] == 'dummy')) {
test_fail
}
# POST to https with JSON body data
&Tmp-String-2 := "%(rest:POST https://%{Tmp-String-0}:%{Tmp-Integer-1}/user/%{User-Name}/mac/%{Called-Station-Id}?section=accounting %{control.Tmp-String-2})"
-if (&REST-HTTP-Status-Code != 200) {
+if (!(&REST-HTTP-Status-Code == 200)) {
test_fail
}
&control.NAS-IP-Address := '$.control\.NAS-IP-Address.value'
}
-if (&control.Tmp-String-1 != "[ \"POST\", \"\\/user\\/<username>\\/mac\\/<client>\" ]") {
+if (!(&control.Tmp-String-1 == "[ \"POST\", \"\\/user\\/<username>\\/mac\\/<client>\" ]")) {
test_fail
}
-if (&control.User-Name != "Bob") {
+if (!(&control.User-Name == "Bob")) {
test_fail
}
-if (&control.NAS-IP-Address != "192.168.1.1") {
+if (!(&control.NAS-IP-Address == "192.168.1.1")) {
test_fail
}
# POST to https with POST body data
&Tmp-String-2 := "%(rest:POST https://%{Tmp-String-0}:%{Tmp-Integer-1}/post/test?section=dummy %{control.Tmp-String-2})"
-if (&REST-HTTP-Status-Code != 200) {
+if (!(&REST-HTTP-Status-Code == 200)) {
test_fail
}
-if (&Tmp-String-2 != "Section: dummy, User: Bob\n") {
+if (!(&Tmp-String-2 == "Section: dummy, User: Bob\n")) {
test_fail
}
# separator - make sure this doesn't end up generating extra arguments, but gets escaped.
&Tmp-String-2 := "%(rest:GET http://%{Tmp-String-0}:%{Tmp-Integer-0}/user/%{User-Name}/reflect/?station=%{Calling-Station-Id})"
-if (&Tmp-String-2 != "{\"station\":\"dummy&unsafe=escaped\"}\n" ) {
+if (!(&Tmp-String-2 == "{\"station\":\"dummy&unsafe=escaped\"}\n" )) {
test_fail
}
&Tmp-String-8 := ""
&Tmp-String-2 := "%(rest:http://%{Tmp-String-0}:%{Tmp-Integer-0}/user/%{User-Name}/reflect/%{Tmp-String-8}?station=%{User-Name})"
-if (&Tmp-String-2 != "{\"station\":\"Bob\"}\n" ) {
+if (!(&Tmp-String-2 == "{\"station\":\"Bob\"}\n" )) {
test_fail
}
# Zero length tainted value - check escaping doesn't break on zero length string
&Tmp-String-2 := "%(rest:http://%{Tmp-String-0}:%{Tmp-Integer-0}/user/%{User-Name}/reflect/%{Tmp-String-9}?station=%{Called-Station-Id})"
-if (&Tmp-String-2 != "{\"station\":\"aa:bb:cc:dd:ee:ff\"}\n" ) {
+if (!(&Tmp-String-2 == "{\"station\":\"aa:bb:cc:dd:ee:ff\"}\n" )) {
test_fail
}