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]
LuciaCabanillasRodriguez commented on PR #11629: URL: https://github.com/apache/apisix/pull/11629#issuecomment-4234468157 Any updates 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]
Baoyuantop commented on PR #11629: URL: https://github.com/apache/apisix/pull/11629#issuecomment-4037486284 Hi @LuciaCabanillasRodriguez, there are still failed CIs that need to be 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]
LuciaCabanillasRodriguez commented on code in PR #11629: URL: https://github.com/apache/apisix/pull/11629#discussion_r2847291805 ## docs/zh/latest/plugins/opa.md: ## @@ -2,8 +2,6 @@ title: opa keywords: - Apache APISIX - - API 网关 - - Plugin Review Comment: Done! -- 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]
LuciaCabanillasRodriguez commented on code in PR #11629: URL: https://github.com/apache/apisix/pull/11629#discussion_r2847279284 ## docs/zh/latest/plugins/opa.md: ## @@ -2,8 +2,6 @@ title: opa keywords: - Apache APISIX - - API 网关 - - Plugin - Open Policy Agent - opa Review Comment: I added this in my last commit! -- 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]
Copilot commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2844262098
##
t/plugin/opa3.t:
##
@@ -0,0 +1,106 @@
+#
+# 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
+--- error_code: 403
+
+
+
+=== TEST 3: hit route (with json request)
+--- request
+POST /hello
+{
+"hello": "world"
+}
+--- response_body
+hello world
+--- error_log_matches
+"\"request\":{\"body\":{\"hello\":\"world\"}"
+
+
+
Review Comment:
`error_log_matches` makes the test depend on log output that isn't directly
tied to the assertion (the allow/deny behavior already proves the body is being
used by OPA). This is likely to be flaky across log-level/config changes.
Prefer asserting via response behavior only (e.g., rely on 200 vs 403), or use
an `echo`-style policy to return the evaluated input and assert `request.body`
from the response body instead of logs.
```suggestion
```
##
docs/en/latest/plugins/opa.md:
##
@@ -87,6 +89,7 @@ Each of these keys are explained below:
- `type` indicates the request type (`http` or `stream`).
- `request` is used when the `type` is `http` and contains the basic request
information (URL, headers etc).
- `var` contains the basic information about the requested connection (IP,
port, request timestamp etc).
+- `body` contains the http-body of the request
Review Comment:
Documentation mismatch: the example shows `"body": {}` under `request`, but
the text below describes `body` as if it were a top-level key. Also, the
implementation can omit `request.body` when empty, and can send a string for
non-JSON bodies. Please clarify that this is `request.body` and document the
possible types/absence so policy authors know what to expect.
```suggestion
- `request.body` contains the HTTP request body. This field may be omitted
when the body is empty. When present, it is:
- a JSON value (object, array, or primitive) if the request body is parsed
as JSON, or
- a string for non‑JSON bodies or bodies that cannot be parsed as JSON.
```
##
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.error(err)
+else
+http.body = body
+end
Review Comment:
When `with_body` is enabled and reading the request body fails (e.g., HTTP/2
or HTTP/3 request without `Content-Length`, or temp-file read errors), the code
currently just logs and continues without `request.body`. This can cause OPA
policies that rely on the bo
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]
Baoyuantop commented on code in PR #11629: URL: https://github.com/apache/apisix/pull/11629#discussion_r2844234135 ## docs/zh/latest/plugins/opa.md: ## @@ -30,28 +28,28 @@ description: 本篇文档介绍了 Apache APISIX 通过 opa 插件与 Open Polic ## 描述 -`opa` 插件可用于与 [Open Policy Agent](https://www.openpolicyagent.org) 进行集成,实现后端服务的认证授权与访问服务等功能解耦,减少系统复杂性。 +`opa` 插件可用于与 [Open Policy Agent (OPA)](https://www.openpolicyagent.org) 集成。OPA 是一个策略引擎,帮助定义和执行授权策略,用以判断用户或应用程序是否拥有执行特定操作或访问特定资源的必要权限。将 OPA 与 APISIX 配合使用可以将授权逻辑从 APISIX 中解耦。 ## 属性 -| 名称 | 类型| 必选项 | 默认值 | 有效值 | 描述 | -|---|-|--|-|---|| +| 名称 | 类型| 是否必需 | 默认值 | 有效值| 描述 | Review Comment: ```suggestion | 名称 | 类型| 必选项 | 默认值 | 有效值| 描述 | ``` ## docs/zh/latest/plugins/opa.md: ## @@ -2,8 +2,6 @@ title: opa keywords: - Apache APISIX - - API 网关 - - Plugin Review Comment: please keep it ## docs/zh/latest/plugins/opa.md: ## @@ -106,22 +106,22 @@ description: 本篇文档介绍了 Apache APISIX 通过 opa 插件与 Open Polic } ``` -上述响应中的代码释义如下: +响应中的键说明: -- `allow` 配置是必不可少的,它表示请求是否允许通过 APISIX 进行转发; -- `reason`、`headers` 和 `status_code` 是可选的,只有当你配置一个自定义响应时才会返回这些选项信息,具体使用方法可查看后续测试用例。 +- `allow` 是必需的,表示请求是否被允许通过 APISIX。 +- `reason`、`headers` 和 `status_code` 是可选的,仅在配置自定义响应时返回。请参见下一节用例。 -## 测试插件 +## 使用示例 Review Comment: ```suggestion ## 测试插件 ``` ## docs/zh/latest/plugins/opa.md: ## @@ -82,16 +81,17 @@ description: 本篇文档介绍了 Apache APISIX 通过 opa 插件与 Open Polic } ``` -上述代码具体释义如下: +以下是各个键的说明: -- `type` 代表请求类型(如 `http` 或 `stream`); -- `request` 则需要在 `type` 为 `http` 时使用,包含基本的请求信息(如 URL、头信息等); -- `var` 包含关于请求连接的基本信息(如 IP、端口、请求时间戳等); -- `route`、`service` 和 `consumer` 包含的数据与 APISIX 中存储的数据相同,只有当这些对象上配置了 `opa` 插件时才会发送。 +- `type` 表示请求类型(`http` 或 `stream`). +- `request` 在 `type` 为 `http` 时使用,包含基本请求信息(URL、头信息等). +- `var` 包含请求连接的基本信息(IP、端口、请求时间戳等)。 +- `body` 包含请求的 HTTP 主体。 +- `route`、`service` 和 `consumer` 包含 APISIX 中存储的相同数据,且仅在 `opa` 插件配置在这些对象上时发送。 -### OPA 向 APISIX 返回数据 +### OPA 服务到 APISIX Review Comment: ```suggestion ### OPA 向 APISIX 返回数据 ``` ## docs/zh/latest/plugins/opa.md: ## @@ -241,9 +241,11 @@ test ### 发送 APISIX 数据 -如果你的 OPA 服务需要根据 APISIX 的某些数据(如 Route 和 Consumer 的详细信息)来进行后续操作时,则可以通过配置插件来实现。 +再看一个场景,当决策需要使用一些 APISIX 数据,比如 `route`、`consumer` 等时,如何操作? Review Comment: ```suggestion 如果你的 OPA 服务需要根据 APISIX 的某些数据(如 Route 和 Consumer 的详细信息)来进行后续操作时,则可以通过配置插件来实现。 ``` -- 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]
Baoyuantop commented on code in PR #11629: URL: https://github.com/apache/apisix/pull/11629#discussion_r2807114896 ## docs/zh/latest/plugins/opa.md: ## @@ -30,28 +28,29 @@ description: 本篇文档介绍了 Apache APISIX 通过 opa 插件与 Open Polic ## 描述 -`opa` 插件可用于与 [Open Policy Agent](https://www.openpolicyagent.org) 进行集成,实现后端服务的认证授权与访问服务等功能解耦,减少系统复杂性。 +`opa` 插件可用于与 [Open Policy Agent (OPA)](https://www.openpolicyagent.org) 集成。OPA 是一个策略引擎,帮助定义和执行授权策略,用以判断用户或应用程序是否拥有执行特定操作或访问特定资源的必要权限。将 OPA 与 APISIX 配合使用可以将授权逻辑从 APISIX 中解耦。 ## 属性 -| 名称 | 类型| 必选项 | 默认值 | 有效值 | 描述 | -|---|-|--|-|---|| +| 名称 | 类型| 是否必需 | 默认值 | 有效值| 描述 | +|---|-|--|-|---|| | host | string | 是 | | | OPA 服务的主机地址,例如 `https://localhost:8181`。 | | ssl_verify| boolean | 否| true| | 当设置为 `true` 时,将验证 SSL 证书。 | -| policy| string | 是 | | | OPA 策略路径,是 `package` 和 `decision` 配置的组合。当使用高级功能(如自定义响应)时,你可以省略 `decision` 配置。 | +| policy| string | 是 | | | OPA 策略路径,是 `package` 和 `decision` 配置的组合。当使用高级功能(如自定义响应)时,你可以省略 `decision` 配置。指定命名空间时,请使用斜杠格式(例如 `examples/echo`),而不是点号格式(例如 `examples.echo`)。| | timeout | integer | 否| 3000ms | [1, 6]ms | 设置 HTTP 调用超时时间。 | | keepalive | boolean | 否| true| | 当设置为 `true` 时,将为多个请求保持连接并处于活动状态。 | | keepalive_timeout | integer | 否| 6ms | [1000, ...]ms | 连接断开后的闲置时间。 | | keepalive_pool| integer | 否| 5 | [1, ...]ms| 连接池限制。 | | with_route| boolean | 否| false | | 当设置为 `true` 时,发送关于当前 Route 的信息。 | | with_service | boolean | 否| false | | 当设置为 `true` 时,发送关于当前 Service 的信息。 | | with_consumer | boolean | 否| false | | 当设置为 `true` 时,发送关于当前 Consumer 的信息。注意,这可能会发送敏感信息,如 API key。请确保在安全的情况下才打开它。 | +| with_body | boolean | 否 | false | | 设置为 `true` 时,发送请求体。注意这可能会发送密码或 API 密钥等敏感信息。确保仅在理解安全隐患的情况下启用此功能。 | ## 数据定义 -### APISIX 向 OPA 发送信息 Review Comment: Please remove irrelevant changes from the Chinese documentation. -- 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]
Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2801977054
##
docs/zh/latest/plugins/opa.md:
##
@@ -2,11 +2,11 @@
title: opa
keywords:
- Apache APISIX
- - API 网关
- - Plugin
+ - API Gateway
+ - 插件
- Open Policy Agent
- opa
-description: 本篇文档介绍了 Apache APISIX 通过 opa 插件与 Open Policy Agent 对接的相关信息。
+description: 本文档包含有关 Apache APISIX opa 插件的信息。
Review Comment:
These changes are irrelevant to this PR; please minimize these irrelevant
changes.
##
docs/en/latest/plugins/opa.md:
##
@@ -78,7 +79,8 @@ The JSON below shows the data sent to the OPA service by
APISIX:
},
"route": {},
"service": {},
-"consumer": {}
+"consumer": {},
+"body": {}
Review Comment:
Please confirm the location of the body data. Based on the code, the body is
located below the request level.
##
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 then
+return nil, "failed to get request body: " .. err
+end
+if original_body == nil then
+return nil
+end
+-- decode to prevent double encoded json objects
+local body, err = core.json.decode(original_body)
+if err ~= nil then
Review Comment:
```suggestion
if err then
```
--
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]
moonming commented on PR #11629: URL: https://github.com/apache/apisix/pull/11629#issuecomment-3894426430 > Can three people with write access review this, please? @Baoyuantop please take alook -- 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]
Sharoek commented on PR #11629: URL: https://github.com/apache/apisix/pull/11629#issuecomment-3891070726 Can three people with write access review this, please? -- 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]
Baoyuantop commented on PR #11629: URL: https://github.com/apache/apisix/pull/11629#issuecomment-3881787195 I reran the failed 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]
LuciaCabanillasRodriguez commented on PR #11629: URL: https://github.com/apache/apisix/pull/11629#issuecomment-3876872429 Could you check it? I think the failing checks are not related with opa -- 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]
LuciaCabanillasRodriguez commented on PR #11629: URL: https://github.com/apache/apisix/pull/11629#issuecomment-3809790975 Could you check the 2 failing checks? I think they are not related with opa -- 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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
