Skip to content

Commit

Permalink
Sketch out the requirements forthe multi PUT
Browse files Browse the repository at this point in the history
These are the tests needed to fix #2
  • Loading branch information
KayEss committed Jun 3, 2017
1 parent b103905 commit f658f29
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Example/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ run ../Cpp/fostgres-test//fostgres-test :
test-user-avatar
;

run ../Cpp/fostgres-test//fostgres-test :
fostgres-test-user-config
:
../../fost-web/Configuration/log-show-all.json
../Cpp/fostgres//fostgres
users/config.fg
users/users.tables.sql
users/view.config.json
:
:
test-user-config
;

14 changes: 14 additions & 0 deletions Example/users/config.csj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"group_name"
"admin"
"user"
"anon"

"permission_name"
"can-register"
"upload-avatar"
"ban-user"

"group_name", "permission_name"
"admin", "ban-user"
"anon", "can-register"
"user", "upload-avatar"
2 changes: 2 additions & 0 deletions Example/users/config.fg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Make sure we can PUT all of the config at one time
PUT config / (module.path.join config.csj) 200
26 changes: 24 additions & 2 deletions Example/users/users.tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,38 @@ CREATE TABLE users (


CREATE TABLE passwords (
username text NOT NULL REFERENCES users ON DELETE CASCADE INITIALLY DEFERRED,
username text NOT NULL REFERENCES users
ON DELETE CASCADE INITIALLY DEFERRED,
hashed text NOT NULL,
salt text NOT NULL,
CONSTRAINT passwords_pk PRIMARY KEY(username)
);


CREATE TABLE avatar_upload (
username text NOT NULL REFERENCES users ON DELETE CASCADE INITIALLY DEFERRED,
username text NOT NULL REFERENCES users
ON DELETE CASCADE INITIALLY DEFERRED,
avatar text NOT NULL,
CONSTRAINT avatar_upload_pk PRIMARY KEY (username)
);


CREATE TABLE groups (
name text NOT NULL,
CONSTRAINT groups_pk PRIMARY KEY (name)
);


CREATE TABLE permissions (
name text NOT NULL,
CONSTRAINT permissions_pk PRIMARY KEY (name)
);


CREATE TABLE group_permissions (
group_name text NOT NULL,
permission_name text NOT NULL,
CONSTRAINT group_permissions_pk
PRIMARY KEY (group_name, permission_name)
);

42 changes: 42 additions & 0 deletions Example/users/view.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"webserver" : {
"views/config": {
"view": "fostgres.sql",
"configuration": {
"dbname": ["request", "headers", "__pgdsn", "dbname"],
"sql": [
{
"path": [],
"GET": [
"SELECT name AS group_name FROM groups",
"SELECT name AS permission_name FROM permissions",
"SELECT * FROM group_permissions"
],
"PUT": [
{
"table": "groups",
"columns": {
"name": {"key": true, "source": "group_name"}
}
},
{
"table": "permissions",
"columns": {
"name": {"key": true, "source": "permission_name"}
}
},
{
"table": "group_permissions",
"columns": {
"group_name": {"key": true},
"permission_name": {"key": true}
}
}
]
}
]
}
}
}
}

0 comments on commit f658f29

Please sign in to comment.