diff --git a/README.md b/README.md index 2d17a58..f1a9db4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

-[![Build Status](https://travis-ci.com/wind-c/comqtt.svg?token=59nqixhtefy2iQRwsPcu&branch=master)](https://travis-ci.com/wind-c/comqtt/v2) +[![Build Status](https://github.com/wind-c/comqtt/actions/workflows/runtests.yaml/badge.svg)](https://github.com/wind-c/comqtt/actions/workflows/runtests.yaml) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/wind-c/comqtt/issues) [![codecov](https://codecov.io/gh/wind-c/comqtt/branch/master/graph/badge.svg?token=6vBUgYVaVB)](https://codecov.io/gh/wind-c/comqtt/v2) [![GoDoc](https://godoc.org/github.com/wind-c/comqtt?status.svg)](https://pkg.go.dev/github.com/wind-c/comqtt/v2) diff --git a/docker-compose.yaml b/docker-compose.yaml index 78b1738..c18ff22 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,4 +9,16 @@ services: - "3306:3306" command: --character-set-server=utf8 --collation-server=utf8_general_ci volumes: - - ./plugin/auth/mysql/testdata/init.sql:/docker-entrypoint-initdb.d/init.sql \ No newline at end of file + - ./plugin/auth/mysql/testdata/init.sql:/docker-entrypoint-initdb.d/init.sql + + postgresql: + image: postgres:16 + container_name: postgresql + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: 12345678 + POSTGRES_DB: comqtt + ports: + - "5432:5432" + volumes: + - ./plugin/auth/postgresql/testdata/init:/docker-entrypoint-initdb.d diff --git a/plugin/auth/postgresql/postgresql_test.go b/plugin/auth/postgresql/postgresql_test.go index 6820a60..c581f66 100644 --- a/plugin/auth/postgresql/postgresql_test.go +++ b/plugin/auth/postgresql/postgresql_test.go @@ -13,7 +13,7 @@ import ( "github.com/wind-c/comqtt/v2/plugin" ) -const path = "./conf.yml" +const path = "./testdata/conf.yml" var ( // Currently, the input is directed to /dev/null. If you need to diff --git a/plugin/auth/postgresql/conf.yml b/plugin/auth/postgresql/testdata/conf.yml similarity index 100% rename from plugin/auth/postgresql/conf.yml rename to plugin/auth/postgresql/testdata/conf.yml diff --git a/plugin/auth/postgresql/testdata/init/init.sql b/plugin/auth/postgresql/testdata/init/init.sql new file mode 100644 index 0000000..8edafa0 --- /dev/null +++ b/plugin/auth/postgresql/testdata/init/init.sql @@ -0,0 +1,24 @@ +BEGIN; +CREATE TABLE auth ( + id serial PRIMARY KEY, + username TEXT NOT NULL UNIQUE, + password TEXT NOT NULL, + allow smallint DEFAULT 1 NOT NULL, + created timestamp with time zone DEFAULT NOW(), + updated timestamp +); + +CREATE TABLE acl( + id serial PRIMARY KEY, + username TEXT NOT NULL, + topic TEXT NOT NULL, + access smallint DEFAULT 3 NOT NULL, + created timestamp with time zone DEFAULT NOW(), + updated timestamp +); +CREATE INDEX acl_username_idx ON acl(username); + +INSERT INTO auth (username, password, allow) VALUES ('zhangsan', '321654', 1); +INSERT INTO acl (username, topic, access) VALUES ('zhangsan', 'topictest/1', 2); + +COMMIT;