tzssangglass commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r802219849



##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,44 @@ Location: /hello?type=string&name=json
 --- error_code: 302
 --- no_error_log
 [error]
+
+
+
+=== TEST 41: redirect

Review comment:
       ```suggestion
   === TEST 41: enable http_to_https (pass X-Forwarded-Proto)
   ```

##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,44 @@ Location: /hello?type=string&name=json
 --- error_code: 302
 --- no_error_log
 [error]
+
+
+
+=== TEST 41: redirect
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("plugin.redirect").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/hello",
+                    "host": "foo.com",
+                    "vars": [
+                        [
+                            "scheme",
+                            "==",
+                            "http"
+                        ]
+                    ],
+                    "plugins": {
+                        "redirect": {
+                            "uri": "https://$host$request_uri";,
+                            "ret_code": 301
+                        }
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]

Review comment:
       and add a test case like 
   
   
   ```
   === TEST 2: enable http_to_https (pass X-Forwarded-Proto)
   --- request
   GET /hello
   --- more_headers
   Host: foo.com
   X-Forwarded-Proto: http
   --- error_code: 301
   --- response_headers
   Location: https://foo.com/hello
   ```

##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,44 @@ Location: /hello?type=string&name=json
 --- error_code: 302
 --- no_error_log
 [error]
+
+
+
+=== TEST 41: redirect
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("plugin.redirect").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/hello",
+                    "host": "foo.com",
+                    "vars": [
+                        [
+                            "scheme",
+                            "==",
+                            "http"
+                        ]
+                    ],
+                    "plugins": {
+                        "redirect": {
+                            "uri": "https://$host$request_uri";,
+                            "ret_code": 301

Review comment:
       ```suggestion
                               "http_to_https": true
   ```




-- 
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]


Reply via email to