Skip to content

Commit

Permalink
Start converting remaining unlang function calls to new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jejones3141 committed Dec 22, 2023
1 parent dfa4d56 commit 43ac320
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 114 deletions.
8 changes: 4 additions & 4 deletions src/tests/modules/cache_rbtree/cache-bin.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 11) {
if (%length(%{Tmp-String-1}) != 11) {
test_fail
}

Expand All @@ -59,7 +59,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 7) {
if (%length(%{Tmp-String-1}) != 7) {
test_fail
}

Expand Down Expand Up @@ -100,7 +100,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 11) {
if (%length(%{Tmp-String-1}) != 11) {
test_fail
}

Expand All @@ -118,7 +118,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 7) {
if (%length(%{Tmp-String-1}) != 7) {
test_fail
}

Expand Down
8 changes: 4 additions & 4 deletions src/tests/modules/cache_rbtree/cache-method-bin.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 11) {
if (%length(%{Tmp-String-1}) != 11) {
test_fail
}

Expand All @@ -59,7 +59,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 7) {
if (%length(%{Tmp-String-1}) != 7) {
test_fail
}

Expand Down Expand Up @@ -100,7 +100,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 11) {
if (%length(%{Tmp-String-1}) != 11) {
test_fail
}

Expand All @@ -118,7 +118,7 @@ if (!updated) {
test_fail
}

if ("%(length:%{Tmp-String-1})" != 7) {
if (%length(%{Tmp-String-1}) != 7) {
test_fail
}

Expand Down
9 changes: 4 additions & 5 deletions src/tests/modules/cache_rbtree/cache-xlat.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@ if (!ok) {
test_fail
}

&request.Tmp-String-2 := "%(cache:request.Tmp-String-1)"
&request.Tmp-String-2 := %cache(request.Tmp-String-1)

if (&Tmp-String-2 != &control.Tmp-String-1) {
test_fail
}

&Tmp-String-3 := "%(cache:request.Tmp-String-4)"

&Tmp-String-3 := "%cache(request.Tmp-String-4)"
if (&Tmp-String-3 != "") {
test_fail
}

# Regression test for deadlock on notfound
&Tmp-String-0 := 'testkey0'

&Tmp-String-3 := "%(cache:request.Tmp-String-4)"
&Tmp-String-3 := %cache(request.Tmp-String-4)

# Would previously deadlock
&Tmp-String-4 := "%(cache:request.Tmp-String-4)"
&Tmp-String-4 := %cache(request.Tmp-String-4)

test_pass
2 changes: 1 addition & 1 deletion src/tests/modules/chap/chap_password.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
&CHAP-Challenge := 0x0102030405060708090a0b0c0d0e0f10
&control.Password.Cleartext := "supersecret"

&CHAP-Password := "%(chap.password:%{control.Password.Cleartext})"
&CHAP-Password := "%chap.password(%{control.Password.Cleartext})"

chap.authenticate
if (ok) {
Expand Down
8 changes: 4 additions & 4 deletions src/tests/modules/cipher/fingerprint.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# We can't really check the values here as the certs change periodically
# but we can test the digest length, and for smoke...
#
&Tmp-Octets-0 := "%(cipher_rsa.certificate:fingerprint sha1)"
&Tmp-Octets-0 := %cipher_rsa.certificate('fingerprint','sha1')

if ("%(length:%{Tmp-Octets-0})" != 20) {
if (%length(%{Tmp-Octets-0}) != 20) {
test_fail
} else {
test_pass
}

&Tmp-Octets-0 := "%(cipher_rsa.certificate:fingerprint sha256)"
&Tmp-Octets-0 := %cipher_rsa.certificate('fingerprint','sha256')

if ("%(length:%{Tmp-Octets-0})" != 32) {
if (%length(%{Tmp-Octets-0}) != 32) {
test_fail
} else {
test_pass
Expand Down
2 changes: 1 addition & 1 deletion src/tests/modules/cipher/serial.unlang
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
&Tmp-Octets-0 := "%(cipher_rsa.certificate:serial)"

if ("%(length:%{Tmp-Octets-0})" != 1) {
if (%length(%{Tmp-Octets-0}) != 1) {
test_fail
} else {
test_pass
Expand Down
14 changes: 7 additions & 7 deletions src/tests/modules/client/xlat.unlang
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
&Tmp-String-0 := "%(client:nas_type)"
&Tmp-String-0 := "%client('nas_type')"

if (&Tmp-String-0 != 'a_type') {
test_fail
}

&Tmp-String-0 := "%(client:nas_type 127.0.0.1)"
&Tmp-String-0 := "%client('nas_type',127.0.0.1)"

if (&Tmp-String-0 != 'a_type') {
test_fail
}

&Tmp-String-0 := "%(client:nas_type 127.0.0.2)"
&Tmp-String-0 := "%client('nas_type',127.0.0.2)"

if (&Tmp-String-0 != 'b_type') {
test_fail
}

&Tmp-String-0 := "%(client:nas_type 127.0.0.5)"
&Tmp-String-0 := "%client('nas_type',127.0.0.5)"

if (&Tmp-String-0 != 'b_type') {
test_fail
Expand All @@ -25,8 +25,8 @@ if (&Tmp-String-0 != 'b_type') {
#
# Test non-existent client properties
#
&Tmp-String-3 := "%(client:non-existent-attr)"
&Tmp-String-4 := "%(client:non-existing-attr2)"
&Tmp-String-3 := "%client('non-existent-attr')"
&Tmp-String-4 := "%client('non-existing-attr2')"

if !(&Tmp-String-3 == "") {
test_fail
Expand All @@ -40,4 +40,4 @@ if !(&Tmp-String-4 == "") {
# Tests for multi-valued keys to be added when update takes multiple values
#

test_pass
test_pass
30 changes: 15 additions & 15 deletions src/tests/modules/eap_sim/sim_xlat_id_aka.unlang
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
if ("%(aka_sim_id_method:%{User-Name})" != 'AKA') {
if (%aka_sim_id_method("%{User-Name}") != 'AKA') {
test_fail
}

if ("%(aka_sim_id_type:%{User-Name})" != 'permanent') {
if (%aka_sim_id_type("%{User-Name}") != 'permanent') {
test_fail
}

#
# Encrypt the permanent ID
#
&control.Tmp-String-0 := '1420032219455258'
&control.User-Name := "%(3gpp_temporary_id_encrypt:%{User-Name} %{control.Tmp-String-0} 6)"
&control.User-Name := %3gpp_temporary_id_encrypt(%{User-Name},%{control.Tmp-String-0},6)

#
# 0.2 - Can we get the EAP method from the encrypted blob correctly?
#
if ("%(aka_sim_id_method:%{control.User-Name})" != 'AKA') {
if (%aka_sim_id_method("%{control.User-Name}") != 'AKA') {
test_fail
}

#
# 0.3 - Can we identify the encrypted blob correctly?
#
if ("%(aka_sim_id_type:%{control.User-Name})" != 'pseudonym') {
if (%aka_sim_id_type("%{control.User-Name}") != 'pseudonym') {
test_fail
}

#
# 0.4 - We should refuse to re-encrypt an encrypted NAI
#
if ("%(3gpp_temporary_id_encrypt:%{control.User-Name} %{control.Tmp-String-0} 6)" != '') {
if ("%3gpp_temporary_id_encrypt(%{control.User-Name},%{control.Tmp-String-0},6)" != '') {
test_fail
}

#
# 0.5 - Get the original IMSI back again
#
&control.Tmp-String-1 := "%(3gpp_temporary_id_decrypt:%{control.User-Name} %{control.Tmp-String-0})"
&control.Tmp-String-1 := %3gpp_temporary_id_decrypt(%{control.User-Name},%{control.Tmp-String-0})

if (&control.Tmp-String-1 != &User-Name) {
test_fail
Expand All @@ -57,27 +57,27 @@ if (&User-Name =~ /^[0-9](.*)/) {
#
&control.Tmp-String-0 := '1420032219455259'
&control += {
&User-Name = "%(3gpp_temporary_id_encrypt:%{User-Name[1]} %{control.Tmp-String-0} 6)"
&User-Name = %3gpp_temporary_id_encrypt(%{User-Name[1]},%{control.Tmp-String-0},6)
}

#
# 1.2 - Can we identify the encrypted blob correctly?
#
if ("%(aka_sim_id_type:%{control.User-Name[1]})" != 'pseudonym') {
if (%aka_sim_id_type("%{control.User-Name[1]}") != 'pseudonym') {
test_fail
}

#
# 1.3 - We should refuse to re-encrypt an encrypted NAI
#
if ("%(3gpp_temporary_id_encrypt:%{control.User-Name[1]} %{control.Tmp-String-0} 6)" != '') {
if ("%3gpp_temporary_id_encrypt(%{control.User-Name[1]},%{control.Tmp-String-0},6)" != '') {
test_fail
}

#
# 1.4 - Get the original IMSI back again
#
&control.Tmp-String-1 := "%(3gpp_temporary_id_decrypt:%{control.User-Name[1]} %{control.Tmp-String-0})"
&control.Tmp-String-1 := %3gpp_temporary_id_decrypt(%{control.User-Name[1]},%{control.Tmp-String-0})

if (&control.Tmp-String-1 != "0%{User-Name[1]}") {
test_fail
Expand All @@ -88,27 +88,27 @@ if (&control.Tmp-String-1 != "0%{User-Name[1]}") {
#
&control.Tmp-String-0 := '1420032219455259'
&control += {
&User-Name = "%(3gpp_temporary_id_encrypt:%{User-Name[1]} %{control.Tmp-String-0} 6 fastauth)"
&User-Name = %3gpp_temporary_id_encrypt(%{User-Name[1]},%{control.Tmp-String-0},6,fastauth)
}

#
# 2.2 - Can we identify the encrypted blob correctly?
#
if ("%(aka_sim_id_type:%{control.User-Name[2]})" != 'fastauth') {
if (%aka_sim_id_type("%{control.User-Name[2]}") != 'fastauth') {
test_fail
}

#
# 2.3 - We should refuse to re-encrypt an encrypted NAI
#
if ("%(3gpp_temporary_id_encrypt:%{control.User-Name[2]} %{control.Tmp-String-0} 6 fastauth)" != '') {
if ("%3gpp_temporary_id_encrypt(%{control.User-Name[2]},%{control.Tmp-String-0},6,fastauth)" != '') {
test_fail
}

#
# 2.4 - Get the original IMSI back again
#
&control.Tmp-String-1 := "%(3gpp_temporary_id_decrypt:%{control.User-Name[2]} %{control.Tmp-String-0})"
&control.Tmp-String-1 := %3gpp_temporary_id_decrypt(%{control.User-Name[2]},%{control.Tmp-String-0})

if (&control.Tmp-String-1 != "0%{User-Name[1]}") {
test_fail
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
if ("%(aka_sim_id_method:%{User-Name})" != 'AKA') {
if (%aka_sim_id_method(%{User-Name}) != 'AKA') {
test_fail
}

if ("%(aka_sim_id_type:%{User-Name})" != 'permanent') {
if (%aka_sim_id_type(%{User-Name}) != 'permanent') {
test_fail
}

#
# 1.1 - Encrypt the permanent ID
#
&control.Tmp-String-0 := '1420032219455259'
&control.User-Name := "%(3gpp_temporary_id_encrypt:%{User-Name} %{control.Tmp-String-0} 6)"
&control.User-Name := %3gpp_temporary_id_encrypt(%{User-Name},%{control.Tmp-String-0},6)

#
# 1.2 - Get the original IMSI back again sans tag
Expand Down
4 changes: 2 additions & 2 deletions src/tests/modules/eap_sim/sim_xlat_id_error.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
&User-Name := '14200322194552581'

if ("%(aka_sim_id_method:%{User-Name})" != '') {
if ("%aka_sim_id_method(%{User-Name})" != '') {
test_fail
}

Expand All @@ -12,7 +12,7 @@ if ("%(aka_sim_id_method:%{User-Name})" != '') {
#
&User-Name := ''

if ("%(aka_sim_id_method:%{User-Name})" != '') {
if ("%aka_sim_id_method(%{User-Name})" != '') {
test_fail
}

Expand Down
12 changes: 6 additions & 6 deletions src/tests/modules/eap_sim/sim_xlat_id_sim.unlang
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
if ("%(aka_sim_id_method:%{User-Name})" != 'SIM') {
if (%aka_sim_id_method(%{User-Name}) != 'SIM') {
test_fail
}

if ("%(aka_sim_id_type:%{User-Name})" != 'permanent') {
if (%aka_sim_id_type(%{User-Name}) != 'permanent') {
test_fail
}

#
# Encrypt the permanent ID
#
&control.Tmp-String-0 := '1234567812345678'
&control.User-Name := "%(3gpp_temporary_id_encrypt:%{User-Name} %{control.Tmp-String-0} 6)"
&control.User-Name := %3gpp_temporary_id_encrypt(%{User-Name},%{control.Tmp-String-0},6)

#
# Can we get the EAP method from the encrypted blob correctly?
#
if ("%(aka_sim_id_method:%{control.User-Name})" != 'SIM') {
if (%aka_sim_id_method(%{control.User-Name}) != 'SIM') {
test_fail
}

#
# Can we identify the encrypted blob correctly?
#
if ("%(aka_sim_id_type:%{control.User-Name})" != 'pseudonym') {
if (%aka_sim_id_type(%{control.User-Name}) != 'pseudonym') {
test_fail
}

#
# We should refuse to re-encrypt an encrypted NAI
#
if ("%(3gpp_temporary_id_encrypt:%{control.User-Name} %{control.Tmp-String-0} 6)" != '') {
if %3gpp_temporary_id_encrypt(%{control.User-Name},%{control.Tmp-String-0},6) {
test_fail
}

Expand Down
8 changes: 4 additions & 4 deletions src/tests/modules/exec/async.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Async calls should always return a zero length string
# because we don't wait for the response.
#
&Tmp-String-0 := "%(exec_async:/bin/sh -c 'echo -n hello')"
if !(&Tmp-String-0 == "") {
&Tmp-String-0 := %exec_async('/bin/sh','-c',"'echo -n hello'")
if &Tmp-String-0 {
test_fail
}

Expand All @@ -25,7 +25,7 @@ if (&reply.Reply-Message == 'hello') {
# Smoke test - Setup an async process that'll keep running after
# after the test exits.
#
&Tmp-String-0 := "%(exec_async:/bin/sh -c 'sleep 1')"
if !(&Tmp-String-0 == "") {
&Tmp-String-0 := %exec_async('/bin/sh','-c',"'sleep 1'")
if &Tmp-String-0 {
test_fail
}
Loading

0 comments on commit 43ac320

Please sign in to comment.