Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #116 from echo-webkom/develop
Browse files Browse the repository at this point in the history
Event registration (master)
  • Loading branch information
bakseter authored Aug 31, 2021
2 parents 54e70c2 + c81bf55 commit ed5b213
Show file tree
Hide file tree
Showing 22 changed files with 1,488 additions and 342 deletions.
7 changes: 5 additions & 2 deletions docker-compose.cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ services:
- '8080:8080'
# Check if backend is ready, and insert bedpres for testing.
healthcheck:
test: ["CMD-SHELL", "./scripts/submit_bedpres -t -x $$WEBKOM_KEY || exit 1" ]
test: ["CMD-SHELL", "./scripts/submit_happening -t -x $$WEBKOM_KEY || exit 1" ]
interval: 5s
timeout: 5s
retries: 5
environment:
DATABASE_URL: postgres://postgres:password@database/postgres
# Value of DEV doesn't matter, only that it's defined.
DEV: "yes"
# Values from .env file
BEDKOM_KEY: ${BEDKOM_KEY}
WEBKOM_KEY: ${WEBKOM_KEY}

database:
image: postgres:13.2-alpine
# Postgres 13.4 is the version Heroku uses.
image: postgres:13.4-alpine
restart: always
ports:
- '5432:5432'
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.kotest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ services:
command: ./gradlew test --build-cache --no-rebuild --no-daemon
environment:
DATABASE_URL: postgres://postgres:password@database/postgres
# Value of DEV doesn't matter, only that it's defined.
DEV: "yes"
# Values from .env file
BEDKOM_KEY: ${BEDKOM_KEY}
WEBKOM_KEY: ${WEBKOM_KEY}

database:
# Postgres 13.2 is the version Heroku uses.
image: postgres:13.2-alpine
# Postgres 13.4 is the version Heroku uses.
image: postgres:13.4-alpine
restart: always
ports:
- '5432:5432'
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ services:
- '8080:8080'
environment:
DATABASE_URL: postgres://postgres:password@database/postgres
# Value of DEV doesn't matter, only that it's defined.
DEV: "yes"
# Values from .env file
BEDKOM_KEY: ${BEDKOM_KEY}
WEBKOM_KEY: ${WEBKOM_KEY}

database:
# Postgres 13.2 is the version Heroku uses.
image: postgres:13.2-alpine
# Postgres 13.4 is the version Heroku uses.
image: postgres:13.4-alpine
restart: always
ports:
- '5432:5432'
Expand Down
13 changes: 10 additions & 3 deletions scripts/delete_bedpres → scripts/delete_happening
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ host=http://localhost
port=8080
user=webkom

while getopts zps:x:u flag; do
while getopts zps:x:u:h: flag; do
case "${flag}" in
z) host=${OPTARG} ;;
p) port=${OPTARG} ;;
s) slug=${OPTARG} ;;
x) secret=${OPTARG} ;;
u) user=${OPTARG} ;;
h) happening=${OPTARG} ;;
*) echo "Invalid flag." ;;
esac
done
Expand All @@ -26,10 +27,16 @@ if [ -z ${slug+x} ]; then
exit 1
fi

if [ -z ${happening+x} ]; then
echo "Happening type not defined (use -h)"
exit 1
fi

curl --verbose \
-X DELETE \
-u "$user":"$secret" \
-H "Connection: close" \
-H "Content-Type: application/json" \
-d '{ "slug": "'"$slug"'" }' \
"$host":"$port"/bedpres
-d '{ "slug": "'"$slug"'"
"type": "'"$happening"'"}' \
"$host":"$port"/happening
14 changes: 11 additions & 3 deletions scripts/delete_registration
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ host=http://localhost
port=8080
user=bedkom

while getopts zps:e:x:u flag; do
while getopts zps:e:x:u:h: flag; do
case "${flag}" in
z) host=${OPTARG} ;;
p) port=${OPTARG} ;;
s) slug=${OPTARG} ;;
e) email=${OPTARG} ;;
x) secret=${OPTARG} ;;
u) user=${OPTARG} ;;
h) happening=${OPTARG} ;;
*) echo "Invalid flag." ;;
esac
done
Expand All @@ -32,10 +33,17 @@ if [ -z ${email+x} ]; then
exit 1
fi

if [ -z ${happening+x} ]; then
echo "Happening type not defined (use -h)"
exit 1
fi

curl --verbose \
-X DELETE \
-u "$user":"$secret" \
-H "Connection: close" \
-H "Content-Type: application/json" \
-d '{ "slug": "'"${slug}"'", "email": "'"${email}"'" }' \
"$host:$port/registration"
-d '{ "slug": "'"${slug}"'",
"email": "'"${email}"'"
"type": "'"${happening}"'" }' \
"$host":"$port"/registration
14 changes: 10 additions & 4 deletions scripts/get_count_registrations
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ host=http://localhost
port=8080
user=bedkom

while getopts zpe:s:x:uw flag; do
while getopts zpe:s:x:uw:h: flag; do
case "${flag}" in
z) host=${OPTARG} ;;
p) port=${OPTARG} ;;
s) slug=${OPTARG} ;;
x) secret=${OPTARG} ;;
u) user=${OPTARG} ;;
w) waitlist=${OPTARG} ;;
h) happening=${OPTARG} ;;
*) echo "Invalid flag." ;;
esac
done
Expand All @@ -22,15 +23,20 @@ if [ -z ${secret+x} ]; then
exit 1
fi

if [ -z ${happening+x} ]; then
echo "Happening type not defined (use -h)".
exit 1
fi

if [ -z ${slug+x} ]; then
echo "No slug specified (use -s)."
echo "Slug not defined (use -s)."
exit 1
elif [ -z ${waitlist+x} ]; then
curl --verbose \
-u "$user":"$secret" \
"$host:$port/registration?count=y&slug=$slug"
"$host:$port/registration?count=y&slug=$slug&type=$happening"
else
curl --verbose \
-u "$user":"$secret" \
"$host:$port/registration?count=y&slug=$slug&waitlist=y"
"$host:$port/registration?count=y&slug=$slug&waitlist=y&type=$happening"
fi
16 changes: 11 additions & 5 deletions scripts/get_registrations
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ host=http://localhost
port=8080
user=bedkom

while getopts zpe:s:x:u flag; do
while getopts zpe:s:x:u:h: flag; do
case "${flag}" in
z) host=${OPTARG} ;;
p) port=${OPTARG} ;;
e) email=${OPTARG} ;;
s) slug=${OPTARG} ;;
x) secret=${OPTARG} ;;
u) user=${OPTARG} ;;
h) happening=${OPTARG} ;;
*) echo "Invalid flag." ;;
esac
done
Expand All @@ -22,20 +23,25 @@ if [ -z ${secret+x} ]; then
exit 1
fi

if [ -z ${happening+x} ]; then
echo "Happening type not defined (use -h)."
exit 1
fi

if [ -z ${email+x} ] && [ -z ${slug+x} ]; then
curl --verbose \
-u "$user":"$secret" \
"$host":"$port"/registration
"$host:$port/registration?type=$happening"
elif [ -z ${slug+x} ]; then
curl --verbose \
-u "$user":"$secret" \
"$host":"$port"/registration?email="$email"
"$host:$port/registration?email=$email&type=$happening"
elif [ -z ${email+x} ]; then
curl --verbose \
-u "$user":"$secret" \
"$host:$port/registration?slug=$slug"
"$host:$port/registration?slug=$slug&type=$happening"
else
curl --verbose \
-u "$user":"$secret" \
"$host:$port/registration?email=$email&slug=$slug"
"$host:$port/registration?email=$email&slug=$slug&type=$happening"
fi
60 changes: 0 additions & 60 deletions scripts/submit_bedpres

This file was deleted.

105 changes: 105 additions & 0 deletions scripts/submit_happening
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

# Default values
host="http://localhost"
port="8080"
testing=false
user="webkom"
mindeg=1
maxdeg=5

while getopts zpts:o:r:x:u:h:ia flag; do
case "${flag}" in
z) host=${OPTARG} ;;
p) port=${OPTARG} ;;
t) testing=true ;;
s) slug=${OPTARG} ;;
o) spots=${OPTARG} ;;
r) regdate=${OPTARG} ;;
x) secret=${OPTARG} ;;
u) user=${OPTARG} ;;
h) happening=${OPTARG} ;;
i) mindeg=${OPTARG} ;;
a) maxdeg=${OPTARG} ;;
*) echo "Invalid flag." ;;
esac
done

if [ -z ${secret+x} ]; then
echo "No authorization header specified (use -x)"
exit 1
fi

if [ "$testing" = true ]; then
curl --verbose \
-X PUT \
-u "$user":"$secret" \
-H "Connection: close" \
-H "Content-Type: application/json" \
-d '{ "slug": "bedriftspresentasjon-med-bekk",
"spots": 50,
"registrationDate": "2021-05-06T16:46+01:00",
"minDegreeYear": 1,
"maxDegreeYear": 5,
"type": "BEDPRES" }' \
"$host":"$port"/happening
curl --verbose \
-X PUT \
-u "$user":"$secret" \
-H "Connection: close" \
-H "Content-Type: application/json" \
-d '{ "slug": "fest-med-tilde",
"spots": 50,
"registrationDate": "2021-05-06T16:46+01:00",
"minDegreeYear": 1,
"maxDegreeYear": 5,
"type": "EVENT" }' \
"$host":"$port"/happening
exit 0
fi

if [ -z ${slug+x} ]; then
echo "Slug not defined (use -s)"
exit 1
fi

if [ -z ${spots+x} ]; then
echo "Spots not defined (use -o)"
exit 1
fi

if [ -z ${regdate+x} ]; then
echo "Registration date not defined (use -r)"
exit 1
fi

if [ -z ${mindeg+x} ]; then
echo "Min degree year not defined (use -i)"
exit 1
fi

if [ -z ${maxdeg+x} ]; then
echo "Min degree year not defined (use -i)"
exit 1
fi

if [ -z ${happening+x} ]; then
echo "Happening type not defined (use -h)"
exit 1
fi

echo "bruh"
echo $happening

curl --verbose \
-X PUT \
-u "$user":"$secret" \
-H "Connection: close" \
-H "Content-Type: application/json" \
-d '{ "slug": "'"${slug}"'",
"spots": '"${spots}"',
"registrationDate": "'"${regdate}"'",
"minDegreeYear": "'"${mindeg}"'",
"maxDegreeYear": "'"${maxdeg}"'",
"type": "'"${happening}"'" }' \
"$host":"$port"/happening
Loading

0 comments on commit ed5b213

Please sign in to comment.