added tests
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 7s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 7s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Successful in 6s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 7s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 7s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Successful in 6s
This commit is contained in:
1 parent
07d3ad4585
commit
f2a11fa1db
4 files changed
+112
-5
No files matched your search
@@ -9,11 +9,13 @@ jobs:
|
||||
- name: prepare-container
|
||||
run: |
|
||||
echo "192.168.3.113 gitea.home.com" >> /etc/hosts && \
|
||||
apk add sqlite-dev
|
||||
apk add sqlite-dev bash
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Building binary with make
|
||||
run: make -j$(nproc)
|
||||
- name: Testing binary
|
||||
run: make test
|
||||
|
||||
Prepare-Build-Testing-With-CMake:
|
||||
runs-on: alpine-sdk
|
||||
@@ -21,7 +23,7 @@ jobs:
|
||||
- name: prepare-container
|
||||
run: |
|
||||
echo "192.168.3.113 gitea.home.com" >> /etc/hosts && \
|
||||
apk add cmake sqlite-dev
|
||||
apk add cmake sqlite-dev bash
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Building binary with CMake
|
||||
@@ -30,6 +32,9 @@ jobs:
|
||||
cd build && \
|
||||
cmake .. && \
|
||||
make -j$(nproc)
|
||||
- name: Testing binary
|
||||
run: |
|
||||
cd build && ../tests.sh
|
||||
|
||||
Prepare-Build-Testing-With-Meson:
|
||||
runs-on: alpine-sdk
|
||||
@@ -37,10 +42,13 @@ jobs:
|
||||
- name: prepare-container
|
||||
run: |
|
||||
echo "192.168.3.113 gitea.home.com" >> /etc/hosts && \
|
||||
apk add meson ninja cmake sqlite-dev
|
||||
apk add meson ninja cmake sqlite-dev bash
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Building binary with meson
|
||||
run: |
|
||||
meson setup build && \
|
||||
ninja -C build
|
||||
- name: Testing binary
|
||||
run: |
|
||||
cd build && ../tests.sh
|
||||
@@ -7,3 +7,4 @@ builddir
|
||||
auth_service
|
||||
users.db
|
||||
*.swp
|
||||
*.log
|
||||
@@ -9,7 +9,7 @@ TARGET = auth_service
|
||||
BUILD_DIR=./build
|
||||
CROSS_COMPILE =
|
||||
|
||||
all: $(TARGET)
|
||||
all: $(TARGET) test
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CROSS_COMPILE)$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
|
||||
@@ -18,4 +18,7 @@ $(TARGET): $(OBJS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
rm -f $(OBJS) $(TARGET) $(shell find . -type f -name '*.log') users.db
|
||||
|
||||
test: $(TARGET)
|
||||
bash ./tests.sh
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
|
||||
RESET="\033[0m"
|
||||
BWHITE="\033[1;37m"
|
||||
BLUE="\033[0;34m"
|
||||
GREEN="\033[0;32m"
|
||||
RED="\033[0;31m"
|
||||
YELLOW="\033[1;33m"
|
||||
CYAN="\033[0;36m"
|
||||
|
||||
./auth_service &> auth_service.log &
|
||||
sleep 0.1
|
||||
|
||||
# test /api/token
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token${RESET} "
|
||||
curl --silent -X POST -d '{"username":"tola","password":"2808"}' localhost:8222/api/token &> api_token_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_token_test.log)
|
||||
if [[ "$res" == *"token"* ]]; then
|
||||
printf "[$GREEN OK $RESET]\n"
|
||||
else
|
||||
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
|
||||
fi
|
||||
|
||||
# test /api/token/verify
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token/verify${RESET} "
|
||||
curl --silent -X POST -d '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"}' localhost:8222/api/token/verify &> api_token_verify_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_token_verify_test.log)
|
||||
if [[ "$res" == *'{"valid":"true"}'* ]]; then
|
||||
printf "[$GREEN OK $RESET]\n"
|
||||
else
|
||||
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
|
||||
fi
|
||||
|
||||
# test /api/users
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users${RESET} "
|
||||
curl --silent -X POST -d '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"}' localhost:8222/api/users &> api_users_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_users_test.log)
|
||||
if [[ "$res" == *'username'* ]]; then
|
||||
printf "[$GREEN OK $RESET]\n"
|
||||
else
|
||||
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
|
||||
fi
|
||||
|
||||
# test /api/users/user
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users/user${RESET} "
|
||||
curl --silent -X POST -d '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"}' localhost:8222/api/users/user &> api_users_user_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_users_user_test.log)
|
||||
if [[ "$res" == *'username'* ]]; then
|
||||
printf "[$GREEN OK $RESET]\n"
|
||||
else
|
||||
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
|
||||
fi
|
||||
|
||||
# test /api/register
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/register${RESET} "
|
||||
curl --silent -X POST -d '{
|
||||
"username":"asdf",
|
||||
"email":"asdf@asdf.com",
|
||||
"password":"asdf",
|
||||
"group":"users",
|
||||
"is_superuser":false
|
||||
}' localhost:8222/api/register &> api_register_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_register_test.log)
|
||||
if [[ "$res" == *'username'* ]]; then
|
||||
printf "[$GREEN OK $RESET]\n"
|
||||
else
|
||||
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
|
||||
fi
|
||||
|
||||
# test /api/users/add
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users/add${RESET} "
|
||||
curl --silent -X POST -d '{
|
||||
"username":"asdff",
|
||||
"email":"asdf@asdff.com",
|
||||
"password":"asdf",
|
||||
"group":"users",
|
||||
"is_superuser":false,
|
||||
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"
|
||||
}' localhost:8222/api/users/add &> api_users_add_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_users_add_test.log)
|
||||
if [[ "$res" == *'username'* ]]; then
|
||||
printf "[$GREEN OK $RESET]\n"
|
||||
else
|
||||
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
|
||||
fi
|
||||
|
||||
# test
|
||||
|
||||
killall auth_service
|
||||
Reference in new issue
Block a user