Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Nov 13, 2013
1 parent 8829aea commit ebd576e
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/tests/keywords/cast-byte
@@ -0,0 +1,25 @@
#
# PRE: update if
#
update {
control:Cleartext-Password := 'hello'
request:Class := 0xad
}

if (<byte>Class == 173) {
update reply {
Filter-Id := "filter"
}
}

if (<byte>Class < 173) {
update reply {
Filter-Id += "wrong"
}
}

if (<byte>Class > 173) {
update reply {
Filter-Id += "wrong"
}
}
25 changes: 25 additions & 0 deletions src/tests/keywords/cast-integer
@@ -0,0 +1,25 @@
#
# PRE: update if
#
update {
control:Cleartext-Password := 'hello'
request:Class := 0x00000101
}

if (<integer>Class == 257) {
update reply {
Filter-Id := "filter"
}
}

if (<integer>Class < 256) {
update reply {
Filter-Id += "wrong"
}
}

if (<integer>Class > 257) {
update reply {
Filter-Id += "wrong"
}
}
25 changes: 25 additions & 0 deletions src/tests/keywords/cast-short
@@ -0,0 +1,25 @@
#
# PRE: update if
#
update {
control:Cleartext-Password := 'hello'
request:Class := 0x0101
}

if (<short>Class == 257) {
update reply {
Filter-Id := "filter"
}
}

if (<short>Class < 256) {
update reply {
Filter-Id += "wrong"
}
}

if (<short>Class > 257) {
update reply {
Filter-Id += "wrong"
}
}
16 changes: 16 additions & 0 deletions src/tests/keywords/expr
@@ -0,0 +1,16 @@
#
# PRE: update if
#
update control {
Cleartext-Password := 'hello'
}

update request {
Session-Timeout := "%{expr: 1 + 2 + 3 + 4}"
}

if (Session-Timeout == 10) {
update reply {
Filter-Id := "filter"
}
}
2 changes: 2 additions & 0 deletions src/tests/keywords/if
@@ -1,4 +1,6 @@
#
# PRE: update
#
# Static if condition
#
if (1) {
Expand Down
18 changes: 18 additions & 0 deletions src/tests/keywords/ipaddr
@@ -0,0 +1,18 @@
#
# PRE: update if
#
update control {
Cleartext-Password := 'hello'
}

if (NAS-IP-Address == 127.0.0.1) {
update reply {
Filter-Id := "filter"
}
}

if (NAS-IP-Addr == 127.0.0.2) {
update reply {
Filter-Id += "wrong"
}
}
11 changes: 11 additions & 0 deletions src/tests/keywords/ipaddr.attrs
@@ -0,0 +1,11 @@
#
# Input packet
#
User-Name = "bob"
User-Password = "hello"
NAS-IP-Address = 127.0.0.1

#
# Expected answer
#
Filter-Id == 'filter'
17 changes: 17 additions & 0 deletions src/tests/keywords/md5
@@ -0,0 +1,17 @@
#
# PRE: update if
#
update {
control:Cleartext-Password := 'hello'
request:Called-Station-Id := "%{md5:This is a string\n}"
}

#
# Put "This is a string" into a file and call "md5sum" on it.
# You should get this string.
#
if (Called-Station-Id == "9ac4dbbc3c0ad2429e61d0df5dc28add") {
update reply {
Filter-Id := "filter"
}
}
2 changes: 2 additions & 0 deletions src/tests/keywords/radiusd.conf
Expand Up @@ -11,6 +11,8 @@ modules {
$INCLUDE ${raddb}/mods-enabled/always

$INCLUDE ${raddb}/mods-enabled/pap

$INCLUDE ${raddb}/mods-enabled/expr
}

server default {
Expand Down
17 changes: 17 additions & 0 deletions src/tests/keywords/sha1
@@ -0,0 +1,17 @@
#
# PRE: update if
#
update {
control:Cleartext-Password := 'hello'
request:Called-Station-Id := "%{sha1:This is a string\n}"
}

#
# Put "This is a string" into a file and call "sha1sum" on it.
# You should get this string.
#
if (Called-Station-Id == "cc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c") {
update reply {
Filter-Id := "filter"
}
}

0 comments on commit ebd576e

Please sign in to comment.