This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new a2fa3ff ci: self host openid configuration (#2698)
a2fa3ff is described below
commit a2fa3ff89d886020a317f7e7f024756296e9861d
Author: 罗泽轩 <[email protected]>
AuthorDate: Wed Nov 11 11:38:25 2020 +0800
ci: self host openid configuration (#2698)
Also split long test
---
t/APISIX.pm | 8 ++++++++
t/plugin/openid-connect.t | 11 ++++++++---
t/plugin/request-validation.t | 6 +++---
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/t/APISIX.pm b/t/APISIX.pm
index 8b2c405..43de420 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -296,6 +296,14 @@ _EOC_
more_clear_headers Date;
}
+
+ location = /.well-known/openid-configuration {
+ content_by_lua_block {
+ ngx.say([[
+{"issuer":"https://samples.auth0.com/","authorization_endpoint":"https://samples.auth0.com/authorize","token_endpoint":"https://samples.auth0.com/oauth/token","device_authorization_endpoint":"https://samples.auth0.com/oauth/device/code","userinfo_endpoint":"https://samples.auth0.com/userinfo","mfa_challenge_endpoint":"https://samples.auth0.com/mfa/challenge","jwks_uri":"https://samples.auth0.com/.well-known/jwks.json","registration_endpoint":"https://samples.auth0.com/oidc/register","rev
[...]
+ ]])
+ }
+ }
}
server {
diff --git a/t/plugin/openid-connect.t b/t/plugin/openid-connect.t
index b9214ce..bc15ca7 100644
--- a/t/plugin/openid-connect.t
+++ b/t/plugin/openid-connect.t
@@ -103,7 +103,7 @@ done
"openid-connect": {
"client_id":
"kbyuFDidLLm280LIwVFiazOqjO3ty8KH",
"client_secret":
"60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa",
- "discovery":
"https://samples.auth0.com/.well-known/openid-configuration",
+ "discovery":
"http://127.0.0.1:1980/.well-known/openid-configuration",
"redirect_uri": "https://iresty.com",
"ssl_verify": false,
"timeout": 10,
@@ -125,7 +125,7 @@ done
"openid-connect": {
"client_id":
"kbyuFDidLLm280LIwVFiazOqjO3ty8KH",
"client_secret":
"60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa",
- "discovery":
"https://samples.auth0.com/.well-known/openid-configuration",
+ "discovery":
"http://127.0.0.1:1980/.well-known/openid-configuration",
"redirect_uri": "https://iresty.com",
"ssl_verify": "no",
"timeout": 10000,
@@ -171,7 +171,7 @@ passed
local res, err = httpc:request_uri(uri, {method = "GET"})
ngx.status = res.status
local location = res.headers['Location']
- if string.find(location, 'https://samples.auth0.com/authorize') ~=
-1 and
+ if location and string.find(location,
'https://samples.auth0.com/authorize') ~= -1 and
string.find(location, 'scope=apisix') ~= -1 and
string.find(location,
'client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH') ~= -1 and
string.find(location, 'response_type=code') ~= -1 and
@@ -513,6 +513,11 @@ passed
}
})
+ if not res then
+ ngx.say(err)
+ return
+ end
+
if res.status == 200 then
local body = json_decode(res.body)
local accessToken = body["access_token"]
diff --git a/t/plugin/request-validation.t b/t/plugin/request-validation.t
index 249d06b..adac026 100644
--- a/t/plugin/request-validation.t
+++ b/t/plugin/request-validation.t
@@ -101,7 +101,7 @@ done
}
}
}
- },
+ },]] .. [[
"upstream": {
"nodes": {
"127.0.0.1:1982": 1
@@ -223,7 +223,7 @@ hello1 world
}
}
}
- },
+ },]] .. [[
"upstream": {
"nodes": {
"127.0.0.1:1982": 1
@@ -344,7 +344,7 @@ hello1 world
}
}
}
- },
+ },]] .. [[
"upstream": {
"nodes": {
"127.0.0.1:1982": 1