| name: test |
| on: |
| push: |
| branches: |
| - master |
| pull_request: |
| branches: [ master ] |
| |
| jobs: |
| test: |
| runs-on: ubuntu-latest |
| strategy: |
| fail-fast: false |
| steps: |
| - name: Checkout |
| uses: actions/checkout@v2 |
| - name: Install Dependencies |
| run: | |
| wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add - |
| sudo apt-get update |
| sudo apt-get -y install software-properties-common |
| sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" |
| sudo apt-get update |
| wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz |
| tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \ |
| cd etcd-v3.4.13-linux-amd64 && \ |
| sudo cp -a etcd etcdctl /usr/bin/ |
| sudo apt-get install -y git openresty curl openresty-openssl111-dev make gcc |
| curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -o install-luarocks.sh |
| chmod +x install-luarocks.sh |
| sudo ./install-luarocks.sh |
| nohup etcd & |
| - name: Install and configure APISIX |
| run: | |
| mkdir apisix-2.7 |
| wget https://downloads.apache.org/apisix/2.7/apache-apisix-2.7-src.tgz |
| tar zxvf apache-apisix-2.7-src.tgz -C apisix-2.7 |
| cd apisix-2.7 |
| make deps |
| make init |
| cd .. |
| - name: Configure apisix-authz |
| run: | |
| cp apisix-authz.lua apisix-2.7/apisix/plugins/apisix-authz.lua |
| # append plugins to config |
| cat <<EOT >> apisix-2.7/conf/config.yaml |
| plugins: # plugin list (sorted by priority) |
| - client-control # priority: 22000 |
| - ext-plugin-pre-req # priority: 12000 |
| - zipkin # priority: 11011 |
| - request-id # priority: 11010 |
| - fault-injection # priority: 11000 |
| - serverless-pre-function # priority: 10000 |
| - batch-requests # priority: 4010 |
| - cors # priority: 4000 |
| - ip-restriction # priority: 3000 |
| - referer-restriction # priority: 2990 |
| - uri-blocker # priority: 2900 |
| - request-validation # priority: 2800 |
| - openid-connect # priority: 2599 |
| - wolf-rbac # priority: 2555 |
| - hmac-auth # priority: 2530 |
| - basic-auth # priority: 2520 |
| - jwt-auth # priority: 2510 |
| - key-auth # priority: 2500 |
| - consumer-restriction # priority: 2400 |
| - authz-keycloak # priority: 2000 |
| #- error-log-logger # priority: 1091 |
| - proxy-mirror # priority: 1010 |
| - proxy-cache # priority: 1009 |
| - proxy-rewrite # priority: 1008 |
| - api-breaker # priority: 1005 |
| - limit-conn # priority: 1003 |
| - limit-count # priority: 1002 |
| - limit-req # priority: 1001 |
| #- node-status # priority: 1000 |
| - server-info # priority: 990 |
| - traffic-split # priority: 966 |
| - redirect # priority: 900 |
| - response-rewrite # priority: 899 |
| #- dubbo-proxy # priority: 507 |
| - grpc-transcode # priority: 506 |
| - prometheus # priority: 500 |
| - echo # priority: 412 |
| - http-logger # priority: 410 |
| - sls-logger # priority: 406 |
| - tcp-logger # priority: 405 |
| - kafka-logger # priority: 403 |
| - syslog # priority: 401 |
| - udp-logger # priority: 400 |
| #- log-rotate # priority: 100 |
| # <- recommend to use priority (0, 100) for your custom plugins |
| - example-plugin # priority: 0 |
| #- skywalking # priority: -1100 |
| - serverless-post-function # priority: -2000 |
| - ext-plugin-post-req # priority: -3000 |
| - apisix-authz |
| EOT |
| sudo apt install make gcc libpcre3 libpcre3-dev |
| sudo luarocks install https://raw.githubusercontent.com/casbin/lua-casbin/master/casbin-1.16.1-1.rockspec |
| - name: Start the server |
| run: | |
| cd apisix-2.7 |
| make run |
| curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' |
| { |
| "uri": "/*", |
| "plugins": { |
| "apisix-authz": { |
| "model_path": "/home/runner/work/apisix-authz/apisix-authz/examples/authz_model.conf", |
| "policy_path": "/home/runner/work/apisix-authz/apisix-authz/examples/authz_policy.csv", |
| "username" : "user" |
| } |
| }, |
| "host": "example.com", |
| "upstream": { |
| "type": "roundrobin", |
| "nodes": { |
| "example.com": 1 |
| } |
| } |
| }' |
| cd .. |
| - name: Set up testing env |
| run: | |
| sudo luarocks install busted |
| sudo luarocks install busted-htest |
| sudo luarocks install luasocket |
| - name: Run Test |
| run : | |
| busted plugin_test.lua -o htest |