Skip to content

Commit

Permalink
schema compile UPDATE allow both deviate replace and add config
Browse files Browse the repository at this point in the history
... no matter if it has been explicitly set or not.
Refs #2114
  • Loading branch information
michalvasko committed Oct 17, 2023
1 parent a3ad5c6 commit 3f32006
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/schema_compile_amend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1376,13 +1376,6 @@ lys_apply_deviate_replace(struct lysc_ctx *ctx, struct lysp_deviate_rpl *d, stru
AMEND_WRONG_NODETYPE("deviation", "replace", "config");
}

if (!(target->flags & LYS_CONFIG_MASK)) {
LOGVAL(ctx->ctx, LY_VCODE_DEV_NOT_PRESENT, "replacing", "config",
d->flags & LYS_CONFIG_W ? "config true" : "config false");
ret = LY_EVALID;
goto cleanup;
}

target->flags &= ~LYS_CONFIG_MASK;
target->flags |= d->flags & LYS_CONFIG_MASK;
}
Expand Down
11 changes: 4 additions & 7 deletions tests/utests/schema/test_tree_schema_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3241,18 +3241,18 @@ test_deviation(void **state)
assert_true(node->flags & LYS_CONFIG_R);

assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module l {namespace urn:l;prefix l; leaf a {config false; type string;}"
"container top {config false; leaf x {type string;}}"
"container top {leaf x {type string;}}"
"deviation /a {deviate replace {config true;}}"
"deviation /top {deviate replace {config true;}}}", LYS_IN_YANG, &mod));
"deviation /top {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("a", node->name);
assert_true(node->flags & LYS_CONFIG_W);
assert_non_null(node = node->next);
assert_string_equal("top", node->name);
assert_true(node->flags & LYS_CONFIG_W);
assert_true(node->flags & LYS_CONFIG_R);
assert_non_null(node = lysc_node_child(node));
assert_string_equal("x", node->name);
assert_true(node->flags & LYS_CONFIG_W);
assert_true(node->flags & LYS_CONFIG_R);

assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module m {namespace urn:m;prefix m;"
"container a {leaf a {type string;}}"
Expand Down Expand Up @@ -3599,9 +3599,6 @@ test_deviation(void **state)
"deviation /top/x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/jj2:{deviation='/top/x'}\".");
CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "Path \"/jj2:{deviation='/top/x'}\".");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj3 {namespace urn:jj3;prefix jj3; container top {leaf x {type string;}}"
"deviation /top/x {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid deviation replacing \"config\" property \"config false\" which is not present.", "Path \"/jj3:{deviation='/top/x'}\".");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj4 {namespace urn:jj4;prefix jj4; choice ch {case a {leaf a{type string;}}}"
"deviation /ch/a {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid deviation of case node - it is not possible to replace \"config\" property.", "Path \"/jj4:{deviation='/ch/a'}\".");
Expand Down

0 comments on commit 3f32006

Please sign in to comment.