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 14, 2023
1 parent 6833c3b commit 0d5d3e6
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 41 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
4 changes: 2 additions & 2 deletions src/tests/modules/exec/async.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 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')"
&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')"
&Tmp-String-0 := "%exec_async('/bin/sh -c \'sleep 1\'')"
if !(&Tmp-String-0 == "") {
test_fail
}
4 changes: 2 additions & 2 deletions src/tests/modules/icmp/ping.unlang
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
&control.Tmp-String-0 := "%(ping:127.0.0.1)"
&control.Tmp-String-0 := %ping(127.0.0.1)

#
# @todo - conditions do not yet support YIELD
#
if (&control.Tmp-String-0 == "yes") {
&control.Password.Cleartext := "hello"

&reply += {
&Reply-Message = "success"
}
Expand Down
16 changes: 8 additions & 8 deletions src/tests/modules/json/json_quote.unlang
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
&Tmp-String-0 := "Hello\n"
if (!(%(json_quote:%{Tmp-String-0}) == "\"Hello\\n\"")) {
if (!(%json_quote(%{Tmp-String-0}) == "\"Hello\\n\"")) {
test_fail
}

&Tmp-String-0 := "Hello\nbob"
if (!(%(json_quote:%{Tmp-String-0}) == "\"Hello\\nbob\"")) {
if (!(%json_quote(%{Tmp-String-0}) == "\"Hello\\nbob\"")) {
test_fail
}

&Tmp-String-0 := "\nHello\nbob"
if (!(%(json_quote:%{Tmp-String-0}) == "\"\\nHello\\nbob\"")) {
if (!(%json_quote(%{Tmp-String-0}) == "\"\\nHello\\nbob\"")) {
test_fail
}

&Tmp-String-0 := "Hello!"
if (!(%(json_quote:%{Tmp-String-0}) == '"Hello!"')) {
if (!(%json_quote(%{Tmp-String-0}) == '"Hello!"')) {
test_fail
}

&Tmp-Integer-0 := 123456
if (!(%(json_quote:%{Tmp-Integer-0}) == '123456')) {
if (!(%json_quote(%{Tmp-Integer-0}) == '123456')) {
test_fail
}

&Tmp-IP-Address-0 := 127.0.0.1
if (!(%(json_quote:%{Tmp-IP-Address-0}) == '"127.0.0.1"')) {
if (!(%json_quote(%{Tmp-IP-Address-0}) == '"127.0.0.1"')) {
test_fail
}

if (!(%(json_quote:%{Tmp-String-1}) == 'null')) {
if (!(%json_quote(%{Tmp-String-1}) == 'null')) {
test_fail
}

# Test calls in arguments as would be passed to REST module
if (!(%(test.passthrough:"{\"messages\":[{\"attributes\":{\"acct_status_type\":%(json_quote:%{Acct-Status-Type})}}]}") == '{"messages":[{"attributes":{"acct_status_type":null}}]}')) {
if (!(%test.passthrough("{\"messages\":[{\"attributes\":{\"acct_status_type\":%json_quote(%{Acct-Status-Type})}}]}") == '{"messages":[{"attributes":{"acct_status_type":null}}]}')) {
test_fail
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/modules/json/regression03.unlang
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Verify parsing works correctly with an unquoted xlat
map json %(test.passthrough:"{ \"foo\":\"bar\" }" {}) {
map json %test.passthrough("{ \"foo\":\"bar\" }",{}) {
&Tmp-String-0 := '$.foo'
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/modules/ldap/xlat_profile.unlang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (!%(ldap.profile:ldap:///cn=profile2,ou=profiles,dc=example,dc=com)) {
if (!%ldap.profile(ldap:///cn=profile2,ou=profiles,dc=example,dc=com)) {
test_fail
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/modules/test/trigger.unlang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ("%(test_trigger:test)" == false) {
if (%test_trigger(test) == false) {
test_fail
}

Expand Down

0 comments on commit 0d5d3e6

Please sign in to comment.