This is an expense tracking system.
There are three types of users: regular users, user managers and admins.
Regular users can CRUD their own expense records.
In addition to above, user managers can CRUD all users.
In addition to above, admins can CRUD expense records that belong to all users.
- You are on linux/mac
- You have installed node, python, npm, yarn and mongodb, if you don't have mongodb:
brew install mongodb
sh init.sh
cd server/
yarn run mongo
cd server/
yarn start
cd client/
yarn start
- visit
http://127.0.0.1:8080
in your browser
cd server/
yarn test
oryarn run test:watch
cd client/
yarn test
oryarn run test:watch
cd client/
yarn run build
cd client/build/
python -m SimpleHTTPServer 2534
- visit
http://127.0.0.1:2534
in your browser - or another port number that is idle
Server-side tests automatically generate some fake data. The three follow accounts have been created and populated with fake data:
-
username:
aa
-
password:
aa
-
group:
Admin
-
username:
ab
-
password:
ab
-
group:
User Manager
-
username:
ac
-
password:
ac
-
group:
Regular User
- make sure you have mongodb running
cd server/
yarn run mongo:reset
- missing parameters
curl -X POST http://localhost:2039/CreateAccount
- duplicated username
curl -d "username=aa&password=aa&group=1" -X POST http://localhost:2039/CreateAccount
- success
curl -d "username="(random)(random)"&password=aa&group=1" -X POST http://localhost:2039/CreateAccount
- missing parameters
curl -X POST http://localhost:2039/CreateAccountThenLogIn
- duplicated username
curl -d "username=aa&password=aa&group=1" -X POST http://localhost:2039/CreateAccountThenLogIn
- success
curl -d "username="(random)(random)"&password=aa&group=1" -X POST http://localhost:2039/CreateAccountThenLogIn
- missing parameters
curl -X POST http://localhost:2039/LogIn
- unrecognized username
curl -d 'username='(random)(random)'&password=aa' -X POST http://localhost:2039/LogIn
- wrong password
curl -d 'username=aa&password='(random)(random) -X POST http://localhost:2039/LogIn
- success
curl -d 'username=aa&password=aa' -X POST http://localhost:2039/LogIn
-
missing parameters
curl -X POST http://localhost:2039/UpdateUser
-
please log in
curl -d "token="(random)(random)"&usernameOriginal=usernameoriginal&username=username&group=1" -X POST http://localhost:2039/UpdateUser
-
not permitted
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&usernameOriginal=usernameoriginal&username=username&group=1" -X POST http://localhost:2039/UpdateUser
-
old username not registered
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&usernameOriginal="(random)(random)"&username=username&group=1" -X POST http://localhost:2039/UpdateUser
-
new username has already registered
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&usernameOriginal=ac&username=aa&group=1" -X POST http://localhost:2039/UpdateUser
-
success without password update
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "usernames=[\"usernameFrom\",\"usernameTo\"]&token="(cat /tmp/token) -X POST http://localhost:2039/DeleteUsers
curl -d "username=usernameFrom&password=passwordFrom&group=1" -X POST http://localhost:2039/CreateAccount
curl -d "token="(cat /tmp/token)"&usernameOriginal=usernameFrom&username=usernameTo&group=3" -X POST http://localhost:2039/UpdateUser
curl -d "username=usernameFrom&password=passwordFrom" -X POST http://localhost:2039/LogIn
curl -d "username=usernameTo&password=passwordFrom" -X POST http://localhost:2039/LogIn
-
success with password update
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "usernames=[\"usernameFrom\",\"usernameTo\"]&token="(cat /tmp/token) -X POST http://localhost:2039/DeleteUsers
curl -d "username=usernameFrom&password=passwordFrom&group=1" -X POST http://localhost:2039/CreateAccount
curl -d "token="(cat /tmp/token)"&usernameOriginal=usernameFrom&username=usernameTo&group=3&password=passwordTo" -X POST http://localhost:2039/UpdateUser
curl -d "username=usernameFrom&password=passwordFrom" -X POST http://localhost:2039/LogIn
curl -d "username=usernameTo&password=passwordTo" -X POST http://localhost:2039/LogIn
-
missing parameters
curl -X POST http://localhost:2039/DeleteUsers
-
please log in
curl -d "token="(random)(random)"&usernames=[\"username1\",\"username2\"]" -X POST http://localhost:2039/DeleteUsers
-
not permitted
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&usernames=[\"username1\",\"username2\"]" -X POST http://localhost:2039/DeleteUsers
-
success
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&usernames=[\"username1\",\"username2\"]" -X POST http://localhost:2039/DeleteUsers
-
missing parameters
curl -X POST http://localhost:2039/GetUsers
-
please log in
curl -d "token="(random)(random) -X POST http://localhost:2039/GetUsers
-
not permitted
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token) -X POST http://localhost:2039/GetUsers
-
success for admin
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token) -X POST http://localhost:2039/GetUsers
-
success for user manager
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token) -X POST http://localhost:2039/GetUsers
-
success with custom pageNumber and pageSize
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&pageSize=5" -X POST http://localhost:2039/GetUsers
curl -d "token="(cat /tmp/token)"&pageSize=5&pageNumber=2" -X POST http://localhost:2039/GetUsers
-
missing parameters
curl -X POST http://localhost:2039/CreateRecord
-
please log in
curl -d "token="(random)(random)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord
-
not permitted
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord
-
username not registered
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&username="(random)(random)"&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord
-
success with creating own record
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord
-
success with creating another user's record for admin
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord
-
missing parameters
curl -X POST http://localhost:2039/UpdateRecord
-
please log in
curl -d "token="(random)(random)"&id="(random)(random)"&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/UpdateRecord
-
id not found
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&id="(random)(random)"&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/UpdateRecord
-
not permitted
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
rm -rf /tmp/id; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id'
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&id="(cat /tmp/id)"&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/UpdateRecord
-
username not registered
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
rm -rf /tmp/id; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id'
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&id="(cat /tmp/id)"&username="(random)(random)"&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/UpdateRecord
-
success with updating own record
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
rm -rf /tmp/id; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id'
curl -d "token="(cat /tmp/token)"&id="(cat /tmp/id)"&dateAndTime=1/2/2017, 12:15:17 PM&description=new desc&amount=200" -X POST http://localhost:2039/UpdateRecord
-
success with updating another user's record for admin
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
rm -rf /tmp/id; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id'
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&id="(cat /tmp/id)"&dateAndTime=1/2/2017, 12:15:17 PM&description=new desc&amount=200" -X POST http://localhost:2039/UpdateRecord
-
missing parameters
curl -X POST http://localhost:2039/DeleteRecords
-
please log in
curl -d "token="(random)(random)"&ids=[]" -X POST http://localhost:2039/DeleteRecords
-
not permitted
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
rm -rf /tmp/id1; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id1'
rm -rf /tmp/id2; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id2'
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&ids=[\""(cat /tmp/id1)"\",\""(cat /tmp/id2)"\"]" -X POST http://localhost:2039/DeleteRecords
-
success with deleting own record
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
rm -rf /tmp/id1; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id1'
rm -rf /tmp/id2; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id2'
curl -d "token="(cat /tmp/token)"&ids=[\""(cat /tmp/id1)"\",\""(cat /tmp/id2)"\"]" -X POST http://localhost:2039/DeleteRecords
-
success with deleting other user's records for admin
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
rm -rf /tmp/id1; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id1'
rm -rf /tmp/id2; curl -d "token="(cat /tmp/token)"&username=ac&dateAndTime=1/1/2017, 11:11:11 PM&description=desc&amount=100&comment=comm" -X POST http://localhost:2039/CreateRecord | vim - -c 'v/id":"\zs\d*\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/id2'
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&ids=[\""(cat /tmp/id1)"\",\""(cat /tmp/id2)"\"]" -X POST http://localhost:2039/DeleteRecords
-
missing parameters
curl -X POST http://localhost:2039/GetRecords
-
please log in
curl -d "token="(random)(random) -X POST http://localhost:2039/GetRecords
-
success with own records for non admin
rm -rf /tmp/token; curl -d "username=ab&password=ab" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token) -X POST http://localhost:2039/GetRecords
-
success with all records for admin
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token) -X POST http://localhost:2039/GetRecords
-
success with date range
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&from=1497801600000&to=1498492799000" -X POST http://localhost:2039/GetRecords
-
success with amount range
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&min=10&max=20" -X POST http://localhost:2039/GetRecords
-
success with both date and amount range
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&from=1497801600000&to=1498492799000&min=10&max=20" -X POST http://localhost:2039/GetRecords
-
success with pageNumber and pageSize
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&pageSize=5&pageNumber=1" -X POST http://localhost:2039/GetRecords
curl -d "token="(cat /tmp/token)"&pageSize=5&pageNumber=2" -X POST http://localhost:2039/GetRecords
-
success with all date range, amount range, pageNumber and pageSize
rm -rf /tmp/token; curl -d "username=aa&password=aa" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token)"&from=1497801600000&to=1498492799000&min=10&max=20&pageSize=5&pageNumber=1" -X POST http://localhost:2039/GetRecords
curl -d "token="(cat /tmp/token)"&from=1497801600000&to=1498492799000&min=10&max=20&pageSize=5&pageNumber=2" -X POST http://localhost:2039/GetRecords
-
missing parameters
curl -X POST http://localhost:2039/GetSummary
-
please log in
curl -d "token="(random)(random) -X POST http://localhost:2039/GetSummary
-
success
rm -rf /tmp/token; curl -d "username=ac&password=ac" -X POST http://localhost:2039/LogIn | vim - -c 'v/token":"\zs................\ze"/d' -c 'normal dgn' -c 'normal Vp' -c 'x! /tmp/token'
curl -d "token="(cat /tmp/token) -X POST http://localhost:2039/GetSummary