- Have a Postgres database available
docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d onjin/alpine-postgres
This creates a container named postgres
with Postgres super user postgres
with password postgres
.
- Create databases
- Create
customer
database - Create
microservice1
database
-
Execute
db/security.sql
against the database server. -
Execute
db/customer.sql
againstcustomer
database. -
Execute
db/microservice1.sql
againstmicroservice1
database.
- Connect as
postgres
tomicroservice1
database.
psql -U postgres -W microservice1
- Test foreign schema
Execute the following query against
microservice1
database:
SELECT feedback, customer.username, customer.password FROM feedback INNER JOIN customer ON customer.id = feedback.customer_id;
Output should be:
feedback | username | password
------------+----------+--------------------------------------------------------------
Feedback 1 | test | $2a$06$hQU31q0WMPnv.9I2pVcVZeoEuyIeU2r.4fDXIQhhED9KWhKC1/exm
(1 row)
- Disconnect.
- Connect as
postgres
tocustomer
database.
psql -U postgres -W customer
- Test query as
postgres
super user Execute the following query againstcustomer
database:
SELECT * FROM customer;
Output should be:
id | username | password | is_system | is_test | modtime
----+----------+--------------------------------------------------------------+-----------+---------+-------------------------------
1 | test | $2a$06$sPRfklhdpf2B5wohC2Btlul1LAx0Sp7J6pohuF.U1geogK7cEVbSG | f | t | 2016-05-05 19:26:49.930674+00
2 | test2 | $2a$06$tCh8s8GIqEP524osKzvlPu/WIf0HFK6drzfYUcGRX8TPmjPjegbP6 | f | t | 2016-05-05 19:26:49.930674+00
3 | test3 | $2a$06$MiOQ2tfoqSw9HB36TRUvyOhYYhovgKUOiUpLgCWI/mfAbjlyIm.7. | f | t | 2016-05-05 19:26:49.930674+00
(3 rows)
-
Disconnect.
-
Connect as
test
tocustomer
database.
psql -U test -W customer
- Test query as
test
Execute the following query againstcustomer
database:
SELECT * FROM customer;
Output should be:
id | username | password | is_system | is_test | modtime
----+----------+--------------------------------------------------------------+-----------+---------+-------------------------------
1 | test | $2a$06$mBIeYWLAmzykrt68cnHQLe6Km.w1ZG1XxdaZMHJvWQoe.44G9pVGq | f | t | 2016-05-05 17:00:33.443258+00
(1 row)
-
Disconnect.
-
Connect as
test2
tocustomer
database.
psql -U test2 -W customer
- Test query as
test2
Execute the following query againstcustomer
database:
SELECT * FROM customer;
Output should be:
id | username | password | is_system | is_test | modtime
----+----------+--------------------------------------------------------------+-----------+---------+-------------------------------
2 | test2 | $2a$06$BbJYZdYZkSPpM.I/L3K9reDVQyqgOu4yHqfllY6qRQjjkgTQ8qYL. | f | t | 2016-05-05 17:00:33.443258+00
(1 row)
-
Disconnect.
-
Connect as
test3
tocustomer
database.
psql -U test3 -W customer
- Test query as
test3
Note: indb/customer.sql
usertest3
has limitedSELECT
permissions tocustomer
table. Because of thisSELECT * FROM customer;
will not work. You need to specify the columns user has access to. Execute the following query againstcustomer
database:
SELECT id, username, is_system, is_test FROM customer;
Output should be:
id | username | is_system | is_test
----+----------+-----------+---------
3 | test3 | f | t
(1 row)