Compare commits
293 commits
mcaptcha-u
...
master
Author | SHA1 | Date | |
---|---|---|---|
c813819c4d | |||
|
1660c1033c | ||
b75db26783 | |||
|
820e1aa819 | ||
bba7e336dd | |||
|
c9f8b1d0bb | ||
8a1b4c4f9a | |||
|
f94dd07902 | ||
7c081e9e0c | |||
36d1bc7018 | |||
|
846bb4c0f6 | ||
2a3b118d0a | |||
687913aad4 | |||
657c78f6d7 | |||
52eb65e545 | |||
|
8d2d4b168b | ||
|
9dadb97ad0 | ||
|
c42e500c21 | ||
|
b93fd63ff2 | ||
|
75c26b8783 | ||
e7221e2595 | |||
ca2cc3c7ef | |||
|
7d953cd6ae | ||
|
c9c3666c8c | ||
92f57872ed | |||
b518ff1b53 | |||
22984a7a1e | |||
|
d97c45a12f | ||
|
2f9256c0bf | ||
|
19a6aac68a | ||
e304bc8a7d | |||
8bd0561c48 | |||
9ad6cdce87 | |||
|
6aa4958dfa | ||
|
06ccb1438e | ||
|
cdfea981b1 | ||
426b6a2e78 | |||
e7635c8ebf | |||
|
6680038ce6 | ||
|
fef5e21874 | ||
25f5683278 | |||
|
34b8c60553 | ||
0a9bbea35d | |||
|
5b88b3c3e4 | ||
ce0f375388 | |||
02329c694f | |||
|
910b95f853 | ||
|
55bd0c5684 | ||
7d34e25109 | |||
ac3dbd757c | |||
0bf415a7a4 | |||
|
9f16c7f33a | ||
|
24d656d384 | ||
|
734133246c | ||
e158480950 | |||
38e26ab078 | |||
9fa6faa315 | |||
948a475b35 | |||
a7d7707859 | |||
|
0a4b337acd | ||
|
388f9f86e6 | ||
|
75cb05f44a | ||
3435774235 | |||
634075240c | |||
193b9037b5 | |||
2d68b2d527 | |||
|
3dbe0f9ec0 | ||
|
c1db73984c | ||
|
1acd1ea9dc | ||
|
4c4c840a88 | ||
|
a8caa90f1e | ||
b0969f23be | |||
|
bc17778e3d | ||
d2b6843f32 | |||
|
1b3a38b9b2 | ||
7a61b93405 | |||
|
740034d469 | ||
67ff07ed12 | |||
|
f8a1754218 | ||
e02f8ab354 | |||
|
ff4a9c78d8 | ||
8e3a548f39 | |||
|
e8a55135ae | ||
90a07c7460 | |||
|
ffaed65744 | ||
8a3ab62126 | |||
4c79e6ce29 | |||
9c38283fc7 | |||
|
643b15fa84 | ||
|
2ade878fd6 | ||
|
c7c0eac818 | ||
780daffb6f | |||
|
dac0a91e98 | ||
f6af8dad1f | |||
|
a63ada21d9 | ||
029f286c50 | |||
|
50b76783e2 | ||
ef78076d26 | |||
|
df38dd1b7f | ||
2237463682 | |||
|
ffe68716cd | ||
4969f8b9bd | |||
|
bbd31726f6 | ||
fb9c2bf79b | |||
|
9aaf64a1cd | ||
75d30bbbfd | |||
d89f92fa61 | |||
5870ed74b3 | |||
|
442b891da3 | ||
|
adb11eb3a8 | ||
|
65ea05b085 | ||
945663a08b | |||
|
4ebbae064c | ||
20d6adee2c | |||
|
5d0c95520d | ||
6f7d959b01 | |||
|
09555eaa7e | ||
77360122c0 | |||
|
127053d0d4 | ||
e76bed7f17 | |||
5711c84386 | |||
|
901b8f52d8 | ||
e868ac0379 | |||
|
d2ad8bd7de | ||
444b675f22 | |||
|
81d00312ba | ||
67dc419eff | |||
|
b31177df45 | ||
|
a7b911abde | ||
b9e1e6a6df | |||
|
71c1e6969a | ||
b4143619b1 | |||
180754ca72 | |||
233a779e23 | |||
|
94e165c194 | ||
|
f329f75cdd | ||
|
b669887498 | ||
5b03f41e06 | |||
b75e9143eb | |||
a2766c4c57 | |||
|
bccf22ac63 | ||
|
fd22df83ba | ||
|
77731be1c7 | ||
0d4034d286 | |||
|
2dfc7fddd1 | ||
1e120ff30e | |||
a370faa3f7 | |||
7987576d43 | |||
|
0e5cedbe31 | ||
|
8b1ce6c2a7 | ||
|
775aa130f2 | ||
7fbd6f3dc4 | |||
|
87088e5352 | ||
354be7219d | |||
a8fec032c3 | |||
2d17a4e9af | |||
bfaf8dcbd5 | |||
899deadd7b | |||
59027f4e52 | |||
|
9e3da7f535 | ||
|
9630b0e960 | ||
|
873ce697e9 | ||
|
8d154dddbf | ||
|
42fb307332 | ||
|
7f04ea8392 | ||
884012970d | |||
48572b0a0e | |||
d8848e50d7 | |||
ce9fb50738 | |||
|
8580984e50 | ||
|
969be4993b | ||
|
000be3e63b | ||
|
058dda3d38 | ||
8b492cb55a | |||
55a250fd95 | |||
|
bfcf224172 | ||
|
09ae40ec5d | ||
6728e9c8c4 | |||
|
a7e86d10a7 | ||
1077812e63 | |||
|
18e148f354 | ||
324a1179bb | |||
|
16b049b0f6 | ||
ca76bf9caf | |||
e8e9fb6392 | |||
|
775aff77a4 | ||
|
27054b9025 | ||
0fbf91200e | |||
|
ecdfcf110d | ||
bbba3f8d97 | |||
|
f76073dacf | ||
2b85036aa6 | |||
|
c1878ed382 | ||
3115eeedee | |||
c811e77bd7 | |||
9524a9fd15 | |||
|
05f27518d4 | ||
|
3e7de1d759 | ||
|
e12a802619 | ||
a19795a340 | |||
64554b057c | |||
a83cc9b05e | |||
3678fca26a | |||
|
e2df341f19 | ||
|
49afa8c94b | ||
98220fcbc8 | |||
89e2f00382 | |||
518a5d58cb | |||
|
e0b777bc04 | ||
b2a06a4883 | |||
cd81262f69 | |||
316cc0589a | |||
3b3dc7b346 | |||
|
cad1334fe4 | ||
|
416fff2227 | ||
|
4b1e58456d | ||
|
d937fe257f | ||
|
b74b069727 | ||
|
ba89f7f378 | ||
|
3dec37e8b8 | ||
|
8da9c17714 | ||
648424fdf3 | |||
c066d42272 | |||
bb9e8bae33 | |||
acd1dddcf4 | |||
8e129c64d9 | |||
37fc8897af | |||
858fae15f6 | |||
8c3fe53071 | |||
bacacdd192 | |||
1d7c8640de | |||
a561059cce | |||
0e08bb1b77 | |||
|
eb98fea3b0 | ||
290f6c5cc1 | |||
bbf64ba1fb | |||
|
6e6b814b86 | ||
|
171718b788 | ||
|
f30463b0ac | ||
6e68747978 | |||
ab2915ece1 | |||
|
f00aba852c | ||
|
38b73dac8c | ||
|
4f53b67d9b | ||
|
9e7b1740f4 | ||
|
06a5669157 | ||
|
dcd6e5619b | ||
|
0737797c26 | ||
|
5630b2e41c | ||
|
18d59fc61b | ||
|
da0ce2c61b | ||
|
c421692595 | ||
|
d54c238529 | ||
dade31ba60 | |||
af79e82881 | |||
3a619a681d | |||
|
48186185c5 | ||
|
0efb1b7555 | ||
|
d15589d118 | ||
88136c8ab5 | |||
2685fdbe0e | |||
9192b32904 | |||
ed190a9f1a | |||
d44e982acd | |||
9d212797d5 | |||
d2651f0800 | |||
5cb3bcdca5 | |||
21e89209a1 | |||
39011330f3 | |||
|
d94d6d7717 | ||
|
84a8a4331c | ||
|
aad5797299 | ||
|
bcc489c577 | ||
|
79cdf68b8f | ||
|
07910c1190 | ||
|
86b044703c | ||
|
253aaf4542 | ||
|
34a203ec49 | ||
|
f46d680405 | ||
5ffbed57e0 | |||
|
711cdd64d2 | ||
ab2f2c0a90 | |||
ba379f1999 | |||
0ba21e184d | |||
abf4ded284 | |||
cfc459dde1 | |||
ae1bc888f3 | |||
3ba7b591f5 | |||
b48cc8ffc7 | |||
76075099be | |||
241ccab5fc | |||
802bf71325 | |||
2879a4da01 |
68 changed files with 7937 additions and 7693 deletions
2
.github/workflows/linux.yml
vendored
2
.github/workflows/linux.yml
vendored
|
@ -84,7 +84,7 @@ jobs:
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
if: matrix.version == 'stable' && (github.repository == 'mcapthca/survey')
|
if: matrix.version == 'stable' && (github.repository == 'mcapthca/survey')
|
||||||
uses: JamesIves/github-pages-deploy-action@3.7.1
|
uses: JamesIves/github-pages-deploy-action@v4.6.4
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
BRANCH: gh-pages
|
BRANCH: gh-pages
|
||||||
|
|
23
.sqlx/query-52c16c2c0759140af6348ef7de56b74151a20532ceebc8ee41d079decee3acb5.json
generated
Normal file
23
.sqlx/query-52c16c2c0759140af6348ef7de56b74151a20532ceebc8ee41d079decee3acb5.json
generated
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "SELECT\n difficulty\n FROM\n survey_benches\n WHERE\n duration <= $1\n ORDER BY difficulty ASC LIMIT 1 OFFSET $2;",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "difficulty",
|
||||||
|
"type_info": "Int4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Float4",
|
||||||
|
"Int8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "52c16c2c0759140af6348ef7de56b74151a20532ceebc8ee41d079decee3acb5"
|
||||||
|
}
|
22
.sqlx/query-63370a30a4ff6d31292a3cb632c66184ccff75583e21df5ddf5e8872f710d3d2.json
generated
Normal file
22
.sqlx/query-63370a30a4ff6d31292a3cb632c66184ccff75583e21df5ddf5e8872f710d3d2.json
generated
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "SELECT COUNT(difficulty) FROM survey_benches WHERE duration <= $1;",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "count",
|
||||||
|
"type_info": "Int8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Float4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
null
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "63370a30a4ff6d31292a3cb632c66184ccff75583e21df5ddf5e8872f710d3d2"
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ pipeline:
|
||||||
- COMPILED_DATE=2021-07-21
|
- COMPILED_DATE=2021-07-21
|
||||||
commands:
|
commands:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install -y ca-certificates curl gnupg tar wget
|
- apt-get install -y ca-certificates curl gnupg tar wget libssl-dev
|
||||||
- mkdir -p /etc/apt/keyrings
|
- mkdir -p /etc/apt/keyrings
|
||||||
- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
||||||
- NODE_MAJOR=18 echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
- NODE_MAJOR=18 echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
||||||
|
|
1260
Cargo.lock
generated
1260
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
18
Cargo.toml
18
Cargo.toml
|
@ -24,10 +24,10 @@ path = "./src/tests-migrate.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.3"
|
actix-web = "4.3"
|
||||||
actix-identity = "0.4.0"
|
actix-identity = "0.4.0"
|
||||||
actix-session = { version = "0.6.1", features = ["cookie-session"]}
|
actix-session = { version = "0.10.0", features = ["cookie-session"]}
|
||||||
actix-http = "3.0.4"
|
actix-http = "3.0.4"
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
actix-cors = "0.6.1"
|
actix-cors = "0.7.0"
|
||||||
actix-files = "0.6.0"
|
actix-files = "0.6.0"
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
#actix = "0.12"
|
#actix = "0.12"
|
||||||
|
@ -37,16 +37,16 @@ actix-web-codegen-const-routes = "0.2.0"
|
||||||
|
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
|
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time", "uuid" ] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "postgres", "time", "uuid" ] }
|
||||||
|
|
||||||
#argon2-creds = "0.2.3"
|
#argon2-creds = "0.2.3"
|
||||||
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
||||||
|
|
||||||
derive_builder = "0.11"
|
derive_builder = "0.20"
|
||||||
validator = { version = "0.14", features = ["derive"]}
|
validator = { version = "0.18", features = ["derive"]}
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
|
|
||||||
config = "0.13"
|
config = "0.14"
|
||||||
|
|
||||||
serde = "1"
|
serde = "1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
@ -62,7 +62,7 @@ rand = "0.8"
|
||||||
uuid = { version = "1.4.1", features = ["v4", "serde"] }
|
uuid = { version = "1.4.1", features = ["v4", "serde"] }
|
||||||
|
|
||||||
mime_guess = "2.0.3"
|
mime_guess = "2.0.3"
|
||||||
rust-embed = "6.0.0"
|
rust-embed = "8.0.0"
|
||||||
#libcachebust = "0.3.0"
|
#libcachebust = "0.3.0"
|
||||||
cache-buster = { git = "https://github.com/realaravinth/cache-buster" }
|
cache-buster = { git = "https://github.com/realaravinth/cache-buster" }
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
|
@ -73,7 +73,7 @@ tera = { version="1.17.1", features=["builtins"]}
|
||||||
tokio = { version = "1.25.0", features = ["fs", "macros"] }
|
tokio = { version = "1.25.0", features = ["fs", "macros"] }
|
||||||
csv-async = { version = "1.2.5", features = ["serde", "tokio"] }
|
csv-async = { version = "1.2.5", features = ["serde", "tokio"] }
|
||||||
async-trait = "0.1.68"
|
async-trait = "0.1.68"
|
||||||
reqwest = { version = "0.11.18", features = ["json", "gzip"] }
|
reqwest = { version = "0.12.0", features = ["json", "gzip", "native-tls-vendored"] }
|
||||||
|
|
||||||
#tokio = "1.11.0"
|
#tokio = "1.11.0"
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ version = "0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
#serde_yaml = "0.8.17"
|
#serde_yaml = "0.8.17"
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "uuid", "postgres", "time"] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "uuid", "postgres", "time"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
cache-buster = { version = "0.2.0", git = "https://github.com/realaravinth/cache-buster" }
|
cache-buster = { version = "0.2.0", git = "https://github.com/realaravinth/cache-buster" }
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM node:18-bookworm-slim as frontend
|
FROM node:20-bookworm-slim as frontend
|
||||||
LABEL org.opencontainers.image.source https://github.com/mCaptcha/survey
|
LABEL org.opencontainers.image.source https://github.com/mCaptcha/survey
|
||||||
RUN apt-get update && apt-get install -y make
|
RUN apt-get update && apt-get install -y make
|
||||||
COPY package.json yarn.lock /src/
|
COPY package.json yarn.lock /src/
|
||||||
|
@ -8,14 +8,14 @@ RUN yarn install
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make frontend
|
RUN make frontend
|
||||||
|
|
||||||
FROM rust:1-slim-bookworm as rust
|
FROM rust:latest as rust
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN apt-get update && apt-get install -y git
|
RUN apt-get update && apt-get install -y git libssl-dev
|
||||||
COPY . /src
|
COPY . /src
|
||||||
COPY --from=frontend /src/static/cache/bundle /src/static/cache/bundle
|
COPY --from=frontend /src/static/cache/bundle /src/static/cache/bundle
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm
|
||||||
RUN useradd -ms /bin/bash -u 1001 mcaptcha-survey
|
RUN useradd -ms /bin/bash -u 1001 mcaptcha-survey
|
||||||
WORKDIR /home/mcaptcha-survey
|
WORKDIR /home/mcaptcha-survey
|
||||||
COPY --from=rust /src/target/release/survey /usr/local/bin/
|
COPY --from=rust /src/target/release/survey /usr/local/bin/
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -49,7 +49,7 @@ doc: ## Prepare documentation
|
||||||
cargo doc --no-deps --workspace --all-features
|
cargo doc --no-deps --workspace --all-features
|
||||||
|
|
||||||
docker: ## Build docker images
|
docker: ## Build docker images
|
||||||
docker build -t mcaptcha/survey:master -t mcaptcha/survey:latest .
|
docker buildx build -t mcaptcha/survey:master -t mcaptcha/survey:latest . --load
|
||||||
|
|
||||||
docker-publish: docker ## Build and publish docker images
|
docker-publish: docker ## Build and publish docker images
|
||||||
docker push mcaptcha/survey:master
|
docker push mcaptcha/survey:master
|
||||||
|
|
|
@ -10,7 +10,7 @@ services:
|
||||||
RUST_LOG: debug
|
RUST_LOG: debug
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:13.2
|
image: postgres:16.4
|
||||||
volumes:
|
volumes:
|
||||||
- mcaptcha-survey-data:/var/lib/postgresql/
|
- mcaptcha-survey-data:/var/lib/postgresql/
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
--
|
||||||
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS survey_users (
|
CREATE TABLE IF NOT EXISTS survey_users (
|
||||||
ID UUID PRIMARY KEY NOT NULL UNIQUE,
|
ID UUID PRIMARY KEY NOT NULL UNIQUE,
|
||||||
created_at TIMESTAMPTZ NOT NULL
|
created_at TIMESTAMPTZ NOT NULL
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
--
|
||||||
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
-- Add migration script here
|
-- Add migration script here
|
||||||
CREATE TABLE IF NOT EXISTS survey_admins (
|
CREATE TABLE IF NOT EXISTS survey_admins (
|
||||||
name VARCHAR(100) NOT NULL UNIQUE,
|
name VARCHAR(100) NOT NULL UNIQUE,
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
|
-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
--
|
||||||
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
ALTER TABLE survey_responses
|
ALTER TABLE survey_responses
|
||||||
ADD COLUMN submitted_at TIMESTAMPTZ NOT NULL DEFAULT now();
|
ADD COLUMN submitted_at TIMESTAMPTZ NOT NULL DEFAULT now();
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
--
|
||||||
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS survey_bench_type (
|
CREATE TABLE IF NOT EXISTS survey_bench_type (
|
||||||
name VARCHAR(30) UNIQUE NOT NULL,
|
name VARCHAR(30) UNIQUE NOT NULL,
|
||||||
ID SERIAL PRIMARY KEY NOT NULL
|
ID SERIAL PRIMARY KEY NOT NULL
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
--
|
||||||
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS survey_mcaptcha_hostname (
|
CREATE TABLE IF NOT EXISTS survey_mcaptcha_hostname (
|
||||||
url VARCHAR(3000) UNIQUE NOT NULL,
|
url VARCHAR(3000) UNIQUE NOT NULL,
|
||||||
secret VARCHAR(100) UNIQUE NOT NULL,
|
secret VARCHAR(100) UNIQUE NOT NULL,
|
||||||
|
|
8920
package-lock.json
generated
8920
package-lock.json
generated
File diff suppressed because it is too large
Load diff
28
package.json
28
package.json
|
@ -10,26 +10,26 @@
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^29.0.0",
|
||||||
"@types/jsdom": "^16.2.10",
|
"@types/jsdom": "^21.0.0",
|
||||||
"@types/node": "^16.10.5",
|
"@types/node": "^20.0.0",
|
||||||
"@types/sinon": "^10.0.0",
|
"@types/sinon": "^17.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||||
"@typescript-eslint/parser": "^5.0.0",
|
"@typescript-eslint/parser": "^8.0.0",
|
||||||
"@wasm-tool/wasm-pack-plugin": "^1.6.0",
|
"@wasm-tool/wasm-pack-plugin": "^1.6.0",
|
||||||
"dart-sass": "^1.25.0",
|
"dart-sass": "^1.25.0",
|
||||||
"eslint": "^8.0.1",
|
"eslint": "^9.0.0",
|
||||||
"jest": "^27.2.5",
|
"jest": "^29.0.0",
|
||||||
"jest-fetch-mock": "^3.0.3",
|
"jest-fetch-mock": "^3.0.3",
|
||||||
"jsdom": "^18.0.0",
|
"jsdom": "^25.0.0",
|
||||||
"sinon": "^11.1.2",
|
"sinon": "^19.0.0",
|
||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^29.0.0",
|
||||||
"ts-loader": "^9.2.6",
|
"ts-loader": "^9.2.6",
|
||||||
"ts-node": "^10.3.0",
|
"ts-node": "^10.3.0",
|
||||||
"typescript": "^4.4.4",
|
"typescript": "^5.0.0",
|
||||||
"webpack": "^5.0.0",
|
"webpack": "^5.0.0",
|
||||||
"webpack-cli": "^4.6.0",
|
"webpack-cli": "^5.0.0",
|
||||||
"webpack-dev-server": "^4.3.1"
|
"webpack-dev-server": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mcaptcha/vanilla-glue": "^0.1.0-alpha-3",
|
"@mcaptcha/vanilla-glue": "^0.1.0-alpha-3",
|
||||||
|
|
21
renovate.json
Normal file
21
renovate.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:recommended",
|
||||||
|
":dependencyDashboard"
|
||||||
|
],
|
||||||
|
"labels": [
|
||||||
|
"renovate-bot"
|
||||||
|
],
|
||||||
|
"prHourlyLimit": 0,
|
||||||
|
"timezone": "Asia/kolkata",
|
||||||
|
"prCreation": "immediate",
|
||||||
|
"vulnerabilityAlerts": {
|
||||||
|
"enabled": true,
|
||||||
|
"labels": [
|
||||||
|
"renovate-bot",
|
||||||
|
"renovate-security",
|
||||||
|
"security"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,18 +1,6 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
pub mod v1;
|
pub mod v1;
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
use argon2_creds::Config;
|
use argon2_creds::Config;
|
||||||
|
@ -126,12 +115,12 @@ mod tests {
|
||||||
const PASSWORD: &str = "longpassword2";
|
const PASSWORD: &str = "longpassword2";
|
||||||
const EMAIL: &str = "updatepassuser@a.com";
|
const EMAIL: &str = "updatepassuser@a.com";
|
||||||
|
|
||||||
|
let data = get_test_data().await;
|
||||||
{
|
{
|
||||||
let data = get_test_data().await;
|
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (data, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
@ -164,6 +153,7 @@ mod tests {
|
||||||
};
|
};
|
||||||
|
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
new_password,
|
new_password,
|
||||||
ROUTES.admin.account.update_password,
|
ROUTES.admin.account.update_password,
|
||||||
|
@ -179,6 +169,7 @@ mod tests {
|
||||||
};
|
};
|
||||||
|
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
new_password,
|
new_password,
|
||||||
ROUTES.admin.account.update_password,
|
ROUTES.admin.account.update_password,
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
|
@ -34,12 +22,12 @@ async fn uname_email_exists_works() {
|
||||||
const PASSWORD: &str = "longpassword2";
|
const PASSWORD: &str = "longpassword2";
|
||||||
const EMAIL: &str = "testuserexists@a.com2";
|
const EMAIL: &str = "testuserexists@a.com2";
|
||||||
|
|
||||||
|
let data = get_test_data().await;
|
||||||
{
|
{
|
||||||
let data = get_test_data().await;
|
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (data, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
@ -124,14 +112,14 @@ async fn email_udpate_password_validation_del_userworks() {
|
||||||
const NAME2: &str = "eupdauser";
|
const NAME2: &str = "eupdauser";
|
||||||
const EMAIL2: &str = "eupdauser@a.com";
|
const EMAIL2: &str = "eupdauser@a.com";
|
||||||
|
|
||||||
|
let data = get_test_data().await;
|
||||||
{
|
{
|
||||||
let data = get_test_data().await;
|
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
delete_user(NAME2, &data).await;
|
delete_user(NAME2, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = register_and_signin(NAME2, EMAIL2, PASSWORD).await;
|
let _ = register_and_signin(&data, NAME2, EMAIL2, PASSWORD).await;
|
||||||
let (data, _creds, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_creds, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
@ -152,6 +140,7 @@ async fn email_udpate_password_validation_del_userworks() {
|
||||||
// check duplicate email while duplicate email
|
// check duplicate email while duplicate email
|
||||||
email_payload.email = EMAIL2.into();
|
email_payload.email = EMAIL2.into();
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.account.update_email,
|
ROUTES.admin.account.update_email,
|
||||||
|
@ -165,6 +154,7 @@ async fn email_udpate_password_validation_del_userworks() {
|
||||||
password: NAME.into(),
|
password: NAME.into(),
|
||||||
};
|
};
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.account.delete,
|
ROUTES.admin.account.delete,
|
||||||
|
@ -207,9 +197,8 @@ async fn username_update_works() {
|
||||||
const NAME2: &str = "terstusrtds";
|
const NAME2: &str = "terstusrtds";
|
||||||
const NAME_CHANGE: &str = "terstusrtdsxx";
|
const NAME_CHANGE: &str = "terstusrtdsxx";
|
||||||
|
|
||||||
|
let data = get_test_data().await;
|
||||||
{
|
{
|
||||||
let data = get_test_data().await;
|
|
||||||
|
|
||||||
futures::join!(
|
futures::join!(
|
||||||
delete_user(NAME, &data),
|
delete_user(NAME, &data),
|
||||||
delete_user(NAME2, &data),
|
delete_user(NAME2, &data),
|
||||||
|
@ -217,8 +206,8 @@ async fn username_update_works() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = register_and_signin(NAME2, EMAIL2, PASSWORD).await;
|
let _ = register_and_signin(&data, NAME2, EMAIL2, PASSWORD).await;
|
||||||
let (data, _creds, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_creds, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
@ -238,6 +227,7 @@ async fn username_update_works() {
|
||||||
// check duplicate username with duplicate username
|
// check duplicate username with duplicate username
|
||||||
username_udpate.username = NAME2.into();
|
username_udpate.username = NAME2.into();
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME_CHANGE,
|
NAME_CHANGE,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.account.update_username,
|
ROUTES.admin.account.update_username,
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::http::header;
|
use actix_web::http::header;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
|
@ -585,13 +574,13 @@ mod tests {
|
||||||
const DEVICE_SOFTWARE_RECOGNISED: &str = "Foobar.v2";
|
const DEVICE_SOFTWARE_RECOGNISED: &str = "Foobar.v2";
|
||||||
const THREADS: i32 = 4;
|
const THREADS: i32 = 4;
|
||||||
|
|
||||||
|
let data = get_test_data().await;
|
||||||
{
|
{
|
||||||
let data = get_test_data().await;
|
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (data, _creds, signin_resp) =
|
let (_creds, signin_resp) =
|
||||||
register_and_signin(NAME, EMAIL, PASSWORD).await;
|
register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let survey = get_survey_user(data.clone()).await;
|
let survey = get_survey_user(data.clone()).await;
|
||||||
let survey_cookie = get_cookie!(survey);
|
let survey_cookie = get_cookie!(survey);
|
||||||
|
@ -682,6 +671,7 @@ mod tests {
|
||||||
assert_eq!(responses, res);
|
assert_eq!(responses, res);
|
||||||
|
|
||||||
bad_post_req_test_witout_payload(
|
bad_post_req_test_witout_payload(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
&V1_API_ROUTES.admin.campaign.delete.replace("{uuid}", NAME),
|
&V1_API_ROUTES.admin.campaign.delete.replace("{uuid}", NAME),
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_auth_middleware::*;
|
use actix_auth_middleware::*;
|
||||||
use actix_web::web::ServiceConfig;
|
use actix_web::web::ServiceConfig;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use actix_web::http::{header, StatusCode};
|
use actix_web::http::{header, StatusCode};
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
|
@ -53,11 +41,11 @@ async fn auth_works() {
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
|
|
||||||
// 1. Register and signin
|
// 1. Register and signin
|
||||||
let (_, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
|
|
||||||
// Sign in with email
|
// Sign in with email
|
||||||
signin(EMAIL, PASSWORD).await;
|
signin(&data, EMAIL, PASSWORD).await;
|
||||||
|
|
||||||
// 2. check if duplicate username is allowed
|
// 2. check if duplicate username is allowed
|
||||||
let mut msg = Register {
|
let mut msg = Register {
|
||||||
|
@ -67,6 +55,7 @@ async fn auth_works() {
|
||||||
email: Some(EMAIL.into()),
|
email: Some(EMAIL.into()),
|
||||||
};
|
};
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.auth.register,
|
ROUTES.admin.auth.register,
|
||||||
|
@ -78,6 +67,7 @@ async fn auth_works() {
|
||||||
let name = format!("{}dupemail", NAME);
|
let name = format!("{}dupemail", NAME);
|
||||||
msg.username = name;
|
msg.username = name;
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.auth.register,
|
ROUTES.admin.auth.register,
|
||||||
|
@ -92,6 +82,7 @@ async fn auth_works() {
|
||||||
password: msg.password.clone(),
|
password: msg.password.clone(),
|
||||||
};
|
};
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.auth.login,
|
ROUTES.admin.auth.login,
|
||||||
|
@ -102,6 +93,7 @@ async fn auth_works() {
|
||||||
|
|
||||||
creds.login = "nonexistantuser@example.com".into();
|
creds.login = "nonexistantuser@example.com".into();
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.auth.login,
|
ROUTES.admin.auth.login,
|
||||||
|
@ -115,6 +107,7 @@ async fn auth_works() {
|
||||||
creds.password = NAME.into();
|
creds.password = NAME.into();
|
||||||
|
|
||||||
bad_post_req_test(
|
bad_post_req_test(
|
||||||
|
&data,
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
ROUTES.admin.auth.login,
|
ROUTES.admin.auth.login,
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
mod auth;
|
mod auth;
|
||||||
mod protected;
|
mod protected;
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
|
@ -29,13 +17,13 @@ async fn protected_routes_work() {
|
||||||
const EMAIL: &str = "testuser119@a.com2";
|
const EMAIL: &str = "testuser119@a.com2";
|
||||||
|
|
||||||
let get_protected_urls = [V1_API_ROUTES.admin.auth.logout];
|
let get_protected_urls = [V1_API_ROUTES.admin.auth.logout];
|
||||||
|
let data = get_test_data().await;
|
||||||
|
|
||||||
{
|
{
|
||||||
let data = get_test_data().await;
|
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (data, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_web::web::ServiceConfig;
|
use actix_web::web::ServiceConfig;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_web::web::ServiceConfig;
|
use actix_web::web::ServiceConfig;
|
||||||
|
|
||||||
pub mod db;
|
pub mod db;
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_web::web::ServiceConfig;
|
use actix_web::web::ServiceConfig;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::types::Uuid;
|
use sqlx::types::Uuid;
|
||||||
|
@ -23,6 +12,7 @@ pub mod bench;
|
||||||
pub mod mcaptcha;
|
pub mod mcaptcha;
|
||||||
mod meta;
|
mod meta;
|
||||||
pub mod routes;
|
pub mod routes;
|
||||||
|
pub mod stats;
|
||||||
pub use routes::ROUTES;
|
pub use routes::ROUTES;
|
||||||
|
|
||||||
pub fn services(cfg: &mut ServiceConfig) {
|
pub fn services(cfg: &mut ServiceConfig) {
|
||||||
|
@ -30,6 +20,7 @@ pub fn services(cfg: &mut ServiceConfig) {
|
||||||
bench::services(cfg);
|
bench::services(cfg);
|
||||||
admin::services(cfg);
|
admin::services(cfg);
|
||||||
mcaptcha::services(cfg);
|
mcaptcha::services(cfg);
|
||||||
|
stats::services(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_random(len: usize) -> String {
|
pub fn get_random(len: usize) -> String {
|
||||||
|
|
|
@ -1,25 +1,15 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::admin::routes::Admin;
|
use super::admin::routes::Admin;
|
||||||
use super::bench::routes::Benches;
|
use super::bench::routes::Benches;
|
||||||
use super::mcaptcha::routes::Mcaptcha;
|
use super::mcaptcha::routes::Mcaptcha;
|
||||||
use super::meta::routes::Meta;
|
use super::meta::routes::Meta;
|
||||||
|
use super::stats::routes::Stats;
|
||||||
|
|
||||||
pub const ROUTES: Routes = Routes::new();
|
pub const ROUTES: Routes = Routes::new();
|
||||||
|
|
||||||
|
@ -29,6 +19,7 @@ pub struct Routes {
|
||||||
pub meta: Meta,
|
pub meta: Meta,
|
||||||
pub benches: Benches,
|
pub benches: Benches,
|
||||||
pub mcaptcha: Mcaptcha,
|
pub mcaptcha: Mcaptcha,
|
||||||
|
pub stats: Stats,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Routes {
|
impl Routes {
|
||||||
|
@ -38,6 +29,7 @@ impl Routes {
|
||||||
meta: Meta::new(),
|
meta: Meta::new(),
|
||||||
benches: Benches::new(),
|
benches: Benches::new(),
|
||||||
mcaptcha: Mcaptcha::new(),
|
mcaptcha: Mcaptcha::new(),
|
||||||
|
stats: Stats::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
256
src/api/v1/stats.rs
Normal file
256
src/api/v1/stats.rs
Normal file
|
@ -0,0 +1,256 @@
|
||||||
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::errors::*;
|
||||||
|
use crate::AppData;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Builder, Serialize)]
|
||||||
|
pub struct BuildDetails {
|
||||||
|
pub version: &'static str,
|
||||||
|
pub git_commit_hash: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod routes {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Stats {
|
||||||
|
pub percentile_benches: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Stats {
|
||||||
|
pub const fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
percentile_benches: "/api/v1/stats/benches/percentile",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get difficulty factor with max time limit for percentile of stats
|
||||||
|
#[actix_web_codegen_const_routes::post(
|
||||||
|
path = "crate::V1_API_ROUTES.stats.percentile_benches"
|
||||||
|
)]
|
||||||
|
async fn percentile_benches(
|
||||||
|
data: AppData,
|
||||||
|
payload: web::Json<PercentileReq>,
|
||||||
|
) -> ServiceResult<impl Responder> {
|
||||||
|
struct Count {
|
||||||
|
count: Option<i64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = sqlx::query_as!(
|
||||||
|
Count,
|
||||||
|
"SELECT COUNT(difficulty) FROM survey_benches WHERE duration <= $1;",
|
||||||
|
payload.time as f32
|
||||||
|
)
|
||||||
|
.fetch_one(&data.db)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if count.count.is_none() {
|
||||||
|
return Ok(HttpResponse::Ok().json(PercentileResp {
|
||||||
|
difficulty_factor: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = count.count.unwrap();
|
||||||
|
|
||||||
|
if count < 2 {
|
||||||
|
return Ok(HttpResponse::Ok().json(PercentileResp {
|
||||||
|
difficulty_factor: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
let location = ((count - 1) as f64 * (payload.percentile / 100.00)) + 1.00;
|
||||||
|
let fraction = location - location.floor();
|
||||||
|
|
||||||
|
async fn get_data_at_location(
|
||||||
|
data: &crate::Data,
|
||||||
|
time: u32,
|
||||||
|
location: i64,
|
||||||
|
) -> ServiceResult<Option<u32>> {
|
||||||
|
struct Difficulty {
|
||||||
|
difficulty: Option<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
match sqlx::query_as!(
|
||||||
|
Difficulty,
|
||||||
|
"SELECT
|
||||||
|
difficulty
|
||||||
|
FROM
|
||||||
|
survey_benches
|
||||||
|
WHERE
|
||||||
|
duration <= $1
|
||||||
|
ORDER BY difficulty ASC LIMIT 1 OFFSET $2;",
|
||||||
|
time as f32,
|
||||||
|
location as i64 - 1,
|
||||||
|
)
|
||||||
|
.fetch_one(&data.db)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(res) => Ok(Some(res.difficulty.unwrap() as u32)),
|
||||||
|
Err(sqlx::Error::RowNotFound) => Ok(None),
|
||||||
|
Err(e) => Err(e.into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if fraction > 0.00 {
|
||||||
|
if let (Some(base), Some(ceiling)) = (
|
||||||
|
get_data_at_location(&data, payload.time, location.floor() as i64).await?,
|
||||||
|
get_data_at_location(&data, payload.time, location.floor() as i64 + 1)
|
||||||
|
.await?,
|
||||||
|
) {
|
||||||
|
let res = base as u32 + ((ceiling - base) as f64 * fraction).floor() as u32;
|
||||||
|
|
||||||
|
return Ok(HttpResponse::Ok().json(PercentileResp {
|
||||||
|
difficulty_factor: Some(res),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let Some(base) =
|
||||||
|
get_data_at_location(&data, payload.time, location.floor() as i64).await?
|
||||||
|
{
|
||||||
|
let res = base as u32;
|
||||||
|
|
||||||
|
return Ok(HttpResponse::Ok().json(PercentileResp {
|
||||||
|
difficulty_factor: Some(res),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Ok(HttpResponse::Ok().json(PercentileResp {
|
||||||
|
difficulty_factor: None,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Builder, Serialize)]
|
||||||
|
/// Health check return datatype
|
||||||
|
pub struct PercentileReq {
|
||||||
|
time: u32,
|
||||||
|
percentile: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Builder, Serialize)]
|
||||||
|
/// Health check return datatype
|
||||||
|
pub struct PercentileResp {
|
||||||
|
difficulty_factor: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(percentile_benches);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use actix_web::{http::StatusCode, test, App};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use crate::api::v1::services;
|
||||||
|
use crate::tests::get_test_data;
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn stats_bench_work() {
|
||||||
|
use crate::tests::*;
|
||||||
|
|
||||||
|
const NAME: &str = "benchstatsuesr";
|
||||||
|
const EMAIL: &str = "benchstatsuesr@testadminuser.com";
|
||||||
|
const PASSWORD: &str = "longpassword2";
|
||||||
|
|
||||||
|
const DEVICE_USER_PROVIDED: &str = "foo";
|
||||||
|
const DEVICE_SOFTWARE_RECOGNISED: &str = "Foobar.v2";
|
||||||
|
const THREADS: i32 = 4;
|
||||||
|
|
||||||
|
let data = get_test_data().await;
|
||||||
|
{
|
||||||
|
delete_user(NAME, &data).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
let (creds, signin_resp) =
|
||||||
|
register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
|
let cookies = get_cookie!(signin_resp);
|
||||||
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
let survey = get_survey_user(data.clone()).await;
|
||||||
|
let survey_cookie = get_cookie!(survey);
|
||||||
|
let campaign = create_new_campaign(NAME, data.clone(), cookies.clone()).await;
|
||||||
|
let campaign_config =
|
||||||
|
get_campaign_config(&campaign, data.clone(), survey_cookie.clone()).await;
|
||||||
|
|
||||||
|
assert_eq!(DIFFICULTIES.to_vec(), campaign_config.difficulties);
|
||||||
|
|
||||||
|
let submit_payload = crate::api::v1::bench::Submission {
|
||||||
|
device_user_provided: DEVICE_USER_PROVIDED.into(),
|
||||||
|
device_software_recognised: DEVICE_SOFTWARE_RECOGNISED.into(),
|
||||||
|
threads: THREADS,
|
||||||
|
benches: BENCHES.clone(),
|
||||||
|
submission_type: crate::api::v1::bench::SubmissionType::Wasm,
|
||||||
|
};
|
||||||
|
|
||||||
|
submit_bench(&submit_payload, &campaign, survey_cookie, data.clone()).await;
|
||||||
|
|
||||||
|
let msg = PercentileReq {
|
||||||
|
time: 1,
|
||||||
|
percentile: 99.00,
|
||||||
|
};
|
||||||
|
let resp = test::call_service(
|
||||||
|
&app,
|
||||||
|
post_request!(&msg, V1_API_ROUTES.stats.percentile_benches).to_request(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
let resp: PercentileResp = test::read_body_json(resp).await;
|
||||||
|
|
||||||
|
assert!(resp.difficulty_factor.is_none());
|
||||||
|
|
||||||
|
let msg = PercentileReq {
|
||||||
|
time: 1,
|
||||||
|
percentile: 100.00,
|
||||||
|
};
|
||||||
|
|
||||||
|
let resp = test::call_service(
|
||||||
|
&app,
|
||||||
|
post_request!(&msg, V1_API_ROUTES.stats.percentile_benches).to_request(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
let resp: PercentileResp = test::read_body_json(resp).await;
|
||||||
|
|
||||||
|
assert!(resp.difficulty_factor.is_none());
|
||||||
|
|
||||||
|
let msg = PercentileReq {
|
||||||
|
time: 2,
|
||||||
|
percentile: 100.00,
|
||||||
|
};
|
||||||
|
|
||||||
|
let resp = test::call_service(
|
||||||
|
&app,
|
||||||
|
post_request!(&msg, V1_API_ROUTES.stats.percentile_benches).to_request(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
let resp: PercentileResp = test::read_body_json(resp).await;
|
||||||
|
|
||||||
|
assert_eq!(resp.difficulty_factor.unwrap(), 2);
|
||||||
|
|
||||||
|
let msg = PercentileReq {
|
||||||
|
time: 5,
|
||||||
|
percentile: 90.00,
|
||||||
|
};
|
||||||
|
|
||||||
|
let resp = test::call_service(
|
||||||
|
&app,
|
||||||
|
post_request!(&msg, V1_API_ROUTES.stats.percentile_benches).to_request(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
let resp: PercentileResp = test::read_body_json(resp).await;
|
||||||
|
|
||||||
|
assert_eq!(resp.difficulty_factor.unwrap(), 4);
|
||||||
|
delete_user(NAME, &data).await;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -349,8 +338,8 @@ mod tests {
|
||||||
const DEVICE_SOFTWARE_RECOGNISED: &str = "Foobar.v2";
|
const DEVICE_SOFTWARE_RECOGNISED: &str = "Foobar.v2";
|
||||||
const THREADS: i32 = 4;
|
const THREADS: i32 = 4;
|
||||||
|
|
||||||
|
let data = get_test_data().await;
|
||||||
{
|
{
|
||||||
let data = get_test_data().await;
|
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,8 +348,8 @@ mod tests {
|
||||||
//self.write_campaign_file(&campaign, &archive).await?;
|
//self.write_campaign_file(&campaign, &archive).await?;
|
||||||
//self.write_benchmark_file(&campaign, &archive, data).await?;
|
//self.write_benchmark_file(&campaign, &archive, data).await?;
|
||||||
|
|
||||||
let (data, _creds, signin_resp) =
|
let (creds, signin_resp) =
|
||||||
register_and_signin(NAME, EMAIL, PASSWORD).await;
|
register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let survey = get_survey_user(data.clone()).await;
|
let survey = get_survey_user(data.clone()).await;
|
||||||
let survey_cookie = get_cookie!(survey);
|
let survey_cookie = get_cookie!(survey);
|
||||||
|
|
3
src/cache_buster_data.json.license
Normal file
3
src/cache_buster_data.json.license
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
21
src/data.rs
21
src/data.rs
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
//! App data: database connections, etc.
|
//! App data: database connections, etc.
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
|
|
||||||
use argon2_creds::errors::CredsError;
|
use argon2_creds::errors::CredsError;
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use tera::Context;
|
use tera::Context;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
|
|
||||||
pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES};
|
pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES};
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use sailfish::TemplateOnce;
|
use sailfish::TemplateOnce;
|
||||||
|
|
||||||
use crate::pages::errors::ErrorPage;
|
use crate::pages::errors::ErrorPage;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_auth_middleware::*;
|
use actix_auth_middleware::*;
|
||||||
use actix_web::web::ServiceConfig;
|
use actix_web::web::ServiceConfig;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
@ -237,7 +226,7 @@ mod tests {
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (_, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
|
|
||||||
let campaign =
|
let campaign =
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::types::Uuid;
|
use sqlx::types::Uuid;
|
||||||
|
@ -181,7 +170,7 @@ mod tests {
|
||||||
let data = get_test_data().await;
|
let data = get_test_data().await;
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
let (_, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
|
|
||||||
let uuid =
|
let uuid =
|
||||||
|
|
|
@ -1,18 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
|
@ -262,7 +252,7 @@ mod tests {
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (_, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let survey = get_survey_user(data.clone()).await;
|
let survey = get_survey_user(data.clone()).await;
|
||||||
let survey_cookie = get_cookie!(survey);
|
let survey_cookie = get_cookie!(survey);
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
|
@ -138,7 +127,7 @@ mod tests {
|
||||||
let data = get_test_data().await;
|
let data = get_test_data().await;
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
let (_, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
|
|
||||||
let mut difficulties = String::new();
|
let mut difficulties = String::new();
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
|
@ -122,7 +112,7 @@ mod tests {
|
||||||
let data = get_test_data().await;
|
let data = get_test_data().await;
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
let (_, _, signin_resp) = register_and_signin(NAME, EMAIL, PASSWORD).await;
|
let (_, signin_resp) = register_and_signin(&data, NAME, EMAIL, PASSWORD).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
|
|
||||||
let uuid =
|
let uuid =
|
||||||
|
|
|
@ -1,18 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_web::{http, HttpResponse, Responder};
|
use actix_web::{http, HttpResponse, Responder};
|
||||||
|
|
||||||
pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES};
|
pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES};
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use actix_auth_middleware::GetLoginRoute;
|
use actix_auth_middleware::GetLoginRoute;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use cache_buster::Files;
|
use cache_buster::Files;
|
||||||
|
|
||||||
pub struct FileMap {
|
pub struct FileMap {
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
pub mod filemap;
|
pub mod filemap;
|
||||||
pub mod static_files;
|
pub mod static_files;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use actix_web::body::BoxBody;
|
use actix_web::body::BoxBody;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
|
|
51
src/tests.rs
51
src/tests.rs
|
@ -1,19 +1,8 @@
|
||||||
/*
|
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
//
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -29,6 +18,7 @@ use mktemp::Temp;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use sqlx::migrate::MigrateDatabase;
|
||||||
use sqlx::types::Uuid;
|
use sqlx::types::Uuid;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -58,8 +48,15 @@ pub async fn get_test_data() -> Arc<Data> {
|
||||||
let tmp_dir = Temp::new_dir().unwrap();
|
let tmp_dir = Temp::new_dir().unwrap();
|
||||||
settings.publish.dir = tmp_dir.join("base_path").to_str().unwrap().into();
|
settings.publish.dir = tmp_dir.join("base_path").to_str().unwrap().into();
|
||||||
settings.allow_registration = true;
|
settings.allow_registration = true;
|
||||||
|
let mut url = url::Url::parse(&settings.database.url).unwrap();
|
||||||
|
url.set_path(&crate::api::v1::get_random(16));
|
||||||
|
settings.database.url = url.to_string();
|
||||||
|
sqlx::Postgres::create_database(&settings.database.url)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let test_mcaptcha = Box::new(crate::mcaptcha::tests::TestClient::default());
|
let test_mcaptcha = Box::new(crate::mcaptcha::tests::TestClient::default());
|
||||||
let data = Data::new(settings, test_mcaptcha).await;
|
let data = Data::new(settings, test_mcaptcha).await;
|
||||||
|
|
||||||
db::migrate_db(&data.db).await.unwrap();
|
db::migrate_db(&data.db).await.unwrap();
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
@ -160,17 +157,17 @@ macro_rules! get_app {
|
||||||
|
|
||||||
/// register and signin utility
|
/// register and signin utility
|
||||||
pub async fn register_and_signin(
|
pub async fn register_and_signin(
|
||||||
|
data: &Arc<Data>,
|
||||||
name: &str,
|
name: &str,
|
||||||
email: &str,
|
email: &str,
|
||||||
password: &str,
|
password: &str,
|
||||||
) -> (Arc<Data>, Login, ServiceResponse<EitherBody<BoxBody>>) {
|
) -> (Login, ServiceResponse<EitherBody<BoxBody>>) {
|
||||||
register(name, email, password).await;
|
register(data, name, email, password).await;
|
||||||
signin(name, password).await
|
signin(data, name, password).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// register utility
|
/// register utility
|
||||||
pub async fn register(name: &str, email: &str, password: &str) {
|
pub async fn register(data: &Arc<Data>, name: &str, email: &str, password: &str) {
|
||||||
let data = get_test_data().await;
|
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
// 1. Register
|
// 1. Register
|
||||||
|
@ -195,10 +192,10 @@ pub async fn register(name: &str, email: &str, password: &str) {
|
||||||
|
|
||||||
/// signin util
|
/// signin util
|
||||||
pub async fn signin(
|
pub async fn signin(
|
||||||
|
data: &Arc<Data>,
|
||||||
name: &str,
|
name: &str,
|
||||||
password: &str,
|
password: &str,
|
||||||
) -> (Arc<Data>, Login, ServiceResponse<EitherBody<BoxBody>>) {
|
) -> (Login, ServiceResponse<EitherBody<BoxBody>>) {
|
||||||
let data = get_test_data().await;
|
|
||||||
let app = get_app!(data.clone()).await;
|
let app = get_app!(data.clone()).await;
|
||||||
|
|
||||||
// 2. signin
|
// 2. signin
|
||||||
|
@ -212,18 +209,19 @@ pub async fn signin(
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(signin_resp.status(), StatusCode::OK);
|
assert_eq!(signin_resp.status(), StatusCode::OK);
|
||||||
(data, creds, signin_resp)
|
(creds, signin_resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// pub duplicate test
|
/// pub duplicate test
|
||||||
pub async fn bad_post_req_test<T: Serialize>(
|
pub async fn bad_post_req_test<T: Serialize>(
|
||||||
|
data: &Arc<Data>,
|
||||||
name: &str,
|
name: &str,
|
||||||
password: &str,
|
password: &str,
|
||||||
url: &str,
|
url: &str,
|
||||||
payload: &T,
|
payload: &T,
|
||||||
err: ServiceError,
|
err: ServiceError,
|
||||||
) {
|
) {
|
||||||
let (data, _, signin_resp) = signin(name, password).await;
|
let (_, signin_resp) = signin(data, name, password).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
@ -242,12 +240,13 @@ pub async fn bad_post_req_test<T: Serialize>(
|
||||||
|
|
||||||
/// bad post req test without payload
|
/// bad post req test without payload
|
||||||
pub async fn bad_post_req_test_witout_payload(
|
pub async fn bad_post_req_test_witout_payload(
|
||||||
|
data: &Arc<Data>,
|
||||||
name: &str,
|
name: &str,
|
||||||
password: &str,
|
password: &str,
|
||||||
url: &str,
|
url: &str,
|
||||||
err: ServiceError,
|
err: ServiceError,
|
||||||
) {
|
) {
|
||||||
let (data, _, signin_resp) = signin(name, password).await;
|
let (_, signin_resp) = signin(data, name, password).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue