diff --git a/.gitattributes b/.gitattributes index dc5caf9..591bbcf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *.afdesign filter=lfs diff=lfs merge=lfs -text +test/assets/** filter=lfs diff=lfs merge=lfs -text diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f156e2..e08eb85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.1] - 2022-07-19 + +### Added + +- E2E Tests. +- Make backend more configurable + ## [2.0.1] - 2022-07-18 ### Added diff --git a/Dockerfile b/Dockerfile index 52d503d..2ef3f80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ RUN pnpm run build FROM rust:1.61-alpine as backend WORKDIR /tmp RUN apk add libc-dev openssl-dev alpine-sdk +COPY ./backend/Cargo.* ./ +RUN cargo fetch COPY ./backend ./ RUN cargo build --release @@ -20,7 +22,8 @@ RUN cargo build --release FROM alpine WORKDIR /app COPY --from=backend /tmp/target/release/cryptgeon . -COPY --from=client /tmp/build ./frontend/build -ENV REDIS=redis://redis/ +COPY --from=client /tmp/build ./frontend +ENV FRONTEND_PATH="./frontend" +ENV REDIS="redis://redis/" EXPOSE 5000 ENTRYPOINT [ "/app/cryptgeon" ] diff --git a/README.md b/README.md index 5175cc5..6a25942 100644 --- a/README.md +++ b/README.md @@ -165,8 +165,25 @@ Running `pnpm run dev` in the root folder will start the following things: You can see the app under [localhost:1234](http://localhost:1234). +## Tests + +Tests are end to end tests written with Playwright. + +```sh +pnpm run ci:prepare +docker compose up redis -d +pnpm run ci:server + +# In another terminal. +# Use the test or test:local script. The local version only runs in one browser for quicker development. +pnpm run test:local +``` + ###### Attributions -- Text for tests [Nietzsche Ipsum](https://nietzsche-ipsum.com/) +- Test data: + - Text for tests [Nietzsche Ipsum](https://nietzsche-ipsum.com/) + - [AES Paper](https://www.cs.miami.edu/home/burt/learning/Csc688.012/rijndael/rijndael_doc_V2.pdf) + - [Unsplash Pictures](https://unsplash.com/) - Loading animation by [Nikhil Krishnan](https://codepen.io/nikhil8krishnan/pen/rVoXJa) - Icons made by freepik from www.flaticon.com diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 0591614..5d90ec3 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -424,7 +424,7 @@ dependencies = [ [[package]] name = "cryptgeon" -version = "2.0.1" +version = "2.0.2" dependencies = [ "actix-files", "actix-web", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 551c1ba..60399af 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptgeon" -version = "2.0.1" +version = "2.0.2" authors = ["cupcakearmy "] edition = "2021" diff --git a/backend/src/client.rs b/backend/src/client.rs index 2131e1c..f89501f 100644 --- a/backend/src/client.rs +++ b/backend/src/client.rs @@ -1,14 +1,17 @@ use actix_files::{Files, NamedFile}; use actix_web::{web, Result}; +use crate::config; + pub fn init(cfg: &mut web::ServiceConfig) { cfg.service( - Files::new("/", "./frontend/build") + Files::new("/", config::FRONTEND_PATH.to_string()) .index_file("index.html") .use_etag(true), ); } pub async fn index() -> Result { - Ok(NamedFile::open("./frontend/build/index.html")?) + let index = format!("{}{}", config::FRONTEND_PATH.to_string(), "/index.html"); + Ok(NamedFile::open(index)?) } diff --git a/backend/src/config.rs b/backend/src/config.rs index ff87c78..431ae04 100644 --- a/backend/src/config.rs +++ b/backend/src/config.rs @@ -1,10 +1,14 @@ use byte_unit::Byte; -// General +// Internal lazy_static! { pub static ref VERSION: String = option_env!("CARGO_PKG_VERSION") .unwrap_or("Unknown") .to_string(); + pub static ref FRONTEND_PATH: String = + std::env::var("FRONTEND_PATH").unwrap_or("../frontend/build".to_string()); + pub static ref LISTEN_ADDR: String = + std::env::var("LISTEN_ADDR").unwrap_or("0.0.0.0:5000".to_string()); } // CONFIG diff --git a/backend/src/main.rs b/backend/src/main.rs index 45939cd..122e67c 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -29,7 +29,7 @@ async fn main() -> std::io::Result<()> { .configure(client::init) .default_service(web::to(client::index)) }) - .bind("0.0.0.0:5000")? + .bind(config::LISTEN_ADDR.to_string())? .run() .await; } diff --git a/docker-compose.yml b/docker-compose.yml index 1dfdfb9..5eb2b2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,4 +16,4 @@ services: environment: SIZE_LIMIT: 128 MiB ports: - - 80:5000 + - 1234:5000 diff --git a/frontend/src/lib/ui/AdvancedParameters.svelte b/frontend/src/lib/ui/AdvancedParameters.svelte index 4dceecf..7b5d40c 100644 --- a/frontend/src/lib/ui/AdvancedParameters.svelte +++ b/frontend/src/lib/ui/AdvancedParameters.svelte @@ -12,6 +12,7 @@
- +
{label} - +
{#if files.length}
diff --git a/frontend/src/lib/views/Create.svelte b/frontend/src/lib/views/Create.svelte index 2130128..d3bd78e 100644 --- a/frontend/src/lib/views/Create.svelte +++ b/frontend/src/lib/views/Create.svelte @@ -106,15 +106,29 @@
{#if isFile} - + {:else} -