Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-11-19 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2541164253


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   The logs for this run have expired and are no longer available.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-11-16 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2532920440


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   The author may be unable to continue processing this PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-11-15 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2529809549


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Is there any update here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-11-15 Thread via GitHub


github-actions[bot] commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-3536277679

   This pull request has been marked as stale due to 60 days of inactivity. It 
will be closed in 4 weeks if no further activity occurs. If you think that's 
incorrect or this pull request should instead be reviewed, please simply write 
any comment. Even if closed, you can still revive the PR at any time or discuss 
it on the [email protected] list. Thank you for your contributions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-09-20 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2348355012


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Is there any update here??



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-09-17 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2348919572


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   should I do something more??



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-09-15 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2350490192


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Hi @wistefan, is there still time to deal with these?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-09-15 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2350489032


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Please submit additional fixes to ensure all CI tests pass.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-09-15 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2348470162


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   The failed CI needs to be fixed. Once it's finished, I'll ask other 
maintainers to review it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-12 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2269649261


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   💯 
   
   ```
   TEST_NGINX_BINARY=/usr/bin/openresty prove -I. -It -Itest-nginx/lib -r 
t/plugin/opa4.t
   t/plugin/opa4.t .. ok
   All tests successful.
   Files=1, Tests=12,  2 wallclock secs ( 0.02 usr  0.00 sys +  0.44 cusr  0.21 
csys =  0.67 CPU)
   Result: PASS
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-12 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2269019646


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Thank you so much! Now seems that is working properly, I have to deploy all 
the set up and test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-11 Thread via GitHub


SkyeYoung commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2268757199


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   https://github.com/luarocks/luarocks/wiki/Download



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-11 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2268745671


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Version : 3.8.0
   
   ```
   luarocks --version
   /usr/local/bin/luarocks 3.8.0
   ```
   
   ```
   apt list -a luarocks
   Listing... Done
   luarocks/jammy,now 3.8.0+dfsg1-1 all [installed]
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-11 Thread via GitHub


SkyeYoung commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2268384273


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   > I made `make deps` but I received this issue:
   > 
   > ```
   > apisix master-0 depends on lua-resty-ctxdump 0.1-0 (not installed)
   > Warning: Failed searching manifest: Failed loading manifest for 
https://luarocks.org: Error loading file: [string 
"/var/cache/luarocks/https___luarocks.org/mani..."]:209682: main function has 
more than 65536 constants
   > Warning: Failed searching manifest: Failed loading manifest for 
https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/:
 Error loading file: [string 
"/var/cache/luarocks/https___raw.githubusercon..."]:209616: main function has 
more than 65536 constants
   > Warning: Failed searching manifest: Failed downloading 
https://luafr.org/luarocks/manifest-5.1 - failed downloading 
https://luafr.org/luarocks/manifest-5.1
   > ^CWarning: Failed searching manifest: Failed downloading 
http://luarocks.logiceditor.com/rocks/manifest-5.1 - failed downloading 
http://luarocks.logiceditor.com/rocks/manifest-5.1
   > 
   > Error: Could not satisfy dependency lua-resty-ctxdump 0.1-0: No results 
matching query were found for Lua 5.1.
   > ```
   
   What's your luarocks version? Try updating it. This looks like an issue that 
has already been fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-11 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2266381106


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   ```
   TEST_NGINX_BINARY=/usr/bin/openresty prove -Itest-nginx/lib -r 
t/plugin/opa4.t
   t/plugin/opa4.t .. nginx: [error] init_by_lua error: 
/home/ubuntu/apisix/apisix/patch.lua:20: module 'socket' not found:
   no field package.preload['socket']
   no file '/home/ubuntu/apisix/socket.lua'
   no file '/home/ubuntu/apisix/socket/init.lua'
   no file '/home/ubuntu/apisix/deps/share/lua/5.1/socket/init.lua'
   no file '/home/ubuntu/apisix/deps/share/lua/5.1/socket.lua'
   no file '/home/ubuntu/apisix/apisix/socket.lua'
   no file '/home/ubuntu/apisix/t/socket.lua'
   no file '/home/ubuntu/apisix/t/xrpc/socket.lua'
   no file '/home/ubuntu/apisix/t/xrpc/socket/init.lua'
   no file '/usr/local/openresty/site/lualib/socket.ljbc'
   no file '/usr/local/openresty/site/lualib/socket/init.ljbc'
   no file '/usr/local/openresty/lualib/socket.ljbc'
   no file '/usr/local/openresty/lualib/socket/init.ljbc'
   no file '/usr/local/openresty/site/lualib/socket.lua'
   no file '/usr/local/openresty/site/lualib/socket/init.lua'
   no file '/usr/local/openresty/lualib/socket.lua'
   no file '/usr/local/openresty/lualib/socket/init.lua'
   no file './socket.lua'
   no file '/usr/local/openresty/luajit/share/luajit-2.1/socket.lua'
   no file '/usr/local/share/lua/5.1/socket.lua'
   no file '/usr/local/share/lua/5.1/socket/init.lua'
   no file '/usr/local/openresty/luajit/share/lua/5.1/socket.lua'
   no file '/usr/local/openresty/luajit/share/lua/5.1/socket/init.lua'
   no file '/home/ubuntu/apisix/socket.so'
   no file '/home/ubuntu/apisix/deps/lib/lua/5.1/socket.so'
   no file '/home/ubuntu/apisix/deps/lib64/lua/5.1/socket.so'
   no file '/usr/local/openresty/site/lualib/socket.so'
   no file '/usr/local/openresty/lualib/socket.so'
   no file './socket.so'
   no file '/usr/local/lib/lua/5.1/socket.so'
   no file '/usr/local/openresty/luajit/lib/lua/5.1/socket.so'
   no file '/usr/local/lib/lua/5.1/loadall.so'
   stack traceback:
   [C]: in function 'requir

Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-11 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2266313103


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   I made `make deps` but I received this issue: 
   
   ```
   apisix master-0 depends on lua-resty-ctxdump 0.1-0 (not installed)
   Warning: Failed searching manifest: Failed loading manifest for 
