]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
run some edits under the new regime
authorAlan T. DeKok <aland@freeradius.org>
Wed, 16 Nov 2022 18:44:20 +0000 (13:44 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 17 Nov 2022 12:34:57 +0000 (07:34 -0500)
The behavior which isn't yet converted is:

* giving "update list { ... }" and then a *different* list for
  an attribute inside of the update section.
  The new code doesn't like this, for good reason.

* assigning &request += &control[*]
  the new code doesn't expect to see the [*], and therefore
  just ignores the assignment.

* creating empty attributes if the RHS of an evaluate fails.
  The new code does nothing.

* using array indexes in LHS of assignment for sub-list,
  update foo { bar[1] = baz}.
  The new code doesn't allow it.

* some compile-time errors are produced at different locations

src/tests/keywords/all.mk
src/tests/keywords/update-to-edit [new file with mode: 0644]

index f93fb9c9c0596c27a6991809164e2071ab83d369..d04b5f9634045c3cccb997df929a7af1ba13e445 100644 (file)
@@ -39,19 +39,26 @@ test.keywords.${1}: $(addprefix $(OUTPUT)/,${1})
 
 test.keywords.help: TEST_KEYWORDS_HELP += test.keywords.${1}
 
+#
+#  All of the "update" tests which should also be run with "-S rewrite_update=yes"
+#
+KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error update-filter update-list-error update-list-null-rhs update-null-value-assign update-remove-index update-exec
+
+KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-remove-list update-prepend unknown-update  update-error update-error-2 update-exec-error
+
 #
 #  Migration support.  Some of the tests don't run under the new
 #  conditions, so we don't run them under the new conditions.
 #
 ifneq "$(findstring ${1}, paircmp)" ""
 $(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=no -S use_new_conditions=no
-else
-ifneq "$(findstring ${1}, comments update-to-edit if-regex-multivalue smash wimax unknown unknown-update update-all update-array update-attr-ref-null update-delete update-error-2 update-error-3 update-remove-any update-exec update-exec-error update-filter update-group update-group-error update-hex update-remove-value update-remove-index update-index update-list-error update-list-null-rhs update-null-value-assign update-prepend update-remove-list vendor_specific vendor_specific.raw xlat-unknown)" ""
+else ifneq "$(findstring ${1}, comments update-to-edit if-regex-multivalue smash wimax unknown $(KEYWORD_UPDATE_TESTS) vendor_specific vendor_specific.raw xlat-unknown)" ""
 $(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=yes -S use_new_conditions=yes
+else ifneq "$(findstring ${1}, $(KEYWORD_UPDATE_REWRITE_TESTS))" ""
+$(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=yes -S use_new_conditions=yes -S rewrite_update=yes
 else
 $(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=yes -S use_new_conditions=yes -S forbid_update=yes
 endif
-endif
 
 endef
 $(foreach x,$(FILES),$(eval $(call KEYWORD_TEST,$x)))
diff --git a/src/tests/keywords/update-to-edit b/src/tests/keywords/update-to-edit
new file mode 100644 (file)
index 0000000..851f431
--- /dev/null
@@ -0,0 +1,52 @@
+&Tmp-String-0 := "foo"
+
+update request {
+       &Tmp-String-0 !* ANY
+}
+
+if (&Tmp-String-0) {
+       test_fail
+}
+
+&Tmp-String-0 := "foo"
+&reply.Tmp-String-0 := "bar"
+
+update {
+       &request.Tmp-String-0 !* ANY
+       &reply !* ANY
+}
+
+if (&Tmp-String-0) {
+       test_fail
+}
+
+if (&reply.Tmp-String-0) {
+       test_fail
+}
+
+update reply {
+       &Tmp-Integer-0 := 12
+}
+
+if (!&reply.Tmp-Integer-0) {
+       test_fail
+}
+
+update reply {
+       &Tmp-Integer-0 += 13
+}
+
+if (&reply.Tmp-Integer-0[0] != 12) {
+       test_fail
+}
+
+if (&reply.Tmp-Integer-0[1] != 13) {
+       test_fail
+}
+
+#
+#  Clear out reply as we don't care about the attributes in it.
+#
+&reply := {}
+
+success