https://luarocks.org: Error loading file: [string 
"/var/cache/luarocks/https___luarocks.org/mani..."]:209682: main function has 
more than 65536 constants
   Warning: Failed searching manifest: Failed loading manifest for 
https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/:
 Error loading file: [string 
"/var/cache/luarocks/https___raw.githubusercon..."]:209616: main function has 
more than 65536 constants
   Warning: Failed searching manifest: Failed downloading 
https://luafr.org/luarocks/manifest-5.1 - failed downloading 
https://luafr.org/luarocks/manifest-5.1
   ^CWarning: Failed searching manifest: Failed downloading 
http://luarocks.logiceditor.com/rocks/manifest-5.1 - failed downloading 
http://luarocks.logiceditor.com/rocks/manifest-5.1
   
   Error: Could not satisfy dependency lua-resty-ctxdump 0.1-0: No results 
matching query were found for Lua 5.1.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-10 Thread via GitHub


SkyeYoung commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2265822591


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   > First of all, thank you very much for your help! What I'm having trouble 
with is installing openresty to run the tests.
   
   I'm used to checking these below
   
   * https://github.com/apache/apisix/blob/master/.github/workflows/build.yml
   * https://apisix.apache.org/docs/apisix/building-apisix/#troubleshooting
   * https://metacpan.org/pod/Test::Nginx::Socket



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-07 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2262087550


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   First of all, thank you very much for your help! What I'm having trouble 
with is installing openresty to run the tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-03 Thread via GitHub


SkyeYoung commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2250366960


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   @LuciaCabanillasRodriguez Hi, if you need help @ me.
   
   I used to read this document: https://metacpan.org/pod/Test::Nginx::Socket
   
   Others I prefer to refer to existing examples



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-03 Thread via GitHub


SkyeYoung commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2250366960


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   @LuciaCabanillasRodriguez Hi, if you need help @ me.
   
   I used to read this document: https://metacpan.org/pod/Test::Nginx::Socket
   
   Others I prefer to refer to existing test cases.



##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+  

Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-08-01 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2247268428


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   I will be working on it during August



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-07-28 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2235073452


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Hi @LuciaCabanillasRodriguez, any updates?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-07-03 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2184171959


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   1. For the development environment construction, you can refer to 
https://github.com/apache/apisix/blob/master/docs/en/latest/build-apisix-dev-environment-devcontainers.md
   2. For the testing framework, you can refer to 
https://apisix.apache.org/docs/apisix/internal/testing-framework/
   
   If you have any other questions, please feel free to ask.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-07-03 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2182986408


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Yes @Baoyuantop, I've been running into several issues while creating the 
tests — mostly related to Test-NGINX not working properly, or maybe I'm missing 
something in the setup. I'm getting some errors, but I'm not sure what I'm 
doing wrong. Do you happen to have a guide or any reference I could follow?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-07-02 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2181357935


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Hi @LuciaCabanillasRodriguez, do you need any help with this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-30 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2174851544


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Hi @wistefan, could you please take a look? I’m running into some issues 
with Nginx and would appreciate your help. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-30 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2174418734


##
docs/en/latest/plugins/opa.md:
##
@@ -46,6 +46,7 @@ The `opa` Plugin can be used to integrate with [Open Policy 
Agent (OPA)](https:/
 | with_route| boolean | False| false   |   | When set 
to true, sends information about the current Route. 

  |

Review Comment:
   Updated!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-25 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2167928413


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   You need to add more tests to verify this scenario.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-25 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2166643655


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   Should I do something?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-25 Thread via GitHub


LuciaCabanillasRodriguez commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2166641366


##
docs/en/latest/plugins/opa.md:
##
@@ -46,6 +46,7 @@ The `opa` Plugin can be used to integrate with [Open Policy 
Agent (OPA)](https:/
 | with_route| boolean | False| false   |   | When set 
to true, sends information about the current Route. 

  |
 | with_service  | boolean | False| false   |   | When set 
to true, sends information about the current Service.   

  |
 | with_consumer | boolean | False| false   |   | When set 
to true, sends information about the current Consumer. Note that this may send 
sensitive information like the API key. Make sure to turn it on only when you 
are sure it is safe. |
+| with_body | boolean | False| false   |   | When set 
to true, sends the request body. |

Review Comment:
   I have just added a security warning



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-24 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2165474675


##
t/plugin/opa3.t:
##
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+my ($block) = @_;
+
+if (!defined $block->request) {
+$block->set_value("request", "GET /t");
+}
+});
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: setup route with plugin
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["POST"],
+"plugins": {
+"opa": {
+"host": "http://127.0.0.1:8181";,
+"policy": "with_body",
+"with_body": true
+}
+},
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uris": ["/hello", "/test"]
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- response_body
+passed
+
+
+
+=== TEST 2: hit route (with empty request)
+--- request
+POST /hello
+--- response_body
+hello world
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+
+
+
+=== TEST 4: hit route (with non-json request)
+--- request
+POST /hello
+hello world
+--- response_body
+hello world

Review Comment:
   We need to verify the body data received by OPA during the test.



##
docs/en/latest/plugins/opa.md:
##
@@ -46,6 +46,7 @@ The `opa` Plugin can be used to integrate with [Open Policy 
Agent (OPA)](https:/
 | with_route| boolean | False| false   |   | When set 
to true, sends information about the current Route. 

  |

Review Comment:
   Need to modify Chinese documents synchronously



##
docs/en/latest/plugins/opa.md:
##
@@ -46,6 +46,7 @@ The `opa` Plugin can be used to integrate with [Open Policy 
Agent (OPA)](https:/
 | with_route| boolean | False| false   |   | When set 
to true, sends information about the current Route. 

  |
 | with_service  | boolean | False| false   |   | When set 
to true, sends information about the current Service.   

  |
 | with_consumer | boolean | False| false   |   | When set 
to true, sends information about the current Consumer. Note that this may send 
sensitive information like the API key. Make sure to turn it on only when you 
are sure it is safe. |
+| with_body | boolean | False| false   |   | When set 
to true, sends the request body. |

Review Comment:
   The request body may contain sensitive information (passwords, API keys, 
etc.), so a security warning needs to be added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-24 Thread via GitHub


LuciaCabanillasRodriguez commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-3000690963

   > Maybe we can merge the master branch.
   Is there any update here?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-17 Thread via GitHub


Baoyuantop commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2982334044

   Maybe we can merge the master branch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-17 Thread via GitHub


LuciaCabanillasRodriguez commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2979666071

   Good! I could remove one issue, the other one remains! Any help?? I would 
need some guidance on how to fix it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-09 Thread via GitHub


LuciaCabanillasRodriguez commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2955931382

   Regarding the error in t/discovery/consul_dump.t, I see that the test fails 
because the expected response from Consul isn’t being returned:
   
   `got: ''
   expected: '{"service_a":[{"host":"127.0.0.1","port":30511,"weight":1}]}'
   `
   It seems like either the service_a isn’t being registered properly in Consul 
during the test, or the endpoint isn’t responding as expected.
   
   As for the other warnings and errors like:
   `failed to do SSL handshake: certificate verify failed
   http_init(): failed to load the configuration: connection refused`
   
   These appear to be related to missing services (like Consul or Etcd) or SSL 
verification issues, but I’m not entirely sure how to fix it with certainty.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-06-09 Thread via GitHub


LuciaCabanillasRodriguez commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2955883117

   > Hi, sorry I will take care as soon as I find time. 
@LuciaCabanillasRodriguez help would be very welcome, do you have the time to 
take a look at the test failures?
   
   Hello! I tried to push a file to fix one of the issues, but I received a 
forbidden message. In any case, I solved it locally by running:
   
   `make lint`
   `./utils/reindex t/plugin/opa3.t`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-05-27 Thread via GitHub


wistefan commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2915042314

   Hi, sorry I will take care as soon as I find time. @LuciaCabanillasRodriguez 
help would be very welcome, do you have the time to take a look at the test 
failures?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-05-27 Thread via GitHub


LuciaCabanillasRodriguez commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2913798089

   Hello! Any news?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-05-07 Thread via GitHub


Baoyuantop commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2861476701

   Need to fix the failed CI, waiting for a response from the author.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-05-07 Thread via GitHub


LuciaCabanillasRodriguez commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2859113051

   Hello! What is the status of this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-04-22 Thread via GitHub


Baoyuantop commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2822880310

   @wistefan, please fix failed ci


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-04-17 Thread via GitHub


wistefan commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2812512095

   @Baoyuantop Could you please appove the ci workflows?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-04-02 Thread via GitHub


wistefan commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2774639326

   @Baoyuantop Yes, most likely beginning of next week


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-04-02 Thread via GitHub


Baoyuantop commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2774552898

   Hi @wistefan, do you have time to continue working on this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-03-31 Thread via GitHub


Baoyuantop commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2768341930

   Hi @wistefan, please fix failed ci


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-03-24 Thread via GitHub


Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2011221058


##
apisix/plugins/opa/helper.lua:
##
@@ -34,9 +34,25 @@ local function build_var(conf, ctx)
 }
 end
 
+local function get_body_for_request()
+local original_body, err = core.request.get_body()
+if err ~= nil then

Review Comment:
   ```suggestion
   if err then
   ```



##
docs/en/latest/plugins/opa.md:
##
@@ -46,6 +46,7 @@ The `opa` Plugin can be used to integrate with [Open Policy 
Agent (OPA)](https:/
 | with_route| boolean | False| false   |   | When set 
to true, sends information about the current Route. 

  |
 | with_service  | boolean | False| false   |   | When set 
to true, sends information about the current Service.   

  |
 | with_consumer | boolean | False| false   |   | When set 
to true, sends information about the current Consumer. Note that this may send 
sensitive information like the API key. Make sure to turn it on only when you 
are sure it is safe. |
+| with_body | boolean | False| false   |   | When set 
to true, sends the request body. |

Review Comment:
   The Data definition section also needs to be supplemented.



##
apisix/plugins/opa/helper.lua:
##
@@ -45,8 +61,18 @@ local function build_http_request(conf, ctx)
 headers = core.request.headers(ctx),
 query   = core.request.get_uri_args(ctx),
 }
-end
 
+if conf.with_body then
+local body, err = get_body_for_request()
+if err then
+core.log.warn(err)

Review Comment:
   core.log.error ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-03-24 Thread via GitHub


Baoyuantop commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2749899857

   Hi @wistefan, please synchronize the latest master branch code to trigger 
the test.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-03-24 Thread via GitHub


LuciaCabanillasRodriguez commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2748310823

   Hello! If I want this new implementation with the request body, what should 
I do?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-01-06 Thread via GitHub


wistefan commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2574543671

   > @wistefan Please synchronize the master code to trigger all CI
   
   @moonming Thank you for the review,  I updated.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-01-06 Thread via GitHub


moonming commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2574334119

   @wistefan Please synchronize the master code to trigger all CI


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-01-06 Thread via GitHub


moonming commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r1904869662


##
apisix/plugins/opa/helper.lua:
##
@@ -45,8 +61,13 @@ local function build_http_request(conf, ctx)
 headers = core.request.headers(ctx),
 query   = core.request.get_uri_args(ctx),
 }
-end
 
+if conf.with_body then
+http.body = get_body_for_request()

Review Comment:
   ```suggestion
   local body, err = get_body_for_request()
   if err then
   core.log.warn(err)
   else
   http.body = body
   end
   ```



##
apisix/plugins/opa/helper.lua:
##
@@ -34,9 +34,25 @@ local function build_var(conf, ctx)
 }
 end
 
+local function get_body_for_request()
+local original_body, err = core.request.get_body()
+if err ~= nil then
+error("opa - failed to get request body: " .. err)

Review Comment:
   ```suggestion
   return nil, "failed to get request body: " .. err
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2025-01-06 Thread via GitHub


github-actions[bot] commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2572777502

   This pull request has been marked as stale due to 60 days of inactivity. It 
will be closed in 4 weeks if no further activity occurs. If you think that's 
incorrect or this pull request should instead be reviewed, please simply write 
any comment. Even if closed, you can still revive the PR at any time or discuss 
it on the [email protected] list. Thank you for your contributions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] feat: As a user, I want to include the request body in the opa-input, so that I can reason about its contents [apisix]

2024-11-06 Thread via GitHub


wistefan commented on PR #11629:
URL: https://github.com/apache/apisix/pull/11629#issuecomment-2459485030

   Is there anything I can do to get this PR forward?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]