From 5df3e7af703b459644bb3d3e2fc41d958d7216bd Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 5 Oct 2025 17:59:19 -0700 Subject: [PATCH 01/33] Document change (#683) --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 069f2dd0..1ef92b2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,9 @@ The following log documents the history of the server project. ### Unreleased -None +### 3.0.0-rc1 2025-10-05 + +- Use SQLite instead of Postgres. Please use https://github.com/dnote/pg2sqlite to migrate. ### 2.1.1 2023-03-04 From a62c7f9e93bfe9d21d05c42aff0f4ad499b45f68 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 5 Oct 2025 21:26:12 -0700 Subject: [PATCH 02/33] Build cli v0.15.2 (#684) --- .github/workflows/release-cli.yml | 58 +++++++++++++++++++++++++++++++ CHANGELOG.md | 5 +++ Makefile | 6 ++-- install.sh | 17 +++++++-- pkg/cli/cmd/login/login.go | 4 --- pkg/cli/cmd/login/login_test.go | 4 --- pkg/dirs/dirs_unix.go | 2 +- pkg/dirs/dirs_unix_test.go | 2 +- scripts/cli/build.sh | 16 +++++++-- scripts/cli/release-homebrew.sh | 19 ++++++---- 10 files changed, 108 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/release-cli.yml diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml new file mode 100644 index 00000000..65b2fd0b --- /dev/null +++ b/.github/workflows/release-cli.yml @@ -0,0 +1,58 @@ +name: Release CLI + +on: + push: + tags: + - 'cli-v*' + +jobs: + release: + runs-on: ubuntu-22.04 + permissions: + contents: write + + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version: '>=1.25.0' + + - name: Extract version from tag + id: version + run: | + TAG=${GITHUB_REF#refs/tags/cli-v} + echo "version=$TAG" >> $GITHUB_OUTPUT + echo "Releasing version: $TAG" + + - name: Install dependencies + run: make install + + - name: Run CLI tests + run: make test-cli + + - name: Run E2E tests + run: make test-e2e + + - name: Build CLI + run: make version=${{ steps.version.outputs.version }} build-cli + + - name: Create GitHub release + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION="${{ steps.version.outputs.version }}" + TAG="cli-v${VERSION}" + + # Determine if prerelease (version not matching major.minor.patch) + FLAGS="" + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + FLAGS="--prerelease" + fi + + gh release create "$TAG" \ + build/cli/*.tar.gz \ + build/cli/*_checksums.txt \ + $FLAGS \ + --title="$TAG" \ + --notes="Please see the [CHANGELOG](https://github.com/dnote/dnote/blob/master/CHANGELOG.md)" \ + --draft diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ef92b2e..431232b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -213,6 +213,11 @@ The following log documentes the history of the CLI project None +### 0.15.2 - 2025-10-05 + +* Support for 32bit linux, freebsd amd64, mac arm64. +* Remove Pro. + ### 0.15.1 - 2024-02-03 * Upgrade `color` dependency (#660). diff --git a/Makefile b/Makefile index 3b91d6ae..12cf32cf 100644 --- a/Makefile +++ b/Makefile @@ -95,13 +95,13 @@ endif @${currentDir}/scripts/release.sh cli $(version) ${cliOutputDir} .PHONY: release-cli -release-cli-homebrew: clean build-cli +release-cli-homebrew: ifndef version - $(error version is required. Usage: make version=0.1.0 release-cli) + $(error version is required. Usage: make version=0.1.0 release-cli-homebrew) endif @echo "==> releasing cli on Homebrew" - @${currentDir}/scripts/cli/release-homebrew.sh $(version) ${cliOutputDir} + @${currentDir}/scripts/cli/release-homebrew.sh $(version) .PHONY: release-cli release-server: diff --git a/install.sh b/install.sh index 6537232e..bb09bd8f 100755 --- a/install.sh +++ b/install.sh @@ -68,9 +68,14 @@ uname_os() { uname_arch() { arch=$(uname -m) - case $arch in + case $arch in x86_64) arch="amd64" ;; aarch64) arch="arm64" ;; + arm64) arch="arm64" ;; + armv7l) arch="arm" ;; + armv6l) arch="arm" ;; + armv5l) arch="arm" ;; + arm) arch="arm" ;; x86) arch="386" ;; i686) arch="386" ;; i386) arch="386" ;; @@ -86,9 +91,17 @@ check_platform() { found=1 case "$platform" in - darwin/amd64) found=0;; + # Linux linux/amd64) found=0 ;; linux/arm64) found=0 ;; + linux/arm) found=0 ;; + # macOS + darwin/amd64) found=0 ;; + darwin/arm64) found=0 ;; + # Windows + windows/amd64) found=0 ;; + # FreeBSD + freebsd/amd64) found=0 ;; esac return $found diff --git a/pkg/cli/cmd/login/login.go b/pkg/cli/cmd/login/login.go index 42df6c77..1e667382 100644 --- a/pkg/cli/cmd/login/login.go +++ b/pkg/cli/cmd/login/login.go @@ -126,10 +126,6 @@ func getBaseURL(rawURL string) (string, error) { } func getServerDisplayURL(ctx context.DnoteCtx) string { - if ctx.APIEndpoint == "https://api.getdnote.com" { - return "https://www.getdnote.com" - } - baseURL, err := getBaseURL(ctx.APIEndpoint) if err != nil { return "" diff --git a/pkg/cli/cmd/login/login_test.go b/pkg/cli/cmd/login/login_test.go index 47807c1f..c208fa5d 100644 --- a/pkg/cli/cmd/login/login_test.go +++ b/pkg/cli/cmd/login/login_test.go @@ -31,10 +31,6 @@ func TestGetServerDisplayURL(t *testing.T) { apiEndpoint string expected string }{ - { - apiEndpoint: "https://api.getdnote.com", - expected: "https://www.getdnote.com", - }, { apiEndpoint: "https://dnote.mydomain.com/api", expected: "https://dnote.mydomain.com", diff --git a/pkg/dirs/dirs_unix.go b/pkg/dirs/dirs_unix.go index c6d525e5..59420c0e 100644 --- a/pkg/dirs/dirs_unix.go +++ b/pkg/dirs/dirs_unix.go @@ -16,7 +16,7 @@ * along with Dnote. If not, see . */ -//go:build linux || darwin +//go:build linux || darwin || freebsd package dirs diff --git a/pkg/dirs/dirs_unix_test.go b/pkg/dirs/dirs_unix_test.go index 3d821155..0ab63ad8 100644 --- a/pkg/dirs/dirs_unix_test.go +++ b/pkg/dirs/dirs_unix_test.go @@ -16,7 +16,7 @@ * along with Dnote. If not, see . */ -//go:build linux || darwin +//go:build linux || darwin || freebsd package dirs diff --git a/scripts/cli/build.sh b/scripts/cli/build.sh index 467f1282..c805ba90 100755 --- a/scripts/cli/build.sh +++ b/scripts/cli/build.sh @@ -36,7 +36,7 @@ if [[ $1 == v* ]]; then exit 1 fi -goVersion=go-1.21.x +goVersion=go-1.25.x get_binary_name() { platform=$1 @@ -57,7 +57,7 @@ build() { # build binary destDir="$outputDir/$platform-$arch" - ldflags="-X main.apiEndpoint=https://api.getdnote.com -X main.versionTag=$version" + ldflags="-X main.apiEndpoint=https://localhost:3000/api -X main.versionTag=$version" tags="fts5" pushd "$projectDir" @@ -92,7 +92,7 @@ build() { popd binaryName=$(get_binary_name "$platform") - mv "$destDir/cli-${platform}-"* "$destDir/$binaryName" + mv "$destDir/cli-"* "$destDir/$binaryName" # build tarball tarballName="dnote_${version}_${platform}_${arch}.tar.gz" @@ -113,10 +113,20 @@ if [ -z "$GOOS" ] && [ -z "$GOARCH" ]; then # install the tool go install src.techknowlogick.com/xgo@latest + # Linux build linux amd64 build linux arm64 + build linux arm + + # macOS build darwin amd64 + build darwin arm64 + + # Windows build windows amd64 + + # FreeBSD + build freebsd amd64 else build "$GOOS" "$GOARCH" true fi diff --git a/scripts/cli/release-homebrew.sh b/scripts/cli/release-homebrew.sh index 7e9a7bd5..f48f16dc 100755 --- a/scripts/cli/release-homebrew.sh +++ b/scripts/cli/release-homebrew.sh @@ -10,12 +10,13 @@ if [ ! -d "$cliHomebrewDir" ]; then fi version=$1 -tarball=$2 echo "version: $version" -echo "tarball: $tarball" -sha=$(shasum -a 256 "$tarball" | cut -d ' ' -f 1) +# Download source tarball and calculate SHA256 +source_url="https://github.com/dnote/dnote/archive/refs/tags/cli-v${version}.tar.gz" +echo "Calculating SHA256 for: $source_url" +sha=$(curl -L "$source_url" | shasum -a 256 | cut -d ' ' -f 1) pushd "$cliHomebrewDir" @@ -25,14 +26,18 @@ git pull origin master cat > ./Formula/dnote.rb << EOF class Dnote < Formula - desc "A simple command line notebook for programmers" + desc "Simple command line notebook for programmers" homepage "https://www.getdnote.com" - url "https://github.com/dnote/dnote/releases/download/cli-v${version}/dnote_${version}_darwin_amd64.tar.gz" - version "${version}" + url "https://github.com/dnote/dnote/archive/refs/tags/cli-v${version}.tar.gz" sha256 "${sha}" + license "GPL-3.0" + head "https://github.com/dnote/dnote.git", branch: "master" + + depends_on "go" => :build def install - bin.install "dnote" + ldflags = "-s -w -X main.apiEndpoint=https://api.getdnote.com -X main.versionTag=#{version}" + system "go", "build", *std_go_args(ldflags: ldflags), "-tags", "fts5", "./pkg/cli" end test do From 637d4c686163142891a811917f896bd83c1967c4 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 5 Oct 2025 22:26:48 -0700 Subject: [PATCH 03/33] Simplify contribution (#685) --- CONTRIBUTING.md | 90 ++++++++------------- README.md | 32 +++++--- SELF_HOSTING.md | 116 ++++++++-------------------- Vagrantfile | 20 ----- scripts/vagrant/bootstrap.sh | 19 ----- scripts/vagrant/install_go.sh | 26 ------- scripts/vagrant/install_node.sh | 19 ----- scripts/vagrant/install_postgres.sh | 9 --- scripts/vagrant/install_utils.sh | 18 ----- 9 files changed, 86 insertions(+), 263 deletions(-) delete mode 100644 Vagrantfile delete mode 100755 scripts/vagrant/bootstrap.sh delete mode 100755 scripts/vagrant/install_go.sh delete mode 100755 scripts/vagrant/install_node.sh delete mode 100755 scripts/vagrant/install_postgres.sh delete mode 100755 scripts/vagrant/install_utils.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fb41959d..ffb31385 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,89 +8,61 @@ Dnote is an open source project. ## Setting up -Dnote uses [Vagrant](https://github.com/hashicorp/vagrant) to provision a consistent development environment. +The CLI and server are single single binary files with SQLite embedded - no databases to install, no containers to run, no VMs required. -*Prerequisites* +**Prerequisites** -* Vagrant ([Download](https://www.vagrantup.com/downloads.html)) -* VirtualBox ([Download](https://www.virtualbox.org/)) +* Go 1.25+ ([Download](https://go.dev/dl/)) +* Node.js 18+ ([Download](https://nodejs.org/) - only needed for building frontend assets) -Run the following command from the project root. It starts the virtual machine and bootstraps the project. +**Quick Start** -``` -vagrant up -``` +1. Clone the repository +2. Install dependencies: + ```bash + make install + ``` +3. Start developing! Run tests: + ```bash + make test + ``` + Or start the dev server: + ```bash + make dev-server + ``` -*Workflow* - -* You can make changes to the source code from the host machine. -* Any commands need to be run inside the virtual machine. You can connect to it by running `vagrant ssh`. -* If you want to run tests in a WATCH mode, please do so from the host machine. We cannot watch file changes due to the limitation of file system used in a virtual machine. +That's it. You're ready to contribute. ## Server -The server consists of the frontend web application and a web server. - -### Development - -* Run `make dev-server` to start a local server. -* You can access the server on `localhost:3000` on your machine. - -### Test - ```bash -# Run tests for app +# Start dev server (runs on localhost:3000) +make dev-server + +# Run tests make test-api -# Run in watch mode +# Run tests in watch mode WATCH=true make test-api ``` - ## Command Line Interface -### Build +```bash +# Run tests +make test-cli -You can build either a development version or a production version: - -``` -# Build a development version for your platform and place it in your `PATH`. +# Build dev version (places in your PATH) make debug=true build-cli -# Build a production version for all platforms +# Build production version for all platforms make version=v0.1.0 build-cli -# Build a production version for a specific platform +# Build for a specific platform # Note: You cannot cross-compile using this method because Dnote uses CGO # and requires the OS specific headers. GOOS=[insert OS] GOARCH=[insert arch] make version=v0.1.0 build-cli -``` -### Test - -* Run all tests for the command line interface: - -``` -make test-cli -``` - -### Debug - -Run Dnote with `DNOTE_DEBUG=1` to print debugging statements. For instance: - -``` +# Debug mode DNOTE_DEBUG=1 dnote sync ``` - -### Release - -* Run `make version=v0.1.0 release-cli` to achieve the following: - * Build for all target platforms, create a git tag, push all tags to the repository - * Create a release on GitHub and [Dnote Homebrew tap](https://github.com/dnote/homebrew-dnote). - -**Note** - -- If a release is not stable, - - disable the homebrew release by commenting out relevant code in the release script. - - mark release as pre-release on GitHub release - diff --git a/README.md b/README.md index e23eb426..51579b5a 100644 --- a/README.md +++ b/README.md @@ -3,30 +3,42 @@ ![Build Status](https://github.com/dnote/dnote/actions/workflows/ci.yml/badge.svg) -Dnote is a simple command line notebook for programmers. +Dnote is a simple command line notebook. Single binary, no dependencies. Since 2017. -It **keeps you focused** by providing a way of effortlessly capturing and retrieving information **without leaving your terminal**. It also offers a seamless **multi-device sync**. +Your notes are stored in **one SQLite file** - portable, searchable, and completely under your control. Optional sync between devices via a self-hosted server with REST API access. -![A demo of Dnote command line interface](assets/cli.gif "Dnote command line interface") +```sh +# Add a note (or omit -c to launch your editor) +dnote add linux -c "Check disk usage with df -h" + +# View notes in a book +dnote view linux + +# Full-text search +dnote find "disk usage" + +# Sync notes +dnote sync +``` ## Installation -On macOS, you can install using Homebrew: +On Unix-like systems (Linux, FreeBSD, macOS), you can use the installation script: + + curl -s https://www.getdnote.com/install | sh + +Or on macOS with Homebrew: ```sh brew tap dnote/dnote brew install dnote ``` -On Linux or macOS, you can use the installation script: - - curl -s https://www.getdnote.com/install | sh - -Otherwise, you can download the binary for your platform manually from the [releases page](https://github.com/dnote/dnote/releases). +You can also download the binary for your platform from the [releases page](https://github.com/dnote/dnote/releases). ## Server -You can install it [using Docker](https://github.com/dnote/dnote/blob/master/host/docker/README.md), or [using a binary](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md). +Self-host your own Dnote server - just run a binary, no database required. [Download](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) or run [with Docker](https://github.com/dnote/dnote/blob/master/host/docker/README.md). ## Documentation diff --git a/SELF_HOSTING.md b/SELF_HOSTING.md index 0c52733c..52bc7cfd 100644 --- a/SELF_HOSTING.md +++ b/SELF_HOSTING.md @@ -1,47 +1,26 @@ -# Installing Dnote Server +# Self-Hosting Dnote Server -This guide documents the steps for installing the Dnote server on your own machine. If you prefer Docker, please see [the Docker guide](https://github.com/dnote/dnote/blob/master/host/docker/README.md). +For Docker installation, see [the Docker guide](https://github.com/dnote/dnote/blob/master/host/docker/README.md). -## Overview +## Quick Start -Dnote server comes as a single binary file that you can simply download and run. It uses SQLite as the database. - -## Installation - -1. Download the official Dnote server release from the [release page](https://github.com/dnote/dnote/releases). -2. Extract the archive and move the `dnote-server` executable to `/usr/local/bin`. +Download from [releases](https://github.com/dnote/dnote/releases), extract, and run: ```bash tar -xzf dnote-server-$version-$os.tar.gz mv ./dnote-server /usr/local/bin +dnote-server start --webUrl=https://your.server ``` -3. Run Dnote +You're up and running. Database: `~/.local/share/dnote/server.db` (customize with `--dbPath`). Run `dnote-server start --help` for options. -```bash -dnote-server start --webUrl=$webURL -``` +Set `apiEndpoint: https://your.server/api` in `~/.config/dnote/dnoterc` to connect your CLI to the server. -Replace `$webURL` with the full URL to your server, without a trailing slash (e.g. `https://your.server`). +## Optional guide -Additional flags: -- `--port`: Server port (default: `3000`) -- `--disableRegistration`: Disable user registration (default: `false`) -- `--logLevel`: Log level: `debug`, `info`, `warn`, or `error` (default: `info`) -- `--appEnv`: environment (default: `PRODUCTION`) +### Nginx -You can also use environment variables: `PORT`, `WebURL`, `DisableRegistration`, `LOG_LEVEL`, `APP_ENV`. - -## Configuration - -By now, Dnote is fully functional in your machine. The API, frontend app, and the background tasks are all in the single binary. Let's take a few more steps to configure Dnote. - -### Configure Nginx - -To make it accessible from the Internet, you need to configure Nginx. - -1. Install nginx. -2. Create a new file in `/etc/nginx/sites-enabled/dnote` with the following contents: +Create `/etc/nginx/sites-enabled/dnote`: ``` server { @@ -55,17 +34,16 @@ server { } } ``` -3. Replace `my-dnote-server.com` with the URL for your server. -4. Reload the nginx configuration by running the following: -``` +Replace `my-dnote-server.com` with your domain, then reload: + +```bash sudo service nginx reload ``` -### Configure Apache2 +### Apache2 -1. Install Apache2 and install/enable mod_proxy. -2. Create a new file in `/etc/apache2/sites-available/dnote.conf` with the following contents: +Enable `mod_proxy`, then create `/etc/apache2/sites-available/dnote.conf`: ``` @@ -79,26 +57,20 @@ sudo service nginx reload ``` -3. Enable the dnote site and restart the Apache2 service by running the following: +Enable and restart: -``` +```bash a2ensite dnote sudo service apache2 restart ``` -Now you can access the Dnote frontend application on `/`, and the API on `/api`. +### TLS -### Configure TLS by using LetsEncrypt +Use LetsEncrypt to obtain a certificate and configure HTTPS in your reverse proxy. -It is recommended to use HTTPS. Obtain a certificate using LetsEncrypt and configure TLS in Nginx. +### systemd Daemon -In the future versions of the Dnote Server, HTTPS will be required at all times. - -### Run Dnote As a Daemon - -We can use `systemd` to run Dnote in the background as a Daemon, and automatically start it on system reboot. - -1. Create a new file at `/etc/systemd/system/dnote.service` with the following content: +Create `/etc/systemd/system/dnote.service`: ``` [Unit] @@ -118,45 +90,23 @@ ExecStart=/usr/local/bin/dnote-server start --webUrl=$WebURL WantedBy=multi-user.target ``` -Replace `$user` and `$WebURL` with the actual values. +Replace `$user` and `$WebURL`. Add `--dbPath` to `ExecStart` if you want a custom database location. -By default, the database will be stored at `$XDG_DATA_HOME/dnote/server.db` (typically `~/.local/share/dnote/server.db`). To use a custom location, add `--dbPath=/path/to/database.db` to the `ExecStart` command. +Enable and start: -2. Reload the change by running `sudo systemctl daemon-reload`. -3. Enable the Daemon by running `sudo systemctl enable dnote`.` -4. Start the Daemon by running `sudo systemctl start dnote` +```bash +sudo systemctl daemon-reload +sudo systemctl enable dnote +sudo systemctl start dnote +``` -### Optional: Email Support +### Email Support -To enable sending emails, add the following environment variables to your configuration. But they are not required. +If you want emails, add these environment variables: -- `SmtpHost` - SMTP server hostname -- `SmtpPort` - SMTP server port +- `SmtpHost` - SMTP hostname +- `SmtpPort` - SMTP port - `SmtpUsername` - SMTP username - `SmtpPassword` - SMTP password -For systemd, add these as additional `Environment=` lines in `/etc/systemd/system/dnote.service`. - -### Configure clients - -Let's configure Dnote clients to connect to the self-hosted web API endpoint. - -#### CLI - -We need to modify the configuration file for the CLI. It should have been generated at `~/.config/dnote/dnoterc` upon running the CLI for the first time. - -The following is an example configuration: - -```yaml -editor: nvim -apiEndpoint: https://localhost:3000/api -``` - -Simply change the value for `apiEndpoint` to a full URL to the self-hosted instance, followed by '/api', and save the configuration file. - -e.g. - -```yaml -editor: nvim -apiEndpoint: my-dnote-server.com/api -``` +For systemd, add as `Environment=` lines in the service file. diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 65dd3db1..00000000 --- a/Vagrantfile +++ /dev/null @@ -1,20 +0,0 @@ -# -*- mode: ruby -*- - -Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/bionic64" - config.vm.synced_folder '.', '/go/src/github.com/dnote/dnote' - config.vm.network "forwarded_port", guest: 3000, host: 3000 - config.vm.network "forwarded_port", guest: 8080, host: 8080 - config.vm.network "forwarded_port", guest: 5432, host: 5433 - - config.vm.provision 'shell', path: './scripts/vagrant/install_utils.sh' - config.vm.provision 'shell', path: './scripts/vagrant/install_go.sh', privileged: false - config.vm.provision 'shell', path: './scripts/vagrant/install_node.sh', privileged: false - config.vm.provision 'shell', path: './scripts/vagrant/install_postgres.sh', privileged: false - config.vm.provision 'shell', path: './scripts/vagrant/bootstrap.sh', privileged: false - - config.vm.provider "virtualbox" do |v| - v.memory = 4000 - v.cpus = 2 - end -end diff --git a/scripts/vagrant/bootstrap.sh b/scripts/vagrant/bootstrap.sh deleted file mode 100755 index b8299676..00000000 --- a/scripts/vagrant/bootstrap.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -ex - -echo "export DNOTE=/go/src/github.com/dnote/dnote" >> /home/vagrant/.bash_profile -echo "cd /go/src/github.com/dnote/dnote" >> /home/vagrant/.bash_profile - -# install dependencies -(cd /go/src/github.com/dnote/dnote && make install) - -# set up database -sudo -u postgres createdb dnote -sudo -u postgres createdb dnote_test -sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" - -# allow connection from host and allow to connect without password -sudo sed -i "/port*/a listen_addresses = '*'" /etc/postgresql/14/main/postgresql.conf -sudo sed -i 's/host.*all.*.all.*md5/# &/' /etc/postgresql/14/main/pg_hba.conf -sudo sed -i "$ a host all all all trust" /etc/postgresql/14/main/pg_hba.conf -sudo service postgresql restart diff --git a/scripts/vagrant/install_go.sh b/scripts/vagrant/install_go.sh deleted file mode 100755 index 4dc0c1b0..00000000 --- a/scripts/vagrant/install_go.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1091 -set -eux - -VERSION=1.21 -OS=linux -ARCH=amd64 - -tarball=go$VERSION.$OS-$ARCH.tar.gz - -wget -q https://dl.google.com/go/"$tarball" -sudo tar -C /usr/local -xzf "$tarball" -sudo tar -xf "$tarball" - -sudo mkdir -p /go/src -sudo mkdir -p /go/bin -sudo mkdir -p /go/pkg -sudo chown -R vagrant:vagrant /go - -GOPATH=/go -echo "export GOPATH=$GOPATH" >> /home/vagrant/.bash_profile -echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> /home/vagrant/.bash_profile -source /home/vagrant/.bash_profile - -go version -go env diff --git a/scripts/vagrant/install_node.sh b/scripts/vagrant/install_node.sh deleted file mode 100755 index 1233d449..00000000 --- a/scripts/vagrant/install_node.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1090,SC1091 -set -eux - -VERSION=12.16.2 -NVM_VERSION=v0.35.0 - -# Install nvm -wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/"$NVM_VERSION"/install.sh | bash -cat >> /home/vagrant/.bash_profile<< EOF -export NVM_DIR="\$([ -z "\${XDG_CONFIG_HOME-}" ] && printf %s "\${HOME}/.nvm" || printf %s "\${XDG_CONFIG_HOME}/nvm")" -[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh" # This loads nvm -EOF -source /home/vagrant/.bash_profile - -# Install a node and alias -nvm install --no-progress "$VERSION" 1>/dev/null -nvm alias default "$VERSION" -nvm use default diff --git a/scripts/vagrant/install_postgres.sh b/scripts/vagrant/install_postgres.sh deleted file mode 100755 index f2738021..00000000 --- a/scripts/vagrant/install_postgres.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -ex - -sudo apt-get -y install wget ca-certificates -wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - -sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' - -sudo apt-get update -sudo apt-get install -y postgresql-14 diff --git a/scripts/vagrant/install_utils.sh b/scripts/vagrant/install_utils.sh deleted file mode 100755 index 46322005..00000000 --- a/scripts/vagrant/install_utils.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -set -eux - -sudo apt-get update -sudo apt-get install -y htop git wget build-essential inotify-tools - -# Install Chrome -wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list -sudo apt-get -y update -sudo apt-get install -y google-chrome-stable - -# Install dart-sass -dart_version=1.34.1 -dart_tarball="dart-sass-$dart_version-linux-x64.tar.gz" -wget -q "https://github.com/sass/dart-sass/releases/download/$dart_version/$dart_tarball" -tar -xvzf "$dart_tarball" -C /tmp/ -sudo install /tmp/dart-sass/sass /usr/bin From 162ceb4ad1cd60f7db2b9f007b857e85df35154b Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Fri, 10 Oct 2025 21:20:33 -0700 Subject: [PATCH 04/33] Simplify installation (#686) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 51579b5a..12fd8675 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ On Unix-like systems (Linux, FreeBSD, macOS), you can use the installation scrip Or on macOS with Homebrew: ```sh -brew tap dnote/dnote brew install dnote ``` From ca5af5e34a95eeb239505a57dbc2d22c2eaaced1 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 11 Oct 2025 12:41:51 -0700 Subject: [PATCH 05/33] Run server on port 3001 (#687) * Simplify docker compose file * Run on port 3001 --- CONTRIBUTING.md | 2 +- README.md | 34 ++++++++++++++++++++++++---------- SELF_HOSTING.md | 6 +++--- assets/cli.gif | Bin 251236 -> 0 bytes assets/devices.png | Bin 37561 -> 0 bytes host/docker/Dockerfile | 2 +- host/docker/README.md | 2 +- host/docker/compose.yml | 11 +++-------- pkg/e2e/server_test.go | 4 ++-- pkg/server/.env.dev | 2 +- pkg/server/.env.test | 2 +- pkg/server/config/config.go | 4 ++-- pkg/server/main.go | 4 ++-- scripts/cli/build.sh | 2 +- scripts/cli/dev.sh | 2 +- scripts/e2e/test.sh | 2 +- scripts/server/dev.sh | 2 +- 17 files changed, 45 insertions(+), 36 deletions(-) delete mode 100644 assets/cli.gif delete mode 100644 assets/devices.png diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ffb31385..b0fa33eb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,7 +36,7 @@ That's it. You're ready to contribute. ## Server ```bash -# Start dev server (runs on localhost:3000) +# Start dev server (runs on localhost:3001) make dev-server # Run tests diff --git a/README.md b/README.md index 12fd8675..e9469d83 100644 --- a/README.md +++ b/README.md @@ -23,22 +23,36 @@ dnote sync ## Installation -On Unix-like systems (Linux, FreeBSD, macOS), you can use the installation script: +```bash +# Linux, macOS, FreeBSD, Windows +curl -s https://www.getdnote.com/install | sh - curl -s https://www.getdnote.com/install | sh - -Or on macOS with Homebrew: - -```sh +# macOS with Homebrew brew install dnote ``` -You can also download the binary for your platform from the [releases page](https://github.com/dnote/dnote/releases). +Or [download binary](https://github.com/dnote/dnote/releases). -## Server +## Server (Optional) -Self-host your own Dnote server - just run a binary, no database required. [Download](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) or run [with Docker](https://github.com/dnote/dnote/blob/master/host/docker/README.md). +Just run a binary. No database setup required. + +Run with Docker Compose using [compose.yml](./host/docker/compose.yml): + +```yaml +services: + dnote: + image: dnote/dnote:latest + container_name: dnote + ports: + - 3001:3001 + volumes: + - ./dnote_data:/data + restart: unless-stopped +``` + +Or see the [guide](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) for binary installation and configuration options. ## Documentation -Please see [Dnote wiki](https://github.com/dnote/dnote/wiki) for the documentation. +See the [Dnote wiki](https://github.com/dnote/dnote/wiki) for full documentation. diff --git a/SELF_HOSTING.md b/SELF_HOSTING.md index 52bc7cfd..d033b45e 100644 --- a/SELF_HOSTING.md +++ b/SELF_HOSTING.md @@ -30,7 +30,7 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; - proxy_pass http://127.0.0.1:3000; + proxy_pass http://127.0.0.1:3001; } } ``` @@ -51,8 +51,8 @@ Enable `mod_proxy`, then create `/etc/apache2/sites-available/dnote.conf`: ProxyRequests Off ProxyPreserveHost On - ProxyPass / http://127.0.0.1:3000/ keepalive=On - ProxyPassReverse / http://127.0.0.1:3000/ + ProxyPass / http://127.0.0.1:3001/ keepalive=On + ProxyPassReverse / http://127.0.0.1:3001/ RequestHeader set X-Forwarded-HTTPS "0" ``` diff --git a/assets/cli.gif b/assets/cli.gif deleted file mode 100644 index 8925e1312d7819c4c8306ae1c0af4a716f058b97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 251236 zcmbTccTkhv*ZzB_haP&UhR}QHMa0m%6p?b*d+lp~j7$vGHQWurexL*3&kGCyWLy7- zs^Miv0j<+t3cdhi&=tvuD=+eXdg=jIkc z(VG~YY#$jPZ7R^Sa~~gl+*))gAkzEI;=?ioz0w_g@jOEP3 z9+-r&qn%}0MHT>t@dLo~(L2RK7DG>GYsS|BxIit*FE2jO$uBmNmumVx*Ag}9{>=xQ}}bI z&F!=E%BR~38?HqH06f6cN?2Gy%laa{ph8jIEpl8$*(I0hUh4eR;}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QI#(mK;3W68-?U@)8%+$NXKEaje1$u#u?u5Si*~763luQv?%Cvw!fBmL&a6%vr_+bAy(f=n7xCy4 z#Bg2|a|QCOWDV9}Dw!qbA*U`jW#b=@@YMueFIQuSvpi7J^; zeEKQ;VWesYU03SR!5oTE>Cu250-i|jI?=f27)ovNDSSNFJyb?20?Ei!W35w|)fvx& zvtqgUPefdV(t@H)F>>#@aD?V~(7z_tynvLs$ID-CJ=Gx9RtJIo^O^rxK(dqRY5%Db|g*cV~%7@+BUG8{)(qPgxFd-CVvr~M9t zu6i-HwX~$@iFO_K&PP^Fr!eWypW-Pjr0p3Wefd(NM#SqLo@$!YNi)2(dwGo=C^rY} z*01Dw*sFJ6@n{gglkufPhc1k?u8A zk*p?~`YtTfhz98FN41orCW}%xnq1!~7+k%Y)6?)M}gH<9X=Z&dL_4tD4m1KViQz=3bNUR|)Px|E#Y_AclYKWhV?mDB})+WA-bjK_JVs z7a7fB8P5Jlqy*_tWR<0G;chL{>2%VzegSc)LV^DWruN{%nU0!(>w%Mnt%eOPg=u|; zE521dx$_jr2VoOAQ_#H@9IYp~_S0(2ej#HR^As_d(E# z7Y%KSF1HhY@%B5riGffwCq0?DcjWb+kl5Mn@w#IbL@zcty<=`$+Ggxp8H3(2T(gH} zqG+s2{ms`xJsUj7W#UZ+Ejm>dYbq*@J&=RAMm>4R3%D^Nd+Iw+C|15S{ucw zq@dlB$GRj*<#^lTT-7D%q@*OJBA9bnHTESZ6D(K@h5O4sXZjK9JWfMN+K0(?Yuzy9V>;sCgE$O=9ujiFe3EAH z?|2VkJ}QJf|xW|mp6d1 zQ5Yt3C0=ZJH&Da{_mcJj OpP7jjq|WH>v;P6V4EA3D diff --git a/host/docker/Dockerfile b/host/docker/Dockerfile index 81beabee..cd93f6ca 100644 --- a/host/docker/Dockerfile +++ b/host/docker/Dockerfile @@ -13,4 +13,4 @@ ENTRYPOINT ["./entrypoint.sh"] CMD ./dnote-server start -EXPOSE 3000 +EXPOSE 3001 diff --git a/host/docker/README.md b/host/docker/README.md index 69926481..179492b6 100644 --- a/host/docker/README.md +++ b/host/docker/README.md @@ -19,7 +19,7 @@ docker compose pull docker compose up -d ``` -Visit http://localhost:3000 in your browser to see Dnote running. +Visit http://localhost:3001 in your browser to see Dnote running. Please see [the installation guide](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) for further configuration. diff --git a/host/docker/compose.yml b/host/docker/compose.yml index d2c2e5ed..2869033a 100644 --- a/host/docker/compose.yml +++ b/host/docker/compose.yml @@ -1,14 +1,9 @@ -version: "3" - services: dnote: image: dnote/dnote:latest - environment: - APP_ENV: PRODUCTION - WebURL: localhost:3000 - DisableRegistration: "false" + container_name: dnote ports: - - 3000:3000 + - 3001:3001 volumes: - ./dnote_data:/data - restart: always + restart: unless-stopped diff --git a/pkg/e2e/server_test.go b/pkg/e2e/server_test.go index 52a2d311..c37b7320 100644 --- a/pkg/e2e/server_test.go +++ b/pkg/e2e/server_test.go @@ -151,8 +151,8 @@ func TestServerStartHelp(t *testing.T) { func TestServerStartInvalidConfig(t *testing.T) { cmd := exec.Command(testServerBinary, "start") - // Clear WebURL env var so validation fails - cmd.Env = []string{} + // Set invalid WebURL to trigger validation failure + cmd.Env = []string{"WebURL=not-a-valid-url"} output, err := cmd.CombinedOutput() diff --git a/pkg/server/.env.dev b/pkg/server/.env.dev index 334b1196..fe5dca07 100644 --- a/pkg/server/.env.dev +++ b/pkg/server/.env.dev @@ -5,5 +5,5 @@ SmtpPassword=mock-SmtpPassword SmtpHost=mock-SmtpHost SmtpPort=465 -WebURL=http://localhost:3000 +WebURL=http://localhost:3001 DisableRegistration=false diff --git a/pkg/server/.env.test b/pkg/server/.env.test index d633f83c..8c0befed 100644 --- a/pkg/server/.env.test +++ b/pkg/server/.env.test @@ -5,5 +5,5 @@ SmtpPassword=mock-SmtpPassword SmtpHost=mock-SmtpHost SmtpPort=465 -WebURL=http://localhost:3000 +WebURL=http://localhost:3001 DisableRegistration=false diff --git a/pkg/server/config/config.go b/pkg/server/config/config.go index 916bae4e..e941a9a5 100644 --- a/pkg/server/config/config.go +++ b/pkg/server/config/config.go @@ -93,8 +93,8 @@ type Params struct { func New(p Params) (Config, error) { c := Config{ AppEnv: getOrEnv(p.AppEnv, "APP_ENV", AppEnvProduction), - Port: getOrEnv(p.Port, "PORT", "3000"), - WebURL: getOrEnv(p.WebURL, "WebURL", ""), + Port: getOrEnv(p.Port, "PORT", "3001"), + WebURL: getOrEnv(p.WebURL, "WebURL", "http://localhost:3001"), DBPath: getOrEnv(p.DBPath, "DBPath", DefaultDBPath), DisableRegistration: p.DisableRegistration || readBoolEnv("DisableRegistration"), LogLevel: getOrEnv(p.LogLevel, "LOG_LEVEL", "info"), diff --git a/pkg/server/main.go b/pkg/server/main.go index 4e36b96d..e8fa1aa8 100644 --- a/pkg/server/main.go +++ b/pkg/server/main.go @@ -81,8 +81,8 @@ Flags: } appEnv := startFlags.String("appEnv", "", "Application environment (env: APP_ENV, default: PRODUCTION)") - port := startFlags.String("port", "", "Server port (env: PORT, default: 3000)") - webURL := startFlags.String("webUrl", "", "Full URL to server without trailing slash (env: WebURL, example: https://example.com)") + port := startFlags.String("port", "", "Server port (env: PORT, default: 3001)") + webURL := startFlags.String("webUrl", "", "Full URL to server without trailing slash (env: WebURL, default: http://localhost:3001)") dbPath := startFlags.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") disableRegistration := startFlags.Bool("disableRegistration", false, "Disable user registration (env: DisableRegistration, default: false)") logLevel := startFlags.String("logLevel", "", "Log level: debug, info, warn, or error (env: LOG_LEVEL, default: info)") diff --git a/scripts/cli/build.sh b/scripts/cli/build.sh index c805ba90..c5c6043c 100755 --- a/scripts/cli/build.sh +++ b/scripts/cli/build.sh @@ -57,7 +57,7 @@ build() { # build binary destDir="$outputDir/$platform-$arch" - ldflags="-X main.apiEndpoint=https://localhost:3000/api -X main.versionTag=$version" + ldflags="-X main.apiEndpoint=https://localhost:3001/api -X main.versionTag=$version" tags="fts5" pushd "$projectDir" diff --git a/scripts/cli/dev.sh b/scripts/cli/dev.sh index ce173496..d4a23e76 100755 --- a/scripts/cli/dev.sh +++ b/scripts/cli/dev.sh @@ -6,6 +6,6 @@ dir=$(dirname "${BASH_SOURCE[0]}") sudo rm -rf "$(which dnote)" "$GOPATH/bin/cli" # change tags to darwin if on macos -go install -ldflags "-X main.apiEndpoint=http://127.0.0.1:3000/api" --tags "linux fts5" "$dir/../../pkg/cli" +go install -ldflags "-X main.apiEndpoint=http://127.0.0.1:3001/api" --tags "linux fts5" "$dir/../../pkg/cli" sudo ln -s "$GOPATH/bin/cli" /usr/local/bin/dnote diff --git a/scripts/e2e/test.sh b/scripts/e2e/test.sh index 240d5c97..8ff94364 100755 --- a/scripts/e2e/test.sh +++ b/scripts/e2e/test.sh @@ -9,5 +9,5 @@ source "$basePath/pkg/server/.env.test" set +a pushd "$basePath"/pkg/e2e -go test --tags "fts5" ./... -p 1 +go test --tags "fts5" ./... -p 1 -v -timeout 5m popd diff --git a/scripts/server/dev.sh b/scripts/server/dev.sh index 5eb93328..7e1fe80e 100755 --- a/scripts/server/dev.sh +++ b/scripts/server/dev.sh @@ -23,7 +23,7 @@ cp "$basePath"/pkg/server/assets/static/* "$basePath/pkg/server/static" # run server moduleName="github.com/dnote/dnote" ldflags="-X '$moduleName/pkg/server/buildinfo.CSSFiles=main.css' -X '$moduleName/pkg/server/buildinfo.JSFiles=main.js' -X '$moduleName/pkg/server/buildinfo.Version=dev' -X '$moduleName/pkg/server/buildinfo.Standalone=true'" -task="go run -ldflags \"$ldflags\" --tags fts5 main.go start -port 3000" +task="go run -ldflags \"$ldflags\" --tags fts5 main.go start -port 3001" ( cd "$basePath/pkg/watcher" && \ From fd7b2a78b27fc48dde5cbfb0c0b4b94d0ade51d6 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 11 Oct 2025 13:35:39 -0700 Subject: [PATCH 06/33] Remove email verification (#688) * Remove email verified flag * Fix sass deprecation warnings --- pkg/server/app/email.go | 22 - pkg/server/app/email_test.go | 16 - pkg/server/app/errors.go | 3 - pkg/server/assets/package-lock.json | 529 ++++++++++++++---- pkg/server/assets/styles/src/_books.scss | 11 +- pkg/server/assets/styles/src/_buttons.scss | 56 +- pkg/server/assets/styles/src/_font.scss | 6 +- pkg/server/assets/styles/src/_global.scss | 36 +- pkg/server/assets/styles/src/_header.scss | 56 +- pkg/server/assets/styles/src/_home.scss | 66 +-- pkg/server/assets/styles/src/_login.scss | 25 +- pkg/server/assets/styles/src/_note.scss | 43 +- pkg/server/assets/styles/src/_rem.scss | 39 +- pkg/server/assets/styles/src/_responsive.scss | 18 +- pkg/server/assets/styles/src/_settings.scss | 68 +-- pkg/server/assets/styles/src/_shared.scss | 60 +- pkg/server/assets/styles/src/_theme.scss | 5 +- pkg/server/assets/styles/src/main.scss | 42 +- pkg/server/controllers/helpers.go | 2 - pkg/server/controllers/routes.go | 2 - pkg/server/controllers/users.go | 126 ----- pkg/server/controllers/users_test.go | 291 +--------- pkg/server/database/consts.go | 2 - pkg/server/database/models.go | 7 +- pkg/server/mailer/mailer.go | 7 - pkg/server/mailer/mailer_test.go | 39 -- pkg/server/mailer/templates/verify_email.txt | 5 - pkg/server/mailer/types.go | 6 - pkg/server/middleware/auth_test.go | 4 +- pkg/server/session/session.go | 10 +- pkg/server/session/session_test.go | 9 +- pkg/server/token/token_test.go | 2 +- .../templates/users/email_verification.gohtml | 2 - .../views/templates/users/settings.gohtml | 28 - pkg/server/views/view.go | 2 - 35 files changed, 731 insertions(+), 914 deletions(-) delete mode 100644 pkg/server/mailer/templates/verify_email.txt delete mode 100644 pkg/server/views/templates/users/email_verification.gohtml diff --git a/pkg/server/app/email.go b/pkg/server/app/email.go index 0897e415..2f721a6f 100644 --- a/pkg/server/app/email.go +++ b/pkg/server/app/email.go @@ -65,28 +65,6 @@ func getNoreplySender(webURL string) (string, error) { return addr, nil } -// SendVerificationEmail sends verification email -func (a *App) SendVerificationEmail(email, tokenValue string) error { - body, err := a.EmailTemplates.Execute(mailer.EmailTypeEmailVerification, mailer.EmailKindText, mailer.EmailVerificationTmplData{ - Token: tokenValue, - WebURL: a.WebURL, - }) - if err != nil { - return errors.Wrapf(err, "executing reset verification template for %s", email) - } - - from, err := GetSenderEmail(a.WebURL, defaultSender) - if err != nil { - return errors.Wrap(err, "getting the sender email") - } - - if err := a.EmailBackend.Queue("Verify your Dnote email address", from, []string{email}, mailer.EmailKindText, body); err != nil { - return errors.Wrapf(err, "queueing email for %s", email) - } - - return nil -} - // SendWelcomeEmail sends welcome email func (a *App) SendWelcomeEmail(email string) error { body, err := a.EmailTemplates.Execute(mailer.EmailTypeWelcome, mailer.EmailKindText, mailer.WelcomeTmplData{ diff --git a/pkg/server/app/email_test.go b/pkg/server/app/email_test.go index 1c68a96f..56270604 100644 --- a/pkg/server/app/email_test.go +++ b/pkg/server/app/email_test.go @@ -26,22 +26,6 @@ import ( "github.com/dnote/dnote/pkg/server/testutils" ) -func TestSendVerificationEmail(t *testing.T) { - emailBackend := testutils.MockEmailbackendImplementation{} - a := NewTest() - a.EmailBackend = &emailBackend - a.WebURL = "http://example.com" - - if err := a.SendVerificationEmail("alice@example.com", "mockTokenValue"); err != nil { - t.Fatal(err, "failed to perform") - } - - assert.Equalf(t, len(emailBackend.Emails), 1, "email queue count mismatch") - assert.Equal(t, emailBackend.Emails[0].From, "noreply@example.com", "email sender mismatch") - assert.DeepEqual(t, emailBackend.Emails[0].To, []string{"alice@example.com"}, "email sender mismatch") - -} - func TestSendWelcomeEmail(t *testing.T) { emailBackend := testutils.MockEmailbackendImplementation{} a := NewTest() diff --git a/pkg/server/app/errors.go b/pkg/server/app/errors.go index 250de5d1..895fc40f 100644 --- a/pkg/server/app/errors.go +++ b/pkg/server/app/errors.go @@ -79,7 +79,4 @@ var ( ErrInvalidPassword appError = "Invalid currnet password." // ErrEmailTooLong is an error for email length exceeding the limit ErrEmailTooLong appError = "Email is too long." - - // ErrEmailAlreadyVerified is an error for trying to verify email that is already verified - ErrEmailAlreadyVerified appError = "Email is already verified." ) diff --git a/pkg/server/assets/package-lock.json b/pkg/server/assets/package-lock.json index a37c4305..ec63082c 100644 --- a/pkg/server/assets/package-lock.json +++ b/pkg/server/assets/package-lock.json @@ -1,158 +1,493 @@ { "name": "assets", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" + "packages": { + "": { + "name": "assets", + "version": "1.0.0", + "license": "AGPL-3.0-or-later", + "devDependencies": { + "sass": "^1.50.1" } }, - "binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true + "node_modules/@parcel/watcher": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz", + "integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "dependencies": { + "detect-libc": "^1.0.3", + "is-glob": "^4.0.3", + "micromatch": "^4.0.5", + "node-addon-api": "^7.0.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.5.1", + "@parcel/watcher-darwin-arm64": "2.5.1", + "@parcel/watcher-darwin-x64": "2.5.1", + "@parcel/watcher-freebsd-x64": "2.5.1", + "@parcel/watcher-linux-arm-glibc": "2.5.1", + "@parcel/watcher-linux-arm-musl": "2.5.1", + "@parcel/watcher-linux-arm64-glibc": "2.5.1", + "@parcel/watcher-linux-arm64-musl": "2.5.1", + "@parcel/watcher-linux-x64-glibc": "2.5.1", + "@parcel/watcher-linux-x64-musl": "2.5.1", + "@parcel/watcher-win32-arm64": "2.5.1", + "@parcel/watcher-win32-ia32": "2.5.1", + "@parcel/watcher-win32-x64": "2.5.1" + } }, - "braces": { + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz", + "integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz", + "integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz", + "integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz", + "integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz", + "integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz", + "integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz", + "integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz", + "integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz", + "integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz", + "integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz", + "integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz", + "integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz", + "integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/braces": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, - "requires": { + "optional": true, + "dependencies": { "fill-range": "^7.1.1" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, "dependencies": { - "fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - } + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" } }, - "chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "node_modules/detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" + "optional": true, + "bin": { + "detect-libc": "bin/detect-libc.js" + }, + "engines": { + "node": ">=0.10" } }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, - "optional": true - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" + "optional": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" } }, - "immutable": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.0.0.tgz", - "integrity": "sha512-zIE9hX70qew5qTUjSS7wi1iwj/l7+m54KWU247nhM3v806UdGj1yDndXj+IOYxxtW9zyLI+xqFNZjTuDaLUqFw==", + "node_modules/immutable": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.3.tgz", + "integrity": "sha512-+chQdDfvscSF1SJqv2gn4SRO2ZyS3xL3r7IW/wWEEzrzLisnOlKiQu5ytC/BVNcS15C39WT2Hg/bjKjDMcu+zg==", "dev": true }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-extglob": { + "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.10.0" + } }, - "is-glob": { + "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "requires": { + "optional": true, + "dependencies": { "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-number": { + "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "dev": true, + "optional": true, + "engines": { + "node": ">=0.12.0" + } }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "optional": true, + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } }, - "picomatch": { + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "dev": true, + "optional": true + }, + "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true - }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "dev": true, - "requires": { - "picomatch": "^2.2.1" + "optional": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" } }, - "sass": { - "version": "1.50.1", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.50.1.tgz", - "integrity": "sha512-noTnY41KnlW2A9P8sdwESpDmo+KBNkukI1i8+hOK3footBUcohNHtdOJbckp46XO95nuvcHDDZ+4tmOnpK3hjw==", + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", "dev": true, - "requires": { - "chokidar": ">=3.0.0 <4.0.0", - "immutable": "^4.0.0", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/sass": { + "version": "1.93.2", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.93.2.tgz", + "integrity": "sha512-t+YPtOQHpGW1QWsh1CHQ5cPIr9lbbGZLZnbihP/D/qZj/yuV68m8qarcV17nvkOX81BCrvzAlq2klCQFZghyTg==", + "dev": true, + "dependencies": { + "chokidar": "^4.0.0", + "immutable": "^5.0.2", "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + }, + "optionalDependencies": { + "@parcel/watcher": "^2.4.1" } }, - "source-map-js": { + "node_modules/source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "to-regex-range": { + "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, - "requires": { + "optional": true, + "dependencies": { "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" } } } diff --git a/pkg/server/assets/styles/src/_books.scss b/pkg/server/assets/styles/src/_books.scss index 6f58ef94..c94c4347 100644 --- a/pkg/server/assets/styles/src/_books.scss +++ b/pkg/server/assets/styles/src/_books.scss @@ -1,3 +1,6 @@ +@use "rem"; +@use "theme"; + /* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors * * This file is part of Dnote. @@ -18,12 +21,12 @@ .books-page { .books-content { - padding: rem(16px) rem(24px); - margin-top: rem(16px); + padding: rem.rem(16px) rem.rem(24px); + margin-top: rem.rem(16px); h1 { - border-bottom: 1px solid $lighter-gray; - margin-bottom: rem(12px); + border-bottom: 1px solid theme.$lighter-gray; + margin-bottom: rem.rem(12px); } } } diff --git a/pkg/server/assets/styles/src/_buttons.scss b/pkg/server/assets/styles/src/_buttons.scss index ef1095d5..16059864 100644 --- a/pkg/server/assets/styles/src/_buttons.scss +++ b/pkg/server/assets/styles/src/_buttons.scss @@ -16,9 +16,11 @@ * along with Dnote. If not, see . */ -@import './theme'; -@import './rem'; -@import './font'; +@use "sass:color"; +@use 'theme'; +@use 'rem'; +@use 'font'; +@use "responsive"; @mixin button($text-color, $background-color) { color: $text-color; @@ -26,7 +28,7 @@ &:not(:disabled):hover { color: $text-color; - background-color: darken($background-color, 5%); + background-color: color.adjust($background-color, $lightness: -5%); box-shadow: 0px 0px 4px 2px #cacaca; } } @@ -87,40 +89,40 @@ button:disabled { } .button-small { - @include font-size('small'); - padding: rem(4px) rem(12px); + @include font.font-size('small'); + padding: rem.rem(4px) rem.rem(12px); } .button-normal { // @include font-size('small'); - padding: rem(8px) rem(16px); + padding: rem.rem(8px) rem.rem(16px); } .button-large { - @include font-size('medium'); + @include font.font-size('medium'); - padding: rem(8px) rem(24px); + padding: rem.rem(8px) rem.rem(24px); - @include breakpoint(md) { - padding: rem(12px) rem(36px); + @include responsive.breakpoint(md) { + padding: rem.rem(12px) rem.rem(36px); } - @include breakpoint(lg) { - padding: rem(12px) rem(48px); + @include responsive.breakpoint(lg) { + padding: rem.rem(12px) rem.rem(48px); } } .button-xlarge { - @include font-size('x-large'); + @include font.font-size('x-large'); - padding: rem(16px) rem(24px); + padding: rem.rem(16px) rem.rem(24px); - @include breakpoint(md) { - padding: rem(12px) rem(36px); + @include responsive.breakpoint(md) { + padding: rem.rem(12px) rem.rem(36px); } - @include breakpoint(lg) { - padding: rem(16px) rem(48px); + @include responsive.breakpoint(lg) { + padding: rem.rem(16px) rem.rem(48px); } } @@ -133,23 +135,23 @@ button:disabled { } .button-second { - @include button($black, $second); + @include button(theme.$black, theme.$second); } .button-second-outline { - @include button-outline($black, $second); + @include button-outline(theme.$black, theme.$second); } .button-third { - @include button(#ffffff, $third); + @include button(#ffffff, theme.$third); } .button-third-outline { - @include button-outline($third, $third); + @include button-outline(theme.$third, theme.$third); } .button-danger { - @include button-outline($danger-text, $danger-text); + @include button-outline(theme.$danger-text, theme.$danger-text); font-weight: 600; } @@ -158,7 +160,7 @@ button:disabled { } .button ~ .button { - margin-left: rem(12px); + margin-left: rem.rem(12px); } .button-no-ui { @@ -173,10 +175,10 @@ button:disabled { } .button-link { - color: $link; + color: theme.$link; &:hover { - color: $link-hover; + color: theme.$link-hover; text-decoration: underline; } } diff --git a/pkg/server/assets/styles/src/_font.scss b/pkg/server/assets/styles/src/_font.scss index f64b7236..37bc3163 100644 --- a/pkg/server/assets/styles/src/_font.scss +++ b/pkg/server/assets/styles/src/_font.scss @@ -16,7 +16,7 @@ * along with Dnote. If not, see . */ -@import './responsive'; +@use 'responsive'; $lowDecay: 0.1; $medDecay: 0.15; @@ -95,12 +95,12 @@ $highDecay: 0.2; font-size: $smSizeValue * 1px; font-size: $smSizeValue * 0.1rem; - @include breakpoint(md) { + @include responsive.breakpoint(md) { font-size: $mdSizeValue * 1px; font-size: $mdSizeValue * 0.1rem; } - @include breakpoint(lg) { + @include responsive.breakpoint(lg) { font-size: $lgSizeValue * 1px; font-size: $lgSizeValue * 0.1rem; } diff --git a/pkg/server/assets/styles/src/_global.scss b/pkg/server/assets/styles/src/_global.scss index a91a9a95..8c497658 100644 --- a/pkg/server/assets/styles/src/_global.scss +++ b/pkg/server/assets/styles/src/_global.scss @@ -1,3 +1,9 @@ +@use "font"; +@use "rem"; +@use "responsive"; +@use "theme"; +@use "variables"; + /* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors * * This file is part of Dnote. @@ -20,8 +26,8 @@ position: relative; display: flex; flex-direction: column; - background: $lighter-gray; - min-height: calc(100vh - #{$header-height}); + background: theme.$lighter-gray; + min-height: calc(100vh - #{variables.$header-height}); // margin-bottom: $footer-height; &.nofooter { @@ -29,49 +35,49 @@ } &.noheader:not(.nofooter) { - min-height: calc(100vh - #{$footer-height}); + min-height: calc(100vh - #{variables.$footer-height}); } &.nofooter:not(.noheader) { - min-height: calc(100vh - #{$header-height}); + min-height: calc(100vh - #{variables.$header-height}); } &.nofooter.noheader { min-height: 100vh; } - @include breakpoint(lg) { + @include responsive.breakpoint(lg) { margin-bottom: 0; - min-height: calc(100vh - #{$header-height}); + min-height: calc(100vh - #{variables.$header-height}); } } /* partials */ .partial--time { - color: $gray; - @include font-size('small'); + color: theme.$gray; + @include font.font-size('small'); .mobile-text { - @include breakpoint(md) { + @include responsive.breakpoint(md) { display: none; } } .text { display: none; - @include breakpoint(md) { + @include responsive.breakpoint(md) { display: inherit; } } } .partial--page-toolbar { - @include breakpoint(lg) { - height: rem(48px); - border-radius: rem(4px); - background: $light; + @include responsive.breakpoint(lg) { + height: rem.rem(48px); + border-radius: rem.rem(4px); + background: theme.$light; box-shadow: 0 0 8px rgba(0, 0, 0, 0.14); &.bottom { - margin-top: rem(12px); + margin-top: rem.rem(12px); } } } diff --git a/pkg/server/assets/styles/src/_header.scss b/pkg/server/assets/styles/src/_header.scss index 61c7b5bf..c952599e 100644 --- a/pkg/server/assets/styles/src/_header.scss +++ b/pkg/server/assets/styles/src/_header.scss @@ -16,8 +16,12 @@ * along with Dnote. If not, see . */ -@import './theme'; -@import './variables'; +@use "sass:color"; +@use 'theme'; +@use 'variables'; +@use "font"; +@use "rem"; +@use "responsive"; .header-wrapper { padding: 0; @@ -25,7 +29,7 @@ position: relative; display: flex; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); - background: $first; + background: theme.$first; align-items: stretch; justify-content: space-between; flex: 1; @@ -33,13 +37,13 @@ position: sticky; top: 0; z-index: 4; - height: $header-height; + height: variables.$header-height; .container { height: 100%; } - @include breakpoint(md) { + @include responsive.breakpoint(md) { flex-direction: row; } @@ -60,15 +64,15 @@ .search-wrapper { align-items: center; display: flex; - margin-left: rem(32px); + margin-left: rem.rem(32px); } .search-input { - width: rem(356px); + width: rem.rem(356px); border: 0; padding: 4px 12px; - border-radius: rem(4px); - @include font-size('small'); + border-radius: rem.rem(4px); + @include font.font-size('small'); } .brand { @@ -81,7 +85,7 @@ } .main-nav { - margin-left: rem(32px); + margin-left: rem.rem(32px); display: flex; .list { @@ -94,22 +98,22 @@ } .nav-link { - @include font-size('small'); + @include font.font-size('small'); display: flex; font-weight: 600; align-items: center; - padding: 0 rem(16px); - color: $white; + padding: 0 rem.rem(16px); + color: theme.$white; &:hover { - color: $white; + color: theme.$white; text-decoration: none; - background: lighten($first, 10%); + background: color.adjust(theme.$first, $lightness: 10%); } } .nav-item { - @include font-size('small'); + @include font.font-size('small'); font-weight: 600; } } @@ -131,7 +135,7 @@ display: none; position: absolute; background-color: #f1f1f1; - width: rem(240px); + width: rem.rem(240px); background: #fff; border: 1px solid #d8d8d8; border-radius: 4px; @@ -154,15 +158,15 @@ } .account-dropdown-header { - @include font-size('small'); - color: $light-gray; - padding: rem(8px) rem(12px); + @include font.font-size('small'); + color: theme.$light-gray; + padding: rem.rem(8px) rem.rem(12px); display: block; margin-bottom: 0; white-space: nowrap; svg { - fill: $light-gray; + fill: theme.$light-gray; } .email { @@ -173,15 +177,15 @@ } .dropdown-link { - @include font-size('small'); + @include font.font-size('small'); white-space: pre; - padding: rem(8px) rem(14px); + padding: rem.rem(8px) rem.rem(14px); width: 100%; display: block; color: black; &:hover { - background: $lighter-gray; + background: theme.$lighter-gray; text-decoration: none; color: #0056b3; } @@ -192,7 +196,7 @@ } &:not(.disabled):focus { - background: $lighter-gray; + background: theme.$lighter-gray; color: #0056b3; outline: 1px dotted gray; } @@ -204,7 +208,7 @@ } .session-notice { - margin-left: rem(4px); + margin-left: rem.rem(4px); } } } diff --git a/pkg/server/assets/styles/src/_home.scss b/pkg/server/assets/styles/src/_home.scss index b1eac511..ce72a9f3 100644 --- a/pkg/server/assets/styles/src/_home.scss +++ b/pkg/server/assets/styles/src/_home.scss @@ -16,21 +16,23 @@ * along with Dnote. If not, see . */ -@import './theme'; -@import './font'; +@use 'theme'; +@use 'font'; +@use "rem"; +@use "responsive"; .home-page { .note-group-list { flex-grow: 1; - @include breakpoint(lg) { - margin-top: rem(16px); + @include responsive.breakpoint(lg) { + margin-top: rem.rem(16px); } .note-group-list-empty { - padding: rem(40px) rem(16px); + padding: rem.rem(40px) rem.rem(16px); text-align: center; - color: $gray; + color: theme.$gray; } } @@ -40,29 +42,29 @@ box-shadow: 0 0 8px rgba(0, 0, 0, 0.14); &:not(:first-of-type) { - margin-top: rem(20px); + margin-top: rem.rem(20px); - @include breakpoint(md) { - margin-top: rem(24px); + @include responsive.breakpoint(md) { + margin-top: rem.rem(24px); } } .note-group-header { - @include font-size('small'); + @include font.font-size('small'); display: flex; justify-content: space-between; color: white; - padding: rem(12px) rem(16px); - background: $light; - color: $black; - border-bottom: 1px solid $border-color; + padding: rem.rem(12px) rem.rem(16px); + background: theme.$light; + color: theme.$black; + border-bottom: 1px solid theme.$border-color; border-top-left-radius: 4px; border-top-right-radius: 4px; } .date { font-weight: 600; - @include font-size('small'); + @include font.font-size('small'); } .mask { @@ -78,7 +80,7 @@ .header-date { font-weight: 600; - @include font-size('regular'); + @include font.font-size('regular'); } .header-count { font-weight: 300; @@ -101,23 +103,23 @@ background: white; position: relative; - border-bottom: 1px solid $border-color; + border-bottom: 1px solid theme.$border-color; .link { - color: $black; + color: theme.$black; display: block; - padding: rem(12px) rem(16px); + padding: rem.rem(12px) rem.rem(16px); border: 2px solid transparent; &:hover { text-decoration: none; - background: $light-blue; + background: theme.$light-blue; color: inherit; } } .meta { - line-height: rem(16px); + line-height: rem.rem(16px); } .body { @@ -131,11 +133,11 @@ } .note-content { - margin-top: rem(12px); + margin-top: rem.rem(12px); line-height: 1.6rem; overflow: hidden; text-overflow: ellipsis; - color: $gray; + color: theme.$gray; } .book-label { @@ -143,11 +145,11 @@ text-overflow: ellipsis; white-space: nowrap; font-weight: 700; - @include font-size('small'); + @include font.font-size('small'); width: 212px; - @include breakpoint('md') { + @include responsive.breakpoint('md') { width: 320px; } } @@ -155,7 +157,7 @@ .match { display: inline-block; background: #f7f77d; - padding: rem(4px) rem(4px); + padding: rem.rem(4px) rem.rem(4px); } } @@ -168,12 +170,12 @@ align-items: center; .paginator-info { - @include font-size('small'); - color: $gray; + @include font.font-size('small'); + color: theme.$gray; } .paginator-link { - padding: rem(12px) rem(12px); + padding: rem.rem(12px) rem.rem(12px); &.disabled { cursor: not-allowed; @@ -181,10 +183,10 @@ } .paginator-link-prev { - margin-left: rem(8px); + margin-left: rem.rem(8px); - @include breakpoint(md) { - margin-left: rem(20px); + @include responsive.breakpoint(md) { + margin-left: rem.rem(20px); } } diff --git a/pkg/server/assets/styles/src/_login.scss b/pkg/server/assets/styles/src/_login.scss index 49d5c42c..9200a911 100644 --- a/pkg/server/assets/styles/src/_login.scss +++ b/pkg/server/assets/styles/src/_login.scss @@ -16,11 +16,12 @@ * along with Dnote. If not, see . */ -@import './theme'; -@import './font'; +@use 'theme'; +@use 'font'; +@use "rem"; .auth-page { - background: $lighter-gray; + background: theme.$lighter-gray; text-align: center; min-height: 100vh; padding: 50px 0; @@ -30,8 +31,8 @@ } .heading { - color: $black; - @include font-size('2x-large'); + color: theme.$black; + @include font.font-size('2x-large'); font-weight: 300; margin-top: 12px; margin-bottom: 0; @@ -58,15 +59,15 @@ .callout { color: #7c7c7c; - @include font-size('small'); + @include font.font-size('small'); } .cta { - @include font-size('small'); + @include font.font-size('small'); } .panel { - border: 1px solid $border-color; - background: $white; + border: 1px solid theme.$border-color; + background: theme.$white; border-radius: 2px; padding: 20px; text-align: left; @@ -82,21 +83,21 @@ } } .label { - @include font-size('small'); + @include font.font-size('small'); font-weight: 600; width: 100%; margin-bottom: 0; } .forgot { - @include font-size('small'); + @include font.font-size('small'); float: right; font-weight: 400; } &.password-reset-page { .email-input { - margin-top: rem(16px); + margin-top: rem.rem(16px); } } diff --git a/pkg/server/assets/styles/src/_note.scss b/pkg/server/assets/styles/src/_note.scss index 623d7969..edc83a34 100644 --- a/pkg/server/assets/styles/src/_note.scss +++ b/pkg/server/assets/styles/src/_note.scss @@ -1,3 +1,8 @@ +@use "font"; +@use "rem"; +@use "responsive"; +@use "theme"; + /* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors * * This file is part of Dnote. @@ -18,7 +23,7 @@ .note-page { // min-height: calc(100vh - 57px); - background: $lighter-gray; + background: theme.$lighter-gray; flex-grow: 1; flex-basis: 0; @@ -38,8 +43,8 @@ display: flex; align-items: center; justify-content: space-between; - padding: rem(12px) rem(16px); - border-bottom: 1px solid $border-color; + padding: rem.rem(12px) rem.rem(16px); + border-bottom: 1px solid theme.$border-color; } .header-left, .header-right { @@ -52,27 +57,27 @@ } .content-wrapper { - padding: rem(12px) rem(16px); + padding: rem.rem(12px) rem.rem(16px); } .collapsed-content { - color: $light-gray; + color: theme.$light-gray; } .footer { display: flex; justify-content: space-between; align-items: center; - @include font-size('small'); - padding: rem(12px) rem(16px); + @include font.font-size('small'); + padding: rem.rem(12px) rem.rem(16px); } .ts { - color: $light-gray; + color: theme.$light-gray; } .ts-lead { display: none; - @include breakpoint(md) { + @include responsive.breakpoint(md) { display: inline; } } @@ -83,13 +88,13 @@ } .book-label { - @include font-size('medium'); + @include font.font-size('medium'); font-weight: 600; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - color: $black; + color: theme.$black; a { color: inherit; @@ -103,17 +108,17 @@ // header .header { .book-label { - max-width: rem(200px); - margin-left: rem(12px); + max-width: rem.rem(200px); + margin-left: rem.rem(12px); - @include breakpoint(sm) { - max-width: rem(200px); + @include responsive.breakpoint(sm) { + max-width: rem.rem(200px); } - @include breakpoint(md) { - max-width: rem(420px); + @include responsive.breakpoint(md) { + max-width: rem.rem(420px); } - @include breakpoint(lg) { - max-width: rem(600px); + @include responsive.breakpoint(lg) { + max-width: rem.rem(600px); } } } diff --git a/pkg/server/assets/styles/src/_rem.scss b/pkg/server/assets/styles/src/_rem.scss index e875d0cd..cd736925 100644 --- a/pkg/server/assets/styles/src/_rem.scss +++ b/pkg/server/assets/styles/src/_rem.scss @@ -1,3 +1,6 @@ +@use "sass:list"; +@use "sass:map"; +@use "sass:meta"; /* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors * * This file is part of Dnote. @@ -24,6 +27,8 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +@use "sass:math"; + // assume 1 rem = 10 px // achieved by body { font-size: 62.5%; ) $rem-baseline: 10px !default; @@ -32,24 +37,24 @@ $rem-px-only: false !default; @function rem-separator($list, $separator: false) { @if $separator == "comma" or $separator == "space" { - @return append($list, null, $separator); + @return list.append($list, null, $separator); } - @if function-exists("list-separator") == true { - @return list-separator($list); + @if meta.function-exists("list-separator") == true { + @return list.separator($list); } // list-separator polyfill by Hugo Giraudel (https://sass-compatibility.github.io/#list_separator_function) $test-list: (); @each $item in $list { - $test-list: append($test-list, $item, space); + $test-list: list.append($test-list, $item, space); } @return if($test-list == $list, space, comma); } @mixin rem-baseline($zoom: 100%) { - font-size: $zoom / 16px * $rem-baseline; + font-size: math.div($zoom, 16px) * $rem-baseline; } @function rem-convert($to, $values...) { @@ -57,28 +62,28 @@ $rem-px-only: false !default; $separator: rem-separator($values); @each $value in $values { - @if type-of($value) == "number" and unit($value) == "rem" and $to == "px" { - $result: append($result, $value / 1rem * $rem-baseline, $separator); + @if meta.type-of($value) == "number" and math.unit($value) == "rem" and $to == "px" { + $result: list.append($result, math.div($value, 1rem) * $rem-baseline, $separator); } @else if - type-of($value) == + meta.type-of($value) == "number" and - unit($value) == + math.unit($value) == "px" and $to == "rem" { - $result: append($result, $value / $rem-baseline * 1rem, $separator); - } @else if type-of($value) == "list" { + $result: list.append($result, math.div($value, $rem-baseline) * 1rem, $separator); + } @else if meta.type-of($value) == "list" { $value-separator: rem-separator($value); $value: rem-convert($to, $value...); $value: rem-separator($value, $value-separator); - $result: append($result, $value, $separator); + $result: list.append($result, $value, $separator); } @else { - $result: append($result, $value, $separator); + $result: list.append($result, $value, $separator); } } - @return if(length($result) == 1, nth($result, 1), $result); + @return if(list.length($result) == 1, list.nth($result, 1), $result); } @function rem($values...) { @@ -90,9 +95,9 @@ $rem-px-only: false !default; } @mixin rem($properties, $values...) { - @if type-of($properties) == "map" { - @each $property in map-keys($properties) { - @include rem($property, map-get($properties, $property)); + @if meta.type-of($properties) == "map" { + @each $property in map.keys($properties) { + @include rem($property, map.get($properties, $property)); } } @else { @each $property in $properties { diff --git a/pkg/server/assets/styles/src/_responsive.scss b/pkg/server/assets/styles/src/_responsive.scss index 05188e4c..9aaf9a7f 100644 --- a/pkg/server/assets/styles/src/_responsive.scss +++ b/pkg/server/assets/styles/src/_responsive.scss @@ -16,39 +16,39 @@ * along with Dnote. If not, see . */ -@import './variables'; +@use 'variables'; @mixin breakpoint($point) { @if $point == xl { - @media (min-width: $xl-breakpoint) { + @media (min-width: variables.$xl-breakpoint) { @content; } } @else if $point == lg { - @media (min-width: $lg-breakpoint) { + @media (min-width: variables.$lg-breakpoint) { @content; } } @else if $point == md { - @media (min-width: $md-breakpoint) { + @media (min-width: variables.$md-breakpoint) { @content; } } @else if $point == sm { - @media (min-width: $sm-breakpoint) { + @media (min-width: variables.$sm-breakpoint) { @content; } } @else if $point == smonly { - @media (min-width: $sm-breakpoint) and (max-width: $md-breakpoint - 1px) { + @media (min-width: variables.$sm-breakpoint) and (max-width: variables.$md-breakpoint - 1px) { @content; } } @else if $point == smdown { - @media (max-width: $md-breakpoint - 1px) { + @media (max-width: variables.$md-breakpoint - 1px) { @content; } } @else if $point == mdonly { - @media (min-width: $md-breakpoint) and (max-width: $lg-breakpoint - 1px) { + @media (min-width: variables.$md-breakpoint) and (max-width: variables.$lg-breakpoint - 1px) { @content; } } @else if $point == mddown { - @media (max-width: $lg-breakpoint - 1px) { + @media (max-width: variables.$lg-breakpoint - 1px) { @content; } } diff --git a/pkg/server/assets/styles/src/_settings.scss b/pkg/server/assets/styles/src/_settings.scss index 6b89ed7a..2f5d439d 100644 --- a/pkg/server/assets/styles/src/_settings.scss +++ b/pkg/server/assets/styles/src/_settings.scss @@ -16,17 +16,19 @@ * along with Dnote. If not, see . */ -@import './theme'; -@import './font'; +@use 'theme'; +@use 'font'; +@use "rem"; +@use "responsive"; .settings-page { .sidebar { box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); background: white; - margin-bottom: rem(20px); - margin-top: rem(20px); + margin-bottom: rem.rem(20px); + margin-top: rem.rem(20px); - @include breakpoint(lg) { + @include responsive.breakpoint(lg) { margin-bottom: 0; margin-top: 0; } @@ -34,30 +36,30 @@ .sidebar-item { display: block; - padding: rem(12px) rem(16px); + padding: rem.rem(12px) rem.rem(16px); border-left: 4px solid transparent; - @include font-size('regular'); + @include font.font-size('regular'); &:hover { text-decoration: none; - background: $light; + background: theme.$light; } &.active { font-weight: 600; - border-left-color: $first; + border-left-color: theme.$first; } } .setting-section-wrapper { .header { - @include breakpoint(lg) { + @include responsive.breakpoint(lg) { display: none; } } .setting-section { - margin-top: rem(24px); + margin-top: rem.rem(24px); background: white; box-shadow: 0 0 8px rgba(0, 0, 0, 0.14); @@ -67,27 +69,27 @@ } .section-heading { - @include font-size('regular'); + @include font.font-size('regular'); font-weight: 600; - padding-bottom: rem(4px); - background: $light; - padding: rem(16px) rem(20px); + padding-bottom: rem.rem(4px); + background: theme.$light; + padding: rem.rem(16px) rem.rem(20px); } .section-content { - margin-top: rem(20px); + margin-top: rem.rem(20px); } .actions { - margin-top: rem(18px); + margin-top: rem.rem(18px); text-align: right; } } .setting-row { - padding: rem(16px) rem(20px); + padding: rem.rem(16px) rem.rem(20px); &:not(:last-child) { - border-bottom: 1px solid $border-color; + border-bottom: 1px solid theme.$border-color; } .setting-row-summary { @@ -95,7 +97,7 @@ flex-direction: column; // align-items: flex-start; - @include breakpoint(md) { + @include responsive.breakpoint(md) { flex-direction: row; justify-content: space-between; align-items: center; @@ -103,24 +105,24 @@ } .setting-row-main { - padding-top: rem(24px); + padding-top: rem.rem(24px); } .setting-name { font-weight: 400; - @include font-size('regular'); + @include font.font-size('regular'); margin-bottom: 0; } .setting-desc { margin-bottom: 0; - @include font-size('small'); - color: $gray; + @include font.font-size('small'); + color: theme.$gray; } .setting-action { display: flex; flex-direction: column; - @include breakpoint(md) { + @include responsive.breakpoint(md) { flex-direction: row; } } @@ -130,9 +132,9 @@ word-break: break-all; justify-content: space-between; align-items: center; - margin-top: rem(4px); + margin-top: rem.rem(4px); - @include breakpoint(md) { + @include responsive.breakpoint(md) { flex-direction: row; align-items: center; margin-top: 0; @@ -140,26 +142,26 @@ } .setting-edit { - color: $link; + color: theme.$link; padding: 0; &:hover { - color: $link-hover; + color: theme.$link-hover; } - @include breakpoint(md) { - margin-left: rem(16px); + @include responsive.breakpoint(md) { + margin-left: rem.rem(16px); } } .input-row { & ~ .input-row, .input-row { - margin-top: rem(12px); + margin-top: rem.rem(12px); } } } .email-verification-form { - margin-left: rem(12px); + margin-left: rem.rem(12px); } } diff --git a/pkg/server/assets/styles/src/_shared.scss b/pkg/server/assets/styles/src/_shared.scss index 78d35e03..1b7697c1 100644 --- a/pkg/server/assets/styles/src/_shared.scss +++ b/pkg/server/assets/styles/src/_shared.scss @@ -16,8 +16,10 @@ * along with Dnote. If not, see . */ -@import './font'; -@import './responsive'; +@use 'font'; +@use 'responsive'; +@use "rem"; +@use "theme"; @keyframes holderPulse { 0% { @@ -46,7 +48,7 @@ input[type='email']:disabled, input[type='number']:disabled, input[type='password']:disabled, textarea:disabled { - background-color: $lighter-gray; + background-color: theme.$lighter-gray; cursor: not-allowed; } @@ -76,17 +78,17 @@ button { } .text-input { - border: 1px solid $border-color; - padding: rem(8px) rem(12px); + border: 1px solid theme.$border-color; + padding: rem.rem(8px) rem.rem(12px); position: relative; - border-radius: rem(4px); + border-radius: rem.rem(4px); display: block; &::placeholder { - color: $gray; + color: theme.$gray; } &:focus { - border-color: $light-blue; + border-color: theme.$light-blue; box-shadow: inset 0 1px 2px rgba(24, 31, 35, 0.075), 0 0 0 0.2em rgba(4, 100, 210, 0.3); outline: none; @@ -94,11 +96,11 @@ button { } .text-input-small { - padding: rem(4px) rem(12px); + padding: rem.rem(4px) rem.rem(12px); } .text-input-medium { - padding: rem(8px) rem(12px); + padding: rem.rem(8px) rem.rem(12px); } .text-input-stretch { @@ -110,10 +112,10 @@ button { } a { - color: $link; + color: theme.$link; &:hover { - color: $link-hover; + color: theme.$link-hover; } } @@ -129,12 +131,12 @@ h6 { // grid .container.mobile-fw { - @include breakpoint(mddown) { + @include responsive.breakpoint(mddown) { max-width: 100%; } } .container.mobile-nopadding { - @include breakpoint(mddown) { + @include responsive.breakpoint(mddown) { padding-left: 0; padding-right: 0; @@ -154,30 +156,30 @@ html body { } .page { - padding-top: rem(20px); - padding-bottom: rem(20px); + padding-top: rem.rem(20px); + padding-bottom: rem.rem(20px); &.page-mobile-full { padding-top: 0; padding-bottom: 0; - @include breakpoint(lg) { - padding-top: rem(32px); - padding-bottom: rem(32px); + @include responsive.breakpoint(lg) { + padding-top: rem.rem(32px); + padding-bottom: rem.rem(32px); } } } .page-header { - margin-top: rem(20px); + margin-top: rem.rem(20px); &.page-header-full { - margin-bottom: rem(20px); + margin-bottom: rem.rem(20px); } - @include breakpoint(lg) { + @include responsive.breakpoint(lg) { // padding: 0; - margin-bottom: rem(20px); + margin-bottom: rem.rem(20px); margin-top: 0; } } @@ -189,7 +191,7 @@ html body { background-repeat: no-repeat; background-position: right 8px center; background-size: 8px 10px; - border: 1px solid $border-color; + border: 1px solid theme.$border-color; min-height: 34px; padding: 6px 8px; padding-right: 24px; @@ -207,7 +209,7 @@ html body { &:disabled, &.form-select-disabled { background-image: url('data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABAAAAAUCAYAAACEYr13AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEKSURBVHgBzVTNDYIwFC4NB46OwAi4gY7gETgoE6gTGCcwTgAJ4efGCLCBjMAIXrmA3yOhQazQhJj4JQ0v7fte3/e1hbFfIk3TYxzHp6kc7dtCFEUW5/xBcdM0a9d1S1kel00mSWKCnIkkxDSnXADIMYYEU9O0zPf91WwB6L6NyB3atrUMw7hNFkCbFyROmXYYmypMDMNwo+t6ztSwtW27oEAXrXBuwu2rCht+WPgU7C8gPCBzYOBKhQS5FTwIKBYeQFeJoWyiKNYH5Co6OCuQr/0JdBuPVyElQCd7GRMb3B3HebsHHzexrmvyQvZwqjFZWsDzvCc62BFhSGYD3UMsfs6ToKOd+6EsxgtrtWLW4gUN3AAAAABJRU5ErkJggg=='); - background-color: $lighter-gray; + background-color: theme.$lighter-gray; } } @@ -215,12 +217,12 @@ html body { // width: 100%; width: auto; font-weight: 600; - margin-bottom: rem(4px); - @include font-size('small'); + margin-bottom: rem.rem(4px); + @include font.font-size('small'); } .page-heading { - @include font-size('x-large'); + @include font.font-size('x-large'); } .dropdown-caret { @@ -231,7 +233,7 @@ html body { border-right: 4px solid transparent; border-bottom: 0 solid transparent; border-left: 4px solid transparent; - margin-left: rem(8px); + margin-left: rem.rem(8px); } .divider { diff --git a/pkg/server/assets/styles/src/_theme.scss b/pkg/server/assets/styles/src/_theme.scss index e17497a6..f37d81a5 100644 --- a/pkg/server/assets/styles/src/_theme.scss +++ b/pkg/server/assets/styles/src/_theme.scss @@ -1,3 +1,4 @@ +@use "sass:color"; /* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors * * This file is part of Dnote. @@ -26,7 +27,7 @@ $lighter-gray: #f3f3f3; $dark-gray: #637283; // primary colors -$first: #072a40; +$first: #333745; $second: #e7e7e7; $third: #0a4b73; @@ -35,7 +36,7 @@ $border-color: #d8d8d8; $border-color-light: $lighter-gray; $link: #6f53c0; -$link-hover: darken($link, 5%); +$link-hover: color.adjust($link, $lightness: -5%); $danger-text: #cb2431; $danger-background: #f8d7da; diff --git a/pkg/server/assets/styles/src/main.scss b/pkg/server/assets/styles/src/main.scss index df45971a..4a5a7379 100644 --- a/pkg/server/assets/styles/src/main.scss +++ b/pkg/server/assets/styles/src/main.scss @@ -16,25 +16,25 @@ * along with Dnote. If not, see . */ -@import './reboot'; -@import './grid'; -@import './bootstrap'; -@import './buttons'; -@import './responsive'; -@import './select'; -@import './shared'; -@import './marker'; -@import './rem'; -@import './markdown'; -@import './hljs'; +@use 'reboot'; +@use 'grid'; +@use 'bootstrap'; +@use 'buttons'; +@use 'responsive'; +@use 'select'; +@use 'shared'; +@use 'marker'; +@use 'rem'; +@use 'markdown'; +@use 'hljs'; -@import './login'; -@import './home'; -@import './note'; -@import './books'; -@import './settings'; -@import './header'; -@import './global'; +@use 'login'; +@use 'home'; +@use 'note'; +@use 'books'; +@use 'settings'; +@use 'header'; +@use 'global'; html { font-size: 62.5%; /* 1.0 rem = 10px */ @@ -74,11 +74,11 @@ img { } .container.mobile-nopadding { - @include breakpoint(mdonly) { + @include responsive.breakpoint(mdonly) { max-width: 100%; } - @include breakpoint(mddown) { + @include responsive.breakpoint(mddown) { padding-left: 0; padding-right: 0; @@ -137,7 +137,7 @@ img { } .input { - border-radius: rem(4px); + border-radius: rem.rem(4px); background-clip: padding-box; border: 1px solid #ced4da; transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; diff --git a/pkg/server/controllers/helpers.go b/pkg/server/controllers/helpers.go index 0e88034b..72100c8b 100644 --- a/pkg/server/controllers/helpers.go +++ b/pkg/server/controllers/helpers.go @@ -232,8 +232,6 @@ func getStatusCode(err error) int { return http.StatusUnauthorized case app.ErrEmailTooLong: return http.StatusBadRequest - case app.ErrEmailAlreadyVerified: - return http.StatusConflict case app.ErrMissingToken: return http.StatusBadRequest case app.ErrExpiredToken: diff --git a/pkg/server/controllers/routes.go b/pkg/server/controllers/routes.go index 0c873fa3..db8b706d 100644 --- a/pkg/server/controllers/routes.go +++ b/pkg/server/controllers/routes.go @@ -58,8 +58,6 @@ func NewWebRoutes(a *app.App, c *Controllers) []Route { {"PATCH", "/password-reset", c.Users.PasswordReset, true}, {"GET", "/password-reset/{token}", c.Users.PasswordResetConfirm, true}, {"POST", "/reset-token", c.Users.CreateResetToken, true}, - {"POST", "/verification-token", mw.Auth(a.DB, c.Users.CreateEmailVerificationToken, redirectGuest), true}, - {"GET", "/verify-email/{token}", mw.Auth(a.DB, c.Users.VerifyEmail, redirectGuest), true}, {"PATCH", "/account/profile", mw.Auth(a.DB, c.Users.ProfileUpdate, nil), true}, {"PATCH", "/account/password", mw.Auth(a.DB, c.Users.PasswordUpdate, nil), true}, diff --git a/pkg/server/controllers/users.go b/pkg/server/controllers/users.go index 4643f599..67baca6a 100644 --- a/pkg/server/controllers/users.go +++ b/pkg/server/controllers/users.go @@ -30,7 +30,6 @@ import ( "github.com/dnote/dnote/pkg/server/database" "github.com/dnote/dnote/pkg/server/helpers" "github.com/dnote/dnote/pkg/server/log" - "github.com/dnote/dnote/pkg/server/mailer" "github.com/dnote/dnote/pkg/server/token" "github.com/dnote/dnote/pkg/server/views" "github.com/gorilla/mux" @@ -80,10 +79,6 @@ func NewUsers(app *app.App, viewEngine *views.Engine) *Users { views.Config{Title: "About", Layout: "base", HelperFuncs: commonHelpers, HeaderTemplate: "navbar"}, "users/settings_about", ), - EmailVerificationView: viewEngine.NewView(app, - views.Config{Layout: "base", HelperFuncs: commonHelpers, HeaderTemplate: "navbar"}, - "users/email_verification", - ), app: app, } } @@ -96,7 +91,6 @@ type Users struct { AboutView *views.View PasswordResetView *views.View PasswordResetConfirmView *views.View - EmailVerificationView *views.View app *app.App } @@ -599,10 +593,6 @@ func (u *Users) ProfileUpdate(w http.ResponseWriter, r *http.Request) { return } - // check if email was changed - if form.Email != account.Email.String { - account.EmailVerified = false - } account.Email.String = form.Email if err := tx.Save(&account).Error; err != nil { @@ -620,119 +610,3 @@ func (u *Users) ProfileUpdate(w http.ResponseWriter, r *http.Request) { views.RedirectAlert(w, r, "/", http.StatusFound, alert) } -func (u *Users) VerifyEmail(w http.ResponseWriter, r *http.Request) { - vd := views.Data{} - - vars := mux.Vars(r) - tokenValue := vars["token"] - - if tokenValue == "" { - handleHTMLError(w, r, app.ErrMissingToken, "Missing email verification token", u.EmailVerificationView, vd) - return - } - - var token database.Token - if err := u.app.DB. - Where("value = ? AND type = ?", tokenValue, database.TokenTypeEmailVerification). - First(&token).Error; err != nil { - handleHTMLError(w, r, app.ErrInvalidToken, "Finding token", u.EmailVerificationView, vd) - return - } - - if token.UsedAt != nil { - handleHTMLError(w, r, app.ErrInvalidToken, "Token has already been used.", u.EmailVerificationView, vd) - return - } - - // Expire after ttl - if time.Since(token.CreatedAt).Minutes() > 30 { - handleHTMLError(w, r, app.ErrExpiredToken, "Token has expired.", u.EmailVerificationView, vd) - return - } - - var account database.Account - if err := u.app.DB.Where("user_id = ?", token.UserID).First(&account).Error; err != nil { - handleHTMLError(w, r, err, "finding account", u.EmailVerificationView, vd) - return - } - if account.EmailVerified { - handleHTMLError(w, r, app.ErrEmailAlreadyVerified, "Already verified", u.EmailVerificationView, vd) - return - } - - tx := u.app.DB.Begin() - account.EmailVerified = true - if err := tx.Save(&account).Error; err != nil { - tx.Rollback() - handleHTMLError(w, r, err, "updating email_verified", u.EmailVerificationView, vd) - return - } - if err := tx.Model(&token).Update("used_at", time.Now()).Error; err != nil { - tx.Rollback() - handleHTMLError(w, r, err, "updating reset token", u.EmailVerificationView, vd) - return - } - tx.Commit() - - var user database.User - if err := u.app.DB.Where("id = ?", token.UserID).First(&user).Error; err != nil { - handleHTMLError(w, r, err, "finding user", u.EmailVerificationView, vd) - return - } - - session, err := u.app.SignIn(&user) - if err != nil { - handleHTMLError(w, r, err, "Creating session", u.EmailVerificationView, vd) - } - - setSessionCookie(w, session.Key, session.ExpiresAt) - http.Redirect(w, r, "/", http.StatusFound) -} - -func (u *Users) CreateEmailVerificationToken(w http.ResponseWriter, r *http.Request) { - vd := views.Data{} - - user := context.User(r.Context()) - if user == nil { - handleHTMLError(w, r, app.ErrLoginRequired, "No authenticated user found", u.SettingView, vd) - return - } - - var account database.Account - err := u.app.DB.Where("user_id = ?", user.ID).First(&account).Error - if err != nil { - handleHTMLError(w, r, err, "finding account", u.SettingView, vd) - return - } - - if account.EmailVerified { - handleHTMLError(w, r, app.ErrEmailAlreadyVerified, "email is already verified.", u.SettingView, vd) - return - } - if account.Email.String == "" { - handleHTMLError(w, r, app.ErrEmailRequired, "email is empty.", u.SettingView, vd) - return - } - - tok, err := token.Create(u.app.DB, account.UserID, database.TokenTypeEmailVerification) - if err != nil { - handleHTMLError(w, r, err, "saving token", u.SettingView, vd) - return - } - - if err := u.app.SendVerificationEmail(account.Email.String, tok.Value); err != nil { - if pkgErrors.Cause(err) == mailer.ErrSMTPNotConfigured { - handleHTMLError(w, r, app.ErrInvalidSMTPConfig, "SMTP config is not configured correctly.", u.SettingView, vd) - } else { - handleHTMLError(w, r, err, "sending verification email", u.SettingView, vd) - } - - return - } - - alert := views.Alert{ - Level: views.AlertLvlSuccess, - Message: "Please check your email for the verification", - } - views.RedirectAlert(w, r, "/", http.StatusFound, alert) -} diff --git a/pkg/server/controllers/users_test.go b/pkg/server/controllers/users_test.go index e4c9ff2d..643cb016 100644 --- a/pkg/server/controllers/users_test.go +++ b/pkg/server/controllers/users_test.go @@ -578,12 +578,6 @@ func TestResetPassword(t *testing.T) { Type: database.TokenTypeResetPassword, } testutils.MustExec(t, db.Save(&tok), "preparing token") - otherTok := database.Token{ - UserID: u.ID, - Value: "somerandomvalue", - Type: database.TokenTypeEmailVerification, - } - testutils.MustExec(t, db.Save(&otherTok), "preparing another token") s1 := database.Session{ Key: "some-session-key-1", @@ -618,16 +612,14 @@ func TestResetPassword(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusFound, "Status code mismatch") - var resetToken, verificationToken database.Token + var resetToken database.Token var account database.Account testutils.MustExec(t, db.Where("value = ?", "MivFxYiSMMA4An9dP24DNQ==").First(&resetToken), "finding reset token") - testutils.MustExec(t, db.Where("value = ?", "somerandomvalue").First(&verificationToken), "finding reset token") testutils.MustExec(t, db.Where("id = ?", acc.ID).First(&account), "finding account") assert.NotEqual(t, resetToken.UsedAt, nil, "reset_token UsedAt mismatch") passwordErr := bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte("newpassword")) assert.Equal(t, passwordErr, nil, "Password mismatch") - assert.Equal(t, verificationToken.UsedAt, (*time.Time)(nil), "verificationToken UsedAt mismatch") var s1Count, s2Count int64 testutils.MustExec(t, db.Model(&database.Session{}).Where("id = ?", s1.ID).Count(&s1Count), "counting s1") @@ -777,46 +769,6 @@ func TestResetPassword(t *testing.T) { } }) - t.Run("using wrong type token: email_verification", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - // Setup - a := app.NewTest() - a.Clock = clock.NewMock() - a.DB = db - server := MustNewServer(t, &a) - defer server.Close() - - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "somepassword") - tok := database.Token{ - UserID: u.ID, - Value: "MivFxYiSMMA4An9dP24DNQ==", - Type: database.TokenTypeEmailVerification, - } - testutils.MustExec(t, db.Save(&tok), "Failed to prepare reset_token") - testutils.MustExec(t, db.Model(&tok).Update("created_at", time.Now().Add(time.Minute*-11)), "Failed to prepare reset_token created_at") - - dat := url.Values{} - dat.Set("token", "MivFxYiSMMA4An9dP24DNQ==") - dat.Set("password", "oldpassword") - dat.Set("password_confirmation", "oldpassword") - req := testutils.MakeFormReq(server.URL, "PATCH", "/password-reset", dat) - - // Execute - res := testutils.HTTPDo(t, req) - - // Test - assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status code mismatch") - - var resetToken database.Token - var account database.Account - testutils.MustExec(t, db.Where("value = ?", "MivFxYiSMMA4An9dP24DNQ==").First(&resetToken), "failed to find reset_token") - testutils.MustExec(t, db.Where("id = ?", acc.ID).First(&account), "failed to find account") - - assert.Equal(t, acc.Password, account.Password, "password should not have been updated") - assert.Equal(t, resetToken.UsedAt, (*time.Time)(nil), "used_at should be nil") - }) } func TestCreateResetToken(t *testing.T) { @@ -1018,9 +970,7 @@ func TestUpdateEmail(t *testing.T) { defer server.Close() u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") - acc.EmailVerified = true - testutils.MustExec(t, db.Save(&acc), "updating email_verified") + testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") // Execute dat := url.Values{} @@ -1039,7 +989,6 @@ func TestUpdateEmail(t *testing.T) { testutils.MustExec(t, db.Where("user_id = ?", u.ID).First(&account), "finding account") assert.Equal(t, account.Email.String, "alice-new@example.com", "email mismatch") - assert.Equal(t, account.EmailVerified, false, "EmailVerified mismatch") }) t.Run("password mismatch", func(t *testing.T) { @@ -1053,9 +1002,7 @@ func TestUpdateEmail(t *testing.T) { defer server.Close() u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") - acc.EmailVerified = true - testutils.MustExec(t, db.Save(&acc), "updating email_verified") + testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") // Execute dat := url.Values{} @@ -1074,238 +1021,6 @@ func TestUpdateEmail(t *testing.T) { testutils.MustExec(t, db.Where("user_id = ?", u.ID).First(&account), "finding account") assert.Equal(t, account.Email.String, "alice@example.com", "email mismatch") - assert.Equal(t, account.EmailVerified, true, "EmailVerified mismatch") }) } -func TestVerifyEmail(t *testing.T) { - t.Run("success", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - // Setup - a := app.NewTest() - a.Clock = clock.NewMock() - a.DB = db - server := MustNewServer(t, &a) - defer server.Close() - - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "pass1234") - tok := database.Token{ - UserID: user.ID, - Type: database.TokenTypeEmailVerification, - Value: "someTokenValue", - } - testutils.MustExec(t, db.Save(&tok), "preparing token") - - // Execute - req := testutils.MakeReq(server.URL, "GET", fmt.Sprintf("/verify-email/%s", "someTokenValue"), "") - res := testutils.HTTPAuthDo(t, db, req, user) - - // Test - assert.StatusCodeEquals(t, res, http.StatusFound, "Status code mismatch") - - var account database.Account - var token database.Token - var tokenCount int64 - testutils.MustExec(t, db.Where("user_id = ?", user.ID).First(&account), "finding account") - testutils.MustExec(t, db.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token") - testutils.MustExec(t, db.Model(&database.Token{}).Count(&tokenCount), "counting token") - - assert.Equal(t, account.EmailVerified, true, "email_verified mismatch") - assert.NotEqual(t, token.Value, "", "token value should not have been updated") - assert.Equal(t, tokenCount, int64(1), "token count mismatch") - assert.NotEqual(t, token.UsedAt, (*time.Time)(nil), "token should have been used") - }) - - t.Run("used token", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - // Setup - a := app.NewTest() - a.Clock = clock.NewMock() - a.DB = db - server := MustNewServer(t, &a) - defer server.Close() - - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "pass1234") - - usedAt := time.Now().Add(time.Hour * -11).UTC() - tok := database.Token{ - UserID: user.ID, - Type: database.TokenTypeEmailVerification, - Value: "someTokenValue", - UsedAt: &usedAt, - } - testutils.MustExec(t, db.Save(&tok), "preparing token") - - // Execute - req := testutils.MakeReq(server.URL, "GET", fmt.Sprintf("/verify-email/%s", "someTokenValue"), "") - res := testutils.HTTPAuthDo(t, db, req, user) - - // Test - assert.StatusCodeEquals(t, res, http.StatusBadRequest, "") - - var account database.Account - var token database.Token - var tokenCount int64 - testutils.MustExec(t, db.Where("user_id = ?", user.ID).First(&account), "finding account") - testutils.MustExec(t, db.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token") - testutils.MustExec(t, db.Model(&database.Token{}).Count(&tokenCount), "counting token") - - assert.Equal(t, account.EmailVerified, false, "email_verified mismatch") - assert.NotEqual(t, token.UsedAt, nil, "token used_at mismatch") - assert.Equal(t, tokenCount, int64(1), "token count mismatch") - assert.NotEqual(t, token.UsedAt, (*time.Time)(nil), "token should have been used") - }) - - t.Run("expired token", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - // Setup - a := app.NewTest() - a.Clock = clock.NewMock() - a.DB = db - server := MustNewServer(t, &a) - defer server.Close() - - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "pass1234") - - tok := database.Token{ - UserID: user.ID, - Type: database.TokenTypeEmailVerification, - Value: "someTokenValue", - } - testutils.MustExec(t, db.Save(&tok), "preparing token") - testutils.MustExec(t, db.Model(&tok).Update("created_at", time.Now().Add(time.Minute*-31)), "Failed to prepare token created_at") - - // Execute - req := testutils.MakeReq(server.URL, "GET", fmt.Sprintf("/verify-email/%s", "someTokenValue"), "") - res := testutils.HTTPAuthDo(t, db, req, user) - - // Test - assert.StatusCodeEquals(t, res, http.StatusGone, "") - - var account database.Account - var token database.Token - var tokenCount int64 - testutils.MustExec(t, db.Where("user_id = ?", user.ID).First(&account), "finding account") - testutils.MustExec(t, db.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token") - testutils.MustExec(t, db.Model(&database.Token{}).Count(&tokenCount), "counting token") - - assert.Equal(t, account.EmailVerified, false, "email_verified mismatch") - assert.Equal(t, tokenCount, int64(1), "token count mismatch") - assert.Equal(t, token.UsedAt, (*time.Time)(nil), "token should have not been used") - }) - - t.Run("already verified", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - // Setup - a := app.NewTest() - a.Clock = clock.NewMock() - a.DB = db - server := MustNewServer(t, &a) - defer server.Close() - - user := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, user, "alice@example.com", "oldpass1234") - acc.EmailVerified = true - testutils.MustExec(t, db.Save(&acc), "preparing account") - - tok := database.Token{ - UserID: user.ID, - Type: database.TokenTypeEmailVerification, - Value: "someTokenValue", - } - testutils.MustExec(t, db.Save(&tok), "preparing token") - - // Execute - req := testutils.MakeReq(server.URL, "GET", fmt.Sprintf("/verify-email/%s", "someTokenValue"), "") - res := testutils.HTTPAuthDo(t, db, req, user) - - // Test - assert.StatusCodeEquals(t, res, http.StatusConflict, "") - - var account database.Account - var token database.Token - var tokenCount int64 - testutils.MustExec(t, db.Where("user_id = ?", user.ID).First(&account), "finding account") - testutils.MustExec(t, db.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token") - testutils.MustExec(t, db.Model(&database.Token{}).Count(&tokenCount), "counting token") - - assert.Equal(t, account.EmailVerified, true, "email_verified mismatch") - assert.Equal(t, tokenCount, int64(1), "token count mismatch") - assert.Equal(t, token.UsedAt, (*time.Time)(nil), "token should have not been used") - }) -} - -func TestCreateVerificationToken(t *testing.T) { - t.Run("success", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - // Setup - emailBackend := testutils.MockEmailbackendImplementation{} - a := app.NewTest() - a.Clock = clock.NewMock() - a.DB = db - a.EmailBackend = &emailBackend - server := MustNewServer(t, &a) - defer server.Close() - - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "pass1234") - - // Execute - req := testutils.MakeReq(server.URL, "POST", "/verification-token", "") - res := testutils.HTTPAuthDo(t, db, req, user) - - // Test - assert.StatusCodeEquals(t, res, http.StatusFound, "status code mismatch") - - var account database.Account - var token database.Token - var tokenCount int64 - testutils.MustExec(t, db.Where("user_id = ?", user.ID).First(&account), "finding account") - testutils.MustExec(t, db.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token") - testutils.MustExec(t, db.Model(&database.Token{}).Count(&tokenCount), "counting token") - - assert.Equal(t, account.EmailVerified, false, "email_verified should not have been updated") - assert.NotEqual(t, token.Value, "", "token Value mismatch") - assert.Equal(t, tokenCount, int64(1), "token count mismatch") - assert.Equal(t, token.UsedAt, (*time.Time)(nil), "token UsedAt mismatch") - assert.Equal(t, len(emailBackend.Emails), 1, "email queue count mismatch") - }) - - t.Run("already verified", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - // Setup - a := app.NewTest() - a.Clock = clock.NewMock() - a.DB = db - server := MustNewServer(t, &a) - defer server.Close() - - user := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, user, "alice@example.com", "pass1234") - acc.EmailVerified = true - testutils.MustExec(t, db.Save(&acc), "preparing account") - - // Execute - req := testutils.MakeReq(server.URL, "POST", "/verification-token", "") - res := testutils.HTTPAuthDo(t, db, req, user) - - // Test - assert.StatusCodeEquals(t, res, http.StatusConflict, "Status code mismatch") - - var account database.Account - var tokenCount int64 - testutils.MustExec(t, db.Where("user_id = ?", user.ID).First(&account), "finding account") - testutils.MustExec(t, db.Model(&database.Token{}).Count(&tokenCount), "counting token") - - assert.Equal(t, account.EmailVerified, true, "email_verified should not have been updated") - assert.Equal(t, tokenCount, int64(0), "token count mismatch") - }) -} diff --git a/pkg/server/database/consts.go b/pkg/server/database/consts.go index b4a1db03..6a9abc0c 100644 --- a/pkg/server/database/consts.go +++ b/pkg/server/database/consts.go @@ -21,8 +21,6 @@ package database const ( // TokenTypeResetPassword is a type of a token for reseting password TokenTypeResetPassword = "reset_password" - // TokenTypeEmailVerification is a type of a token for verifying email - TokenTypeEmailVerification = "email_verification" ) const ( diff --git a/pkg/server/database/models.go b/pkg/server/database/models.go index ac3e4e56..98571e10 100644 --- a/pkg/server/database/models.go +++ b/pkg/server/database/models.go @@ -73,10 +73,9 @@ type User struct { // Account is a model for an account type Account struct { Model - UserID int `gorm:"index"` - Email NullString - EmailVerified bool `gorm:"default:false"` - Password NullString + UserID int `gorm:"index"` + Email NullString + Password NullString } // Token is a model for a token diff --git a/pkg/server/mailer/mailer.go b/pkg/server/mailer/mailer.go index d02d8911..1cf786a7 100644 --- a/pkg/server/mailer/mailer.go +++ b/pkg/server/mailer/mailer.go @@ -34,8 +34,6 @@ var ( EmailTypeResetPassword = "reset_password" // EmailTypeResetPasswordAlert represents a password change notification email EmailTypeResetPasswordAlert = "reset_password_alert" - // EmailTypeEmailVerification represents an email verification email - EmailTypeEmailVerification = "verify_email" // EmailTypeWelcome represents an welcome email EmailTypeWelcome = "welcome" ) @@ -79,10 +77,6 @@ func NewTemplates() Templates { if err != nil { panic(errors.Wrap(err, "initializing welcome template")) } - verifyEmailText, err := initTextTmpl(EmailTypeEmailVerification) - if err != nil { - panic(errors.Wrap(err, "initializing email verification template")) - } passwordResetText, err := initTextTmpl(EmailTypeResetPassword) if err != nil { panic(errors.Wrap(err, "initializing password reset template")) @@ -95,7 +89,6 @@ func NewTemplates() Templates { T := Templates{} T.set(EmailTypeResetPassword, EmailKindText, passwordResetText) T.set(EmailTypeResetPasswordAlert, EmailKindText, passwordResetAlertText) - T.set(EmailTypeEmailVerification, EmailKindText, verifyEmailText) T.set(EmailTypeWelcome, EmailKindText, welcomeText) return T diff --git a/pkg/server/mailer/mailer_test.go b/pkg/server/mailer/mailer_test.go index df95b1f9..5837192a 100644 --- a/pkg/server/mailer/mailer_test.go +++ b/pkg/server/mailer/mailer_test.go @@ -32,7 +32,6 @@ func TestAllTemplatesInitialized(t *testing.T) { emailTypes := []string{ EmailTypeResetPassword, EmailTypeResetPasswordAlert, - EmailTypeEmailVerification, EmailTypeWelcome, } @@ -46,44 +45,6 @@ func TestAllTemplatesInitialized(t *testing.T) { } } -func TestEmailVerificationEmail(t *testing.T) { - testCases := []struct { - token string - webURL string - }{ - { - token: "someRandomToken1", - webURL: "http://localhost:3000", - }, - { - token: "someRandomToken2", - webURL: "http://localhost:3001", - }, - } - - tmpl := NewTemplates() - - for _, tc := range testCases { - t.Run(fmt.Sprintf("with WebURL %s", tc.webURL), func(t *testing.T) { - dat := EmailVerificationTmplData{ - Token: tc.token, - WebURL: tc.webURL, - } - body, err := tmpl.Execute(EmailTypeEmailVerification, EmailKindText, dat) - if err != nil { - t.Fatal(errors.Wrap(err, "executing")) - } - - if ok := strings.Contains(body, tc.webURL); !ok { - t.Errorf("email body did not contain %s", tc.webURL) - } - if ok := strings.Contains(body, tc.token); !ok { - t.Errorf("email body did not contain %s", tc.token) - } - }) - } -} - func TestResetPasswordEmail(t *testing.T) { testCases := []struct { token string diff --git a/pkg/server/mailer/templates/verify_email.txt b/pkg/server/mailer/templates/verify_email.txt deleted file mode 100644 index c21af88d..00000000 --- a/pkg/server/mailer/templates/verify_email.txt +++ /dev/null @@ -1,5 +0,0 @@ -Hi, - -Welcome to Dnote! To verify your email, visit the following link: - - {{ .WebURL }}/verify-email/{{ .Token }} diff --git a/pkg/server/mailer/types.go b/pkg/server/mailer/types.go index 3a371911..6ad862de 100644 --- a/pkg/server/mailer/types.go +++ b/pkg/server/mailer/types.go @@ -18,12 +18,6 @@ package mailer -// EmailVerificationTmplData is a template data for email verification emails -type EmailVerificationTmplData struct { - Token string - WebURL string -} - // EmailResetPasswordTmplData is a template data for reset password emails type EmailResetPasswordTmplData struct { AccountEmail string diff --git a/pkg/server/middleware/auth_test.go b/pkg/server/middleware/auth_test.go index 8451ae5d..1485befa 100644 --- a/pkg/server/middleware/auth_test.go +++ b/pkg/server/middleware/auth_test.go @@ -178,7 +178,7 @@ func TestTokenAuth(t *testing.T) { user := testutils.SetupUserData(db) tok := database.Token{ UserID: user.ID, - Type: database.TokenTypeEmailVerification, + Type: database.TokenTypeResetPassword, Value: "xpwFnc0MdllFUePDq9DLeQ==", } testutils.MustExec(t, db.Save(&tok), "preparing token") @@ -193,7 +193,7 @@ func TestTokenAuth(t *testing.T) { w.WriteHeader(http.StatusOK) } - server := httptest.NewServer(TokenAuth(db, handler, database.TokenTypeEmailVerification, nil)) + server := httptest.NewServer(TokenAuth(db, handler, database.TokenTypeResetPassword, nil)) defer server.Close() t.Run("with token", func(t *testing.T) { diff --git a/pkg/server/session/session.go b/pkg/server/session/session.go index 8c55549c..a9494c58 100644 --- a/pkg/server/session/session.go +++ b/pkg/server/session/session.go @@ -24,16 +24,14 @@ import ( // Session represents user session type Session struct { - UUID string `json:"uuid"` - Email string `json:"email"` - EmailVerified bool `json:"email_verified"` + UUID string `json:"uuid"` + Email string `json:"email"` } // New returns a new session for the given user func New(user database.User, account database.Account) Session { return Session{ - UUID: user.UUID, - Email: account.Email.String, - EmailVerified: account.EmailVerified, + UUID: user.UUID, + Email: account.Email.String, } } diff --git a/pkg/server/session/session_test.go b/pkg/server/session/session_test.go index 107dacfe..dec674b7 100644 --- a/pkg/server/session/session_test.go +++ b/pkg/server/session/session_test.go @@ -28,10 +28,10 @@ import ( func TestNew(t *testing.T) { u1 := database.User{UUID: "0f5f0054-d23f-4be1-b5fb-57673109e9cb"} - a1 := database.Account{Email: database.ToNullString("alice@example.com"), EmailVerified: false} + a1 := database.Account{Email: database.ToNullString("alice@example.com")} u2 := database.User{UUID: "718a1041-bbe6-496e-bbe4-ea7e572c295e"} - a2 := database.Account{Email: database.ToNullString("bob@example.com"), EmailVerified: false} + a2 := database.Account{Email: database.ToNullString("bob@example.com")} testCases := []struct { user database.User @@ -52,9 +52,8 @@ func TestNew(t *testing.T) { // Execute got := New(tc.user, tc.account) expected := Session{ - UUID: tc.user.UUID, - Email: tc.account.Email.String, - EmailVerified: tc.account.EmailVerified, + UUID: tc.user.UUID, + Email: tc.account.Email.String, } assert.DeepEqual(t, got, expected, "result mismatch") diff --git a/pkg/server/token/token_test.go b/pkg/server/token/token_test.go index 922cc93d..426ff3d1 100644 --- a/pkg/server/token/token_test.go +++ b/pkg/server/token/token_test.go @@ -33,7 +33,7 @@ func TestCreate(t *testing.T) { kind string }{ { - kind: database.TokenTypeEmailVerification, + kind: database.TokenTypeResetPassword, }, } diff --git a/pkg/server/views/templates/users/email_verification.gohtml b/pkg/server/views/templates/users/email_verification.gohtml deleted file mode 100644 index 969688a4..00000000 --- a/pkg/server/views/templates/users/email_verification.gohtml +++ /dev/null @@ -1,2 +0,0 @@ -{{define "yield"}} -{{end}} diff --git a/pkg/server/views/templates/users/settings.gohtml b/pkg/server/views/templates/users/settings.gohtml index a9639468..9f747b3e 100644 --- a/pkg/server/views/templates/users/settings.gohtml +++ b/pkg/server/views/templates/users/settings.gohtml @@ -144,34 +144,6 @@ -

-
-
-

Email Verified

-
- -
- {{ if eq true false }} b{{end}} - - {{if .EmailVerified}} - Yes - {{else}} - No - - - {{end}} -
-
-
-
diff --git a/pkg/server/views/view.go b/pkg/server/views/view.go index 2b0e57a9..3484dca8 100644 --- a/pkg/server/views/view.go +++ b/pkg/server/views/view.go @@ -116,8 +116,6 @@ func (v *View) Render(w http.ResponseWriter, r *http.Request, data *Data, status } if vd.Account != nil { vd.Yield["Email"] = vd.Account.Email.String - vd.Yield["EmailVerified"] = vd.Account.EmailVerified - vd.Yield["EmailVerified"] = vd.Account.EmailVerified } vd.Yield["CurrentPath"] = r.URL.Path vd.Yield["Standalone"] = buildinfo.Standalone From e0f68fc8d87fcb467387494c5f4e0f1fe05020e3 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:14:20 -0700 Subject: [PATCH 07/33] Rate limit client (#689) --- pkg/cli/client/client.go | 100 ++++++++++++++++++++-------- pkg/cli/client/client_test.go | 64 +++++++++++++++--- pkg/cli/context/ctx.go | 3 + pkg/cli/infra/init.go | 2 + pkg/e2e/sync_test.go | 1 - pkg/server/.env.dev | 9 +-- pkg/server/.env.test | 8 --- pkg/server/middleware/limit.go | 72 ++++++++++++-------- pkg/server/middleware/limit_test.go | 82 +++++++++++++++++++++++ 9 files changed, 263 insertions(+), 78 deletions(-) create mode 100644 pkg/server/middleware/limit_test.go diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index b90ddaca..b24c432e 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -33,6 +33,7 @@ import ( "github.com/dnote/dnote/pkg/cli/context" "github.com/dnote/dnote/pkg/cli/log" "github.com/pkg/errors" + "golang.org/x/time/rate" ) // ErrInvalidLogin is an error for invalid credentials for login @@ -44,15 +45,66 @@ var ErrContentTypeMismatch = errors.New("content type mismatch") var contentTypeApplicationJSON = "application/json" var contentTypeNone = "" -// requestOptions contians options for requests +// requestOptions contains options for requests type requestOptions struct { HTTPClient *http.Client // ExpectedContentType is the Content-Type that the client is expecting from the server ExpectedContentType *string } -var defaultRequestOptions = requestOptions{ - ExpectedContentType: &contentTypeApplicationJSON, +const ( + // clientRateLimitPerSecond is the max requests per second the client will make + clientRateLimitPerSecond = 50 + // clientRateLimitBurst is the burst capacity for rate limiting + clientRateLimitBurst = 100 +) + +// rateLimitedTransport wraps an http.RoundTripper with rate limiting +type rateLimitedTransport struct { + transport http.RoundTripper + limiter *rate.Limiter +} + +func (t *rateLimitedTransport) RoundTrip(req *http.Request) (*http.Response, error) { + // Wait for rate limiter to allow the request + if err := t.limiter.Wait(req.Context()); err != nil { + return nil, err + } + return t.transport.RoundTrip(req) +} + +// NewRateLimitedHTTPClient creates an HTTP client with rate limiting +func NewRateLimitedHTTPClient() *http.Client { + // Calculate interval from rate: 1 second / requests per second + interval := time.Second / time.Duration(clientRateLimitPerSecond) + + transport := &rateLimitedTransport{ + transport: http.DefaultTransport, + limiter: rate.NewLimiter(rate.Every(interval), clientRateLimitBurst), + } + return &http.Client{ + Transport: transport, + } +} + +func getHTTPClient(ctx context.DnoteCtx, options *requestOptions) *http.Client { + if options != nil && options.HTTPClient != nil { + return options.HTTPClient + } + + if ctx.HTTPClient != nil { + return ctx.HTTPClient + } + + return &http.Client{} +} + +func getExpectedContentType(options *requestOptions) string { + if options != nil && options.ExpectedContentType != nil { + return *options.ExpectedContentType + } + + return contentTypeApplicationJSON } func getReq(ctx context.DnoteCtx, path, method, body string) (*http.Request, error) { @@ -72,22 +124,6 @@ func getReq(ctx context.DnoteCtx, path, method, body string) (*http.Request, err return req, nil } -func getHTTPClient(options *requestOptions) http.Client { - if options != nil && options.HTTPClient != nil { - return *options.HTTPClient - } - - return http.Client{} -} - -func getExpectedContentType(options *requestOptions) string { - if options != nil && options.ExpectedContentType != nil { - return *options.ExpectedContentType - } - - return contentTypeApplicationJSON -} - // checkRespErr checks if the given http response indicates an error. It returns a boolean indicating // if the response is an error, and a decoded error message. func checkRespErr(res *http.Response) error { @@ -124,7 +160,7 @@ func doReq(ctx context.DnoteCtx, method, path, body string, options *requestOpti log.Debug("HTTP request: %+v\n", req) - hc := getHTTPClient(options) + hc := getHTTPClient(ctx, options) res, err := hc.Do(req) if err != nil { return res, errors.Wrap(err, "making http request") @@ -542,15 +578,27 @@ func Signin(ctx context.DnoteCtx, email, password string) (SigninResponse, error // Signout deletes a user session on the server side func Signout(ctx context.DnoteCtx, sessionKey string) error { - hc := http.Client{ - // No need to follow redirect - CheckRedirect: func(req *http.Request, via []*http.Request) error { - return http.ErrUseLastResponse - }, + // Create a client that shares the transport (and thus rate limiter) from ctx.HTTPClient + // but doesn't follow redirects + var hc *http.Client + if ctx.HTTPClient != nil { + hc = &http.Client{ + Transport: ctx.HTTPClient.Transport, + CheckRedirect: func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + }, + } + } else { + log.Warnf("No HTTP client configured for signout - falling back\n") + hc = &http.Client{ + CheckRedirect: func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + }, + } } opts := requestOptions{ - HTTPClient: &hc, + HTTPClient: hc, ExpectedContentType: &contentTypeNone, } _, err := doAuthorizedReq(ctx, "POST", "/v3/signout", "", &opts) diff --git a/pkg/cli/client/client_test.go b/pkg/cli/client/client_test.go index 59bdf4b0..c5467ad6 100644 --- a/pkg/cli/client/client_test.go +++ b/pkg/cli/client/client_test.go @@ -23,12 +23,15 @@ import ( "fmt" "net/http" "net/http/httptest" + "sync/atomic" "testing" + "time" "github.com/dnote/dnote/pkg/assert" "github.com/dnote/dnote/pkg/cli/context" "github.com/dnote/dnote/pkg/cli/testutils" "github.com/pkg/errors" + "golang.org/x/time/rate" ) // startCommonTestServer starts a test HTTP server that simulates a common set of senarios @@ -82,9 +85,10 @@ func TestSignIn(t *testing.T) { defer commonTs.Close() correctEndpoint := fmt.Sprintf("%s/api", ts.URL) + testClient := NewRateLimitedHTTPClient() t.Run("success", func(t *testing.T) { - result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint}, "alice@example.com", "pass1234") + result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint, HTTPClient: testClient}, "alice@example.com", "pass1234") if err != nil { t.Errorf("got signin request error: %+v", err.Error()) } @@ -94,7 +98,7 @@ func TestSignIn(t *testing.T) { }) t.Run("failure", func(t *testing.T) { - result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint}, "alice@example.com", "incorrectpassword") + result, err := Signin(context.DnoteCtx{APIEndpoint: correctEndpoint, HTTPClient: testClient}, "alice@example.com", "incorrectpassword") assert.Equal(t, err, ErrInvalidLogin, "err mismatch") assert.Equal(t, result.Key, "", "Key mismatch") @@ -103,7 +107,7 @@ func TestSignIn(t *testing.T) { t.Run("server error", func(t *testing.T) { endpoint := fmt.Sprintf("%s/bad-api", ts.URL) - result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint}, "alice@example.com", "pass1234") + result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com", "pass1234") if err == nil { t.Error("error should have been returned") } @@ -114,7 +118,7 @@ func TestSignIn(t *testing.T) { t.Run("accidentally pointing to a catch-all handler", func(t *testing.T) { endpoint := fmt.Sprintf("%s", ts.URL) - result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint}, "alice@example.com", "pass1234") + result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com", "pass1234") assert.Equal(t, errors.Cause(err), ErrContentTypeMismatch, "error cause mismatch") assert.Equal(t, result.Key, "", "Key mismatch") @@ -134,17 +138,18 @@ func TestSignOut(t *testing.T) { defer commonTs.Close() correctEndpoint := fmt.Sprintf("%s/api", ts.URL) + testClient := NewRateLimitedHTTPClient() t.Run("success", func(t *testing.T) { - err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: correctEndpoint}, "alice@example.com") + err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: correctEndpoint, HTTPClient: testClient}, "alice@example.com") if err != nil { - t.Errorf("got signin request error: %+v", err.Error()) + t.Errorf("got signout request error: %+v", err.Error()) } }) t.Run("server error", func(t *testing.T) { endpoint := fmt.Sprintf("%s/bad-api", commonTs.URL) - err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint}, "alice@example.com") + err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com") if err == nil { t.Error("error should have been returned") } @@ -152,8 +157,51 @@ func TestSignOut(t *testing.T) { t.Run("accidentally pointing to a catch-all handler", func(t *testing.T) { endpoint := fmt.Sprintf("%s", commonTs.URL) - err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint}, "alice@example.com") + err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com") assert.Equal(t, errors.Cause(err), ErrContentTypeMismatch, "error cause mismatch") }) + + // Gracefully handle a case where http client was not initialized in the context. + t.Run("nil HTTPClient", func(t *testing.T) { + err := Signout(context.DnoteCtx{SessionKey: "somekey", APIEndpoint: correctEndpoint}, "alice@example.com") + if err != nil { + t.Errorf("got signout request error: %+v", err.Error()) + } + }) +} + +func TestRateLimitedTransport(t *testing.T) { + var requestCount atomic.Int32 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + requestCount.Add(1) + w.WriteHeader(http.StatusOK) + })) + defer ts.Close() + + transport := &rateLimitedTransport{ + transport: http.DefaultTransport, + limiter: rate.NewLimiter(10, 5), + } + client := &http.Client{Transport: transport} + + // Make 10 requests + start := time.Now() + numRequests := 10 + for i := range numRequests { + req, _ := http.NewRequest("GET", ts.URL, nil) + resp, err := client.Do(req) + if err != nil { + t.Fatalf("Request %d failed: %v", i, err) + } + resp.Body.Close() + } + elapsed := time.Since(start) + + // Burst of 5, then 5 more at 10 req/s = 500ms minimum + if elapsed < 500*time.Millisecond { + t.Errorf("Rate limit not enforced: 10 requests took %v, expected >= 500ms", elapsed) + } + + assert.Equal(t, int(requestCount.Load()), 10, "request count mismatch") } diff --git a/pkg/cli/context/ctx.go b/pkg/cli/context/ctx.go index a5f62340..61cd5be8 100644 --- a/pkg/cli/context/ctx.go +++ b/pkg/cli/context/ctx.go @@ -20,6 +20,8 @@ package context import ( + "net/http" + "github.com/dnote/dnote/pkg/cli/database" "github.com/dnote/dnote/pkg/clock" ) @@ -44,6 +46,7 @@ type DnoteCtx struct { Editor string Clock clock.Clock EnableUpgradeCheck bool + HTTPClient *http.Client } // Redact replaces private information from the context with a set of diff --git a/pkg/cli/infra/init.go b/pkg/cli/infra/init.go index 72286cad..2b6c9618 100644 --- a/pkg/cli/infra/init.go +++ b/pkg/cli/infra/init.go @@ -28,6 +28,7 @@ import ( "strconv" "time" + "github.com/dnote/dnote/pkg/cli/client" "github.com/dnote/dnote/pkg/cli/config" "github.com/dnote/dnote/pkg/cli/consts" "github.com/dnote/dnote/pkg/cli/context" @@ -159,6 +160,7 @@ func SetupCtx(ctx context.DnoteCtx) (context.DnoteCtx, error) { Editor: cf.Editor, Clock: clock.New(), EnableUpgradeCheck: cf.EnableUpgradeCheck, + HTTPClient: client.NewRateLimitedHTTPClient(), } return ret, nil diff --git a/pkg/e2e/sync_test.go b/pkg/e2e/sync_test.go index 2f3234f2..2ddf373e 100644 --- a/pkg/e2e/sync_test.go +++ b/pkg/e2e/sync_test.go @@ -95,7 +95,6 @@ func TestMain(m *testing.M) { a.EmailTemplates = mailer.Templates{} a.EmailBackend = &apitest.MockEmailbackendImplementation{} a.DB = serverDb - a.WebURL = os.Getenv("WebURL") var err error server, err = controllers.NewServer(&a) diff --git a/pkg/server/.env.dev b/pkg/server/.env.dev index fe5dca07..c78a6704 100644 --- a/pkg/server/.env.dev +++ b/pkg/server/.env.dev @@ -1,9 +1,2 @@ APP_ENV=DEVELOPMENT - -SmtpUsername=mock-SmtpUsername -SmtpPassword=mock-SmtpPassword -SmtpHost=mock-SmtpHost -SmtpPort=465 - -WebURL=http://localhost:3001 -DisableRegistration=false +DBPath=../../dev-server.db diff --git a/pkg/server/.env.test b/pkg/server/.env.test index 8c0befed..b9cf3101 100644 --- a/pkg/server/.env.test +++ b/pkg/server/.env.test @@ -1,9 +1 @@ APP_ENV=TEST - -SmtpUsername=mock-SmtpUsername -SmtpPassword=mock-SmtpPassword -SmtpHost=mock-SmtpHost -SmtpPort=465 - -WebURL=http://localhost:3001 -DisableRegistration=false diff --git a/pkg/server/middleware/limit.go b/pkg/server/middleware/limit.go index 3b3c3987..2f737613 100644 --- a/pkg/server/middleware/limit.go +++ b/pkg/server/middleware/limit.go @@ -29,63 +29,81 @@ import ( "golang.org/x/time/rate" ) +const ( + // serverRateLimitPerSecond is the max requests per second the server will accept per IP + serverRateLimitPerSecond = 50 + // serverRateLimitBurst is the burst capacity for rate limiting + serverRateLimitBurst = 100 +) + type visitor struct { limiter *rate.Limiter lastSeen time.Time } -var visitors = make(map[string]*visitor) -var mtx sync.RWMutex - -func init() { - go cleanupVisitors() +// RateLimiter holds the rate limiting state for visitors +type RateLimiter struct { + visitors map[string]*visitor + mtx sync.RWMutex } -// addVisitor adds a new visitor to the map and returns a limiter for the visitor -func addVisitor(identifier string) *rate.Limiter { - // initialize a token bucket - limiter := rate.NewLimiter(rate.Every(1*time.Second), 60) +// NewRateLimiter creates a new rate limiter instance +func NewRateLimiter() *RateLimiter { + rl := &RateLimiter{ + visitors: make(map[string]*visitor), + } + go rl.cleanupVisitors() + return rl +} - mtx.Lock() - visitors[identifier] = &visitor{ +var defaultLimiter = NewRateLimiter() + +// addVisitor adds a new visitor to the map and returns a limiter for the visitor +func (rl *RateLimiter) addVisitor(identifier string) *rate.Limiter { + // Calculate interval from rate: 1 second / requests per second + interval := time.Second / time.Duration(serverRateLimitPerSecond) + limiter := rate.NewLimiter(rate.Every(interval), serverRateLimitBurst) + + rl.mtx.Lock() + rl.visitors[identifier] = &visitor{ limiter: limiter, lastSeen: time.Now()} - mtx.Unlock() + rl.mtx.Unlock() return limiter } // getVisitor returns a limiter for a visitor with the given identifier. It // adds the visitor to the map if not seen before. -func getVisitor(identifier string) *rate.Limiter { - mtx.RLock() - v, exists := visitors[identifier] +func (rl *RateLimiter) getVisitor(identifier string) *rate.Limiter { + rl.mtx.RLock() + v, exists := rl.visitors[identifier] if !exists { - mtx.RUnlock() - return addVisitor(identifier) + rl.mtx.RUnlock() + return rl.addVisitor(identifier) } v.lastSeen = time.Now() - mtx.RUnlock() + rl.mtx.RUnlock() return v.limiter } // cleanupVisitors deletes visitors that has not been seen in a while from the // map of visitors -func cleanupVisitors() { +func (rl *RateLimiter) cleanupVisitors() { for { time.Sleep(time.Minute) - mtx.Lock() + rl.mtx.Lock() - for identifier, v := range visitors { + for identifier, v := range rl.visitors { if time.Since(v.lastSeen) > 3*time.Minute { - delete(visitors, identifier) + delete(rl.visitors, identifier) } } - mtx.Unlock() + rl.mtx.Unlock() } } @@ -107,10 +125,10 @@ func lookupIP(r *http.Request) string { } // Limit is a middleware to rate limit the handler -func Limit(next http.Handler) http.HandlerFunc { +func (rl *RateLimiter) Limit(next http.Handler) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { identifier := lookupIP(r) - limiter := getVisitor(identifier) + limiter := rl.getVisitor(identifier) if !limiter.Allow() { http.Error(w, "Too many requests", http.StatusTooManyRequests) @@ -124,12 +142,12 @@ func Limit(next http.Handler) http.HandlerFunc { }) } -// ApplyLimit applies rate limit conditionally +// ApplyLimit applies rate limit conditionally using the global limiter func ApplyLimit(h http.HandlerFunc, rateLimit bool) http.Handler { ret := h if rateLimit && os.Getenv("APP_ENV") != "TEST" { - ret = Limit(ret) + ret = defaultLimiter.Limit(ret) } return ret diff --git a/pkg/server/middleware/limit_test.go b/pkg/server/middleware/limit_test.go new file mode 100644 index 00000000..1d5743ee --- /dev/null +++ b/pkg/server/middleware/limit_test.go @@ -0,0 +1,82 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package middleware + +import ( + "net/http" + "net/http/httptest" + "testing" +) + +func TestLimit(t *testing.T) { + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + }) + + limiter := NewRateLimiter() + middleware := limiter.Limit(handler) + + // Make burst + 5 requests from same IP + numRequests := serverRateLimitBurst + 5 + blockedCount := 0 + + for range numRequests { + req := httptest.NewRequest("GET", "/test", nil) + req.RemoteAddr = "192.168.1.1:1234" + w := httptest.NewRecorder() + + middleware.ServeHTTP(w, req) + + if w.Code == http.StatusTooManyRequests { + blockedCount++ + } + } + + // At least some requests after burst should be blocked + if blockedCount == 0 { + t.Error("Expected some requests to be rate limited after burst") + } +} + +func TestLimit_DifferentIPs(t *testing.T) { + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + }) + + limiter := NewRateLimiter() + middleware := limiter.Limit(handler) + + // Exhaust rate limit for first IP + for range serverRateLimitBurst + 5 { + req := httptest.NewRequest("GET", "/test", nil) + req.RemoteAddr = "192.168.1.1:1234" + w := httptest.NewRecorder() + middleware.ServeHTTP(w, req) + } + + // Request from different IP should still succeed + req := httptest.NewRequest("GET", "/test", nil) + req.RemoteAddr = "192.168.1.2:5678" + w := httptest.NewRecorder() + middleware.ServeHTTP(w, req) + + if w.Code != http.StatusOK { + t.Errorf("Request from different IP should succeed, got status %d", w.Code) + } +} From 24491bc68a561a70b61d934958d627db32af711b Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 12 Oct 2025 12:03:20 -0700 Subject: [PATCH 08/33] Allow to upload all data to an empty server (#690) * Handle server switch * Avoid losing data in case of race * Simplify --- pkg/cli/client/client.go | 20 +- pkg/cli/client/client_test.go | 18 + pkg/cli/cmd/root/root.go | 16 + pkg/cli/cmd/sync/sync.go | 100 +++++- pkg/cli/cmd/sync/sync_test.go | 67 ++++ pkg/cli/infra/init.go | 25 +- pkg/cli/infra/init_test.go | 49 +++ pkg/cli/main.go | 11 +- pkg/cli/main_test.go | 6 +- pkg/cli/migrate/migrations.go | 5 +- pkg/cli/testutils/main.go | 176 ++++++++-- pkg/e2e/sync_test.go | 621 ++++++++++++++++++++++++++++++++-- 12 files changed, 1050 insertions(+), 64 deletions(-) diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index b24c432e..021afe7d 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -42,6 +42,21 @@ var ErrInvalidLogin = errors.New("wrong credentials") // ErrContentTypeMismatch is an error for invalid credentials for login var ErrContentTypeMismatch = errors.New("content type mismatch") +// HTTPError represents an HTTP error response from the server +type HTTPError struct { + StatusCode int + Message string +} + +func (e *HTTPError) Error() string { + return fmt.Sprintf(`response %d "%s"`, e.StatusCode, e.Message) +} + +// IsConflict returns true if the error is a 409 Conflict error +func (e *HTTPError) IsConflict() bool { + return e.StatusCode == 409 +} + var contentTypeApplicationJSON = "application/json" var contentTypeNone = "" @@ -137,7 +152,10 @@ func checkRespErr(res *http.Response) error { } bodyStr := string(body) - return errors.Errorf(`response %d "%s"`, res.StatusCode, strings.TrimRight(bodyStr, "\n")) + return &HTTPError{ + StatusCode: res.StatusCode, + Message: strings.TrimRight(bodyStr, "\n"), + } } func checkContentType(res *http.Response, options *requestOptions) error { diff --git a/pkg/cli/client/client_test.go b/pkg/cli/client/client_test.go index c5467ad6..31b6d6c8 100644 --- a/pkg/cli/client/client_test.go +++ b/pkg/cli/client/client_test.go @@ -205,3 +205,21 @@ func TestRateLimitedTransport(t *testing.T) { assert.Equal(t, int(requestCount.Load()), 10, "request count mismatch") } + +func TestHTTPError(t *testing.T) { + t.Run("IsConflict returns true for 409", func(t *testing.T) { + conflictErr := &HTTPError{ + StatusCode: 409, + Message: "Conflict", + } + + assert.Equal(t, conflictErr.IsConflict(), true, "IsConflict() should return true for 409") + + notFoundErr := &HTTPError{ + StatusCode: 404, + Message: "Not Found", + } + + assert.Equal(t, notFoundErr.IsConflict(), false, "IsConflict() should return false for 404") + }) +} diff --git a/pkg/cli/cmd/root/root.go b/pkg/cli/cmd/root/root.go index 81e0c58a..750629e4 100644 --- a/pkg/cli/cmd/root/root.go +++ b/pkg/cli/cmd/root/root.go @@ -22,6 +22,8 @@ import ( "github.com/spf13/cobra" ) +var apiEndpointFlag string + var root = &cobra.Command{ Use: "dnote", Short: "Dnote - a simple command line notebook", @@ -32,6 +34,20 @@ var root = &cobra.Command{ }, } +func init() { + root.PersistentFlags().StringVar(&apiEndpointFlag, "api-endpoint", "", "the API endpoint to connect to (defaults to value in config)") +} + +// GetRoot returns the root command +func GetRoot() *cobra.Command { + return root +} + +// GetAPIEndpointFlag returns the value of the --api-endpoint flag +func GetAPIEndpointFlag() string { + return apiEndpointFlag +} + // Register adds a new command func Register(cmd *cobra.Command) { root.AddCommand(cmd) diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index 1d511d98..ff8e8a5f 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -29,6 +29,7 @@ import ( "github.com/dnote/dnote/pkg/cli/infra" "github.com/dnote/dnote/pkg/cli/log" "github.com/dnote/dnote/pkg/cli/migrate" + "github.com/dnote/dnote/pkg/cli/ui" "github.com/dnote/dnote/pkg/cli/upgrade" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -629,6 +630,20 @@ func stepSync(ctx context.DnoteCtx, tx *database.DB, afterUSN int) error { return nil } +// isConflictError checks if an error is a 409 Conflict error from the server +func isConflictError(err error) bool { + if err == nil { + return false + } + + var httpErr *client.HTTPError + if errors.As(err, &httpErr) { + return httpErr.IsConflict() + } + + return false +} + func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) { isBehind := false @@ -661,6 +676,12 @@ func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) { } else { resp, err := client.CreateBook(ctx, book.Label) if err != nil { + // If we get a 409 conflict, it means another client uploaded data. + if isConflictError(err) { + log.Debug("409 conflict creating book %s, will retry after sync\n", book.Label) + isBehind = true + continue + } return isBehind, errors.Wrap(err, "creating a book") } @@ -766,7 +787,10 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) { } else { resp, err := client.CreateNote(ctx, note.BookUUID, note.Body) if err != nil { - return isBehind, errors.Wrap(err, "creating a note") + // If we get a 409 conflict, it means another client uploaded data. + log.Debug("error creating note (will retry after sync): %v\n", err) + isBehind = true + continue } note.Dirty = false @@ -885,6 +909,26 @@ func saveSyncState(tx *database.DB, serverTime int64, serverMaxUSN int) error { return nil } +// prepareEmptyServerSync marks all local books and notes as dirty when syncing to an empty server. +// This is typically used when switching to a new empty server but wanting to upload existing local data. +// Returns true if preparation was done, false otherwise. +func prepareEmptyServerSync(tx *database.DB) error { + // Mark all books and notes as dirty and reset USN to 0 + if _, err := tx.Exec("UPDATE books SET usn = 0, dirty = 1 WHERE deleted = 0"); err != nil { + return errors.Wrap(err, "marking books as dirty") + } + if _, err := tx.Exec("UPDATE notes SET usn = 0, dirty = 1 WHERE deleted = 0"); err != nil { + return errors.Wrap(err, "marking notes as dirty") + } + + // Reset lastMaxUSN to 0 to match the server + if err := updateLastMaxUSN(tx, 0); err != nil { + return errors.Wrap(err, "resetting last max usn") + } + + return nil +} + func newRun(ctx context.DnoteCtx) infra.RunEFunc { return func(cmd *cobra.Command, args []string) error { if ctx.SessionKey == "" { @@ -915,6 +959,52 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc { log.Debug("lastSyncAt: %d, lastMaxUSN: %d, syncState: %+v\n", lastSyncAt, lastMaxUSN, syncState) + // Handle a case where server has MaxUSN=0 but local has data (server switch) + var bookCount, noteCount int + if err := tx.QueryRow("SELECT count(*) FROM books WHERE deleted = 0").Scan(&bookCount); err != nil { + return errors.Wrap(err, "counting local books") + } + if err := tx.QueryRow("SELECT count(*) FROM notes WHERE deleted = 0").Scan(¬eCount); err != nil { + return errors.Wrap(err, "counting local notes") + } + + // If a client has previously synced (lastMaxUSN > 0) but the server was never synced to (MaxUSN = 0), + // and the client has undeleted books or notes, allow to upload all data to the server. + // The client might have switched servers or the server might need to be restored for any reasons. + if syncState.MaxUSN == 0 && lastMaxUSN > 0 && (bookCount > 0 || noteCount > 0) { + log.Debug("empty server detected: server.MaxUSN=%d, local.MaxUSN=%d, books=%d, notes=%d\n", + syncState.MaxUSN, lastMaxUSN, bookCount, noteCount) + + log.Warnf("The server is empty but you have local data. Maybe you switched servers?\n") + log.Debug("server state: MaxUSN = 0 (empty)\n") + log.Debug("local state: %d books, %d notes (MaxUSN = %d)\n", bookCount, noteCount, lastMaxUSN) + + confirmed, err := ui.Confirm(fmt.Sprintf("Upload %d books and %d notes to the server?", bookCount, noteCount), false) + if err != nil { + tx.Rollback() + return errors.Wrap(err, "getting user confirmation") + } + + if !confirmed { + tx.Rollback() + return errors.New("sync cancelled by user") + } + + fmt.Println() // Add newline after confirmation. + + if err := prepareEmptyServerSync(tx); err != nil { + return errors.Wrap(err, "preparing for empty server sync") + } + + // Re-fetch lastMaxUSN after prepareEmptyServerSync + lastMaxUSN, err = getLastMaxUSN(tx) + if err != nil { + return errors.Wrap(err, "getting the last max_usn after prepare") + } + + log.Debug("prepared empty server sync: marked %d books and %d notes as dirty\n", bookCount, noteCount) + } + var syncErr error if isFullSync || lastSyncAt < syncState.FullSyncBefore { syncErr = fullSync(ctx, tx) @@ -953,6 +1043,14 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc { tx.Rollback() return errors.Wrap(err, "performing the follow-up step sync") } + + // After syncing server changes (which resolves conflicts), send local changes again + // This uploads books/notes that were skipped due to 409 conflicts + _, err = sendChanges(ctx, tx) + if err != nil { + tx.Rollback() + return errors.Wrap(err, "sending changes after conflict resolution") + } } tx.Commit() diff --git a/pkg/cli/cmd/sync/sync_test.go b/pkg/cli/cmd/sync/sync_test.go index 0cfb87e4..34f0c9df 100644 --- a/pkg/cli/cmd/sync/sync_test.go +++ b/pkg/cli/cmd/sync/sync_test.go @@ -3170,3 +3170,70 @@ func TestCleanLocalBooks(t *testing.T) { database.MustScan(t, "getting b3", db.QueryRow("SELECT label FROM books WHERE uuid = ?", "b3-uuid"), &b3.Label) database.MustScan(t, "getting b5", db.QueryRow("SELECT label FROM books WHERE uuid = ?", "b5-uuid"), &b5.Label) } + +func TestPrepareEmptyServerSync(t *testing.T) { + // set up + db := database.InitTestDB(t, "../../tmp/.dnote", nil) + defer database.TeardownTestDB(t, db) + + // Setup: local has synced data (usn > 0, dirty = false) and some deleted items + database.MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", "b1-uuid", "b1-label", 5, false, false) + database.MustExec(t, "inserting b2", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", "b2-uuid", "b2-label", 8, false, false) + database.MustExec(t, "inserting b3 deleted", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", "b3-uuid", "b3-label", 6, true, false) + database.MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, usn, deleted, dirty, added_on) VALUES (?, ?, ?, ?, ?, ?, ?)", "n1-uuid", "b1-uuid", "note 1", 6, false, false, 1541108743) + database.MustExec(t, "inserting n2", db, "INSERT INTO notes (uuid, book_uuid, body, usn, deleted, dirty, added_on) VALUES (?, ?, ?, ?, ?, ?, ?)", "n2-uuid", "b2-uuid", "note 2", 9, false, false, 1541108743) + database.MustExec(t, "inserting n3 deleted", db, "INSERT INTO notes (uuid, book_uuid, body, usn, deleted, dirty, added_on) VALUES (?, ?, ?, ?, ?, ?, ?)", "n3-uuid", "b1-uuid", "note 3", 7, true, false, 1541108743) + database.MustExec(t, "setting last_max_usn", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastMaxUSN, 9) + + // execute + tx, err := db.Begin() + if err != nil { + t.Fatal(errors.Wrap(err, "beginning transaction")) + } + + if err := prepareEmptyServerSync(tx); err != nil { + tx.Rollback() + t.Fatal(errors.Wrap(err, "executing prepareEmptyServerSync")) + } + + tx.Commit() + + // test - verify non-deleted items are marked dirty with usn=0, deleted items unchanged + var b1, b2, b3 database.Book + database.MustScan(t, "getting b1", db.QueryRow("SELECT usn, dirty, deleted FROM books WHERE uuid = ?", "b1-uuid"), &b1.USN, &b1.Dirty, &b1.Deleted) + database.MustScan(t, "getting b2", db.QueryRow("SELECT usn, dirty, deleted FROM books WHERE uuid = ?", "b2-uuid"), &b2.USN, &b2.Dirty, &b2.Deleted) + database.MustScan(t, "getting b3", db.QueryRow("SELECT usn, dirty, deleted FROM books WHERE uuid = ?", "b3-uuid"), &b3.USN, &b3.Dirty, &b3.Deleted) + + assert.Equal(t, b1.USN, 0, "b1 USN should be reset to 0") + assert.Equal(t, b1.Dirty, true, "b1 should be marked dirty") + assert.Equal(t, b1.Deleted, false, "b1 should not be deleted") + + assert.Equal(t, b2.USN, 0, "b2 USN should be reset to 0") + assert.Equal(t, b2.Dirty, true, "b2 should be marked dirty") + assert.Equal(t, b2.Deleted, false, "b2 should not be deleted") + + assert.Equal(t, b3.USN, 6, "b3 USN should remain unchanged (deleted item)") + assert.Equal(t, b3.Dirty, false, "b3 should not be marked dirty (deleted item)") + assert.Equal(t, b3.Deleted, true, "b3 should remain deleted") + + var n1, n2, n3 database.Note + database.MustScan(t, "getting n1", db.QueryRow("SELECT usn, dirty, deleted FROM notes WHERE uuid = ?", "n1-uuid"), &n1.USN, &n1.Dirty, &n1.Deleted) + database.MustScan(t, "getting n2", db.QueryRow("SELECT usn, dirty, deleted FROM notes WHERE uuid = ?", "n2-uuid"), &n2.USN, &n2.Dirty, &n2.Deleted) + database.MustScan(t, "getting n3", db.QueryRow("SELECT usn, dirty, deleted FROM notes WHERE uuid = ?", "n3-uuid"), &n3.USN, &n3.Dirty, &n3.Deleted) + + assert.Equal(t, n1.USN, 0, "n1 USN should be reset to 0") + assert.Equal(t, n1.Dirty, true, "n1 should be marked dirty") + assert.Equal(t, n1.Deleted, false, "n1 should not be deleted") + + assert.Equal(t, n2.USN, 0, "n2 USN should be reset to 0") + assert.Equal(t, n2.Dirty, true, "n2 should be marked dirty") + assert.Equal(t, n2.Deleted, false, "n2 should not be deleted") + + assert.Equal(t, n3.USN, 7, "n3 USN should remain unchanged (deleted item)") + assert.Equal(t, n3.Dirty, false, "n3 should not be marked dirty (deleted item)") + assert.Equal(t, n3.Deleted, true, "n3 should remain deleted") + + var lastMaxUSN int + database.MustScan(t, "getting last_max_usn", db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) + assert.Equal(t, lastMaxUSN, 0, "last_max_usn should be reset to 0") +} diff --git a/pkg/cli/infra/init.go b/pkg/cli/infra/init.go index 2b6c9618..532f1f1e 100644 --- a/pkg/cli/infra/init.go +++ b/pkg/cli/infra/init.go @@ -68,7 +68,10 @@ func getDBPath(paths context.Paths) string { return fmt.Sprintf("%s/%s/%s", paths.Data, consts.DnoteDirName, consts.DnoteDBFileName) } -func newCtx(versionTag string) (context.DnoteCtx, error) { +// newBaseCtx creates a minimal context with paths and database connection. +// This base context is used for file and database initialization before +// being enriched with config values by setupCtx. +func newBaseCtx(versionTag string) (context.DnoteCtx, error) { dnoteDir := getLegacyDnotePath(dirs.Home) paths := context.Paths{ Home: dirs.Home, @@ -95,8 +98,8 @@ func newCtx(versionTag string) (context.DnoteCtx, error) { } // Init initializes the Dnote environment and returns a new dnote context -func Init(apiEndpoint, versionTag string) (*context.DnoteCtx, error) { - ctx, err := newCtx(versionTag) +func Init(versionTag, apiEndpoint string) (*context.DnoteCtx, error) { + ctx, err := newBaseCtx(versionTag) if err != nil { return nil, errors.Wrap(err, "initializing a context") } @@ -119,7 +122,7 @@ func Init(apiEndpoint, versionTag string) (*context.DnoteCtx, error) { return nil, errors.Wrap(err, "running migration") } - ctx, err = SetupCtx(ctx) + ctx, err = setupCtx(ctx, apiEndpoint) if err != nil { return nil, errors.Wrap(err, "setting up the context") } @@ -129,8 +132,10 @@ func Init(apiEndpoint, versionTag string) (*context.DnoteCtx, error) { return &ctx, nil } -// SetupCtx populates the context and returns a new context -func SetupCtx(ctx context.DnoteCtx) (context.DnoteCtx, error) { +// setupCtx enriches the base context with values from config file and database. +// This is called after files and database have been initialized. +// If apiEndpoint is provided, it overrides the value from config. +func setupCtx(ctx context.DnoteCtx, apiEndpoint string) (context.DnoteCtx, error) { db := ctx.DB var sessionKey string @@ -150,13 +155,19 @@ func SetupCtx(ctx context.DnoteCtx) (context.DnoteCtx, error) { return ctx, errors.Wrap(err, "reading config") } + // Use override if provided, otherwise use config value + endpoint := cf.APIEndpoint + if apiEndpoint != "" { + endpoint = apiEndpoint + } + ret := context.DnoteCtx{ Paths: ctx.Paths, Version: ctx.Version, DB: ctx.DB, SessionKey: sessionKey, SessionKeyExpiry: sessionKeyExpiry, - APIEndpoint: cf.APIEndpoint, + APIEndpoint: endpoint, Editor: cf.Editor, Clock: clock.New(), EnableUpgradeCheck: cf.EnableUpgradeCheck, diff --git a/pkg/cli/infra/init_test.go b/pkg/cli/infra/init_test.go index 08f25139..cb50a95f 100644 --- a/pkg/cli/infra/init_test.go +++ b/pkg/cli/infra/init_test.go @@ -19,9 +19,12 @@ package infra import ( + "fmt" + "os" "testing" "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/config" "github.com/dnote/dnote/pkg/cli/database" "github.com/pkg/errors" ) @@ -91,3 +94,49 @@ func TestInitSystemKV_existing(t *testing.T) { db.QueryRow("SELECT value FROM system WHERE key = ?", "testKey"), &val) assert.Equal(t, val, "testVal", "system value should not have been updated") } + +func TestInit_APIEndpointChange(t *testing.T) { + // Create a temporary directory for test + tmpDir, err := os.MkdirTemp("", "dnote-init-test-*") + if err != nil { + t.Fatal(errors.Wrap(err, "creating temp dir")) + } + defer os.RemoveAll(tmpDir) + + // Set up environment to use our temp directory + t.Setenv("XDG_CONFIG_HOME", fmt.Sprintf("%s/config", tmpDir)) + t.Setenv("XDG_DATA_HOME", fmt.Sprintf("%s/data", tmpDir)) + t.Setenv("XDG_CACHE_HOME", fmt.Sprintf("%s/cache", tmpDir)) + + // First init. + endpoint1 := "http://127.0.0.1:3001" + ctx, err := Init("test-version", endpoint1) + if err != nil { + t.Fatal(errors.Wrap(err, "initializing")) + } + defer ctx.DB.Close() + assert.Equal(t, ctx.APIEndpoint, endpoint1, "should use endpoint1 API endpoint") + + // Test that config was written with endpoint1. + cf, err := config.Read(*ctx) + if err != nil { + t.Fatal(errors.Wrap(err, "reading config")) + } + + // Second init with different endpoint. + endpoint2 := "http://127.0.0.1:3002" + ctx2, err := Init("test-version", endpoint2) + if err != nil { + t.Fatal(errors.Wrap(err, "initializing with override")) + } + defer ctx2.DB.Close() + // Context must be using that endpoint. + assert.Equal(t, ctx2.APIEndpoint, endpoint2, "should use endpoint2 API endpoint") + + // The config file shouldn't have been modified. + cf2, err := config.Read(*ctx2) + if err != nil { + t.Fatal(errors.Wrap(err, "reading config after override")) + } + assert.Equal(t, cf2.APIEndpoint, cf.APIEndpoint, "config should still have original endpoint, not endpoint2") +} diff --git a/pkg/cli/main.go b/pkg/cli/main.go index 518e0ee0..31c81dd5 100644 --- a/pkg/cli/main.go +++ b/pkg/cli/main.go @@ -46,7 +46,16 @@ var apiEndpoint string var versionTag = "master" func main() { - ctx, err := infra.Init(apiEndpoint, versionTag) + // Parse flags early to check if --api-endpoint was provided + root.GetRoot().ParseFlags(os.Args[1:]) + + // Use flag value if provided, otherwise use ldflags value + endpoint := apiEndpoint + if flagValue := root.GetAPIEndpointFlag(); flagValue != "" { + endpoint = flagValue + } + + ctx, err := infra.Init(versionTag, endpoint) if err != nil { panic(errors.Wrap(err, "initializing context")) } diff --git a/pkg/cli/main_test.go b/pkg/cli/main_test.go index 05badb02..151d4cbf 100644 --- a/pkg/cli/main_test.go +++ b/pkg/cli/main_test.go @@ -109,7 +109,7 @@ func TestAddNote(t *testing.T) { t.Run("new book", func(t *testing.T) { // Set up and execute testutils.RunDnoteCmd(t, opts, binaryName, "add", "js", "-c", "foo") - testutils.WaitDnoteCmd(t, opts, testutils.UserContent, binaryName, "add", "js") + testutils.MustWaitDnoteCmd(t, opts, testutils.UserContent, binaryName, "add", "js") defer testutils.RemoveDir(t, testDir) @@ -349,7 +349,7 @@ func TestRemoveNote(t *testing.T) { if tc.yesFlag { testutils.RunDnoteCmd(t, opts, binaryName, "remove", "-y", "1") } else { - testutils.WaitDnoteCmd(t, opts, testutils.UserConfirm, binaryName, "remove", "1") + testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveNote, binaryName, "remove", "1") } defer testutils.RemoveDir(t, testDir) @@ -436,7 +436,7 @@ func TestRemoveBook(t *testing.T) { if tc.yesFlag { testutils.RunDnoteCmd(t, opts, binaryName, "remove", "-y", "js") } else { - testutils.WaitDnoteCmd(t, opts, testutils.UserConfirm, binaryName, "remove", "js") + testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveBook, binaryName, "remove", "js") } defer testutils.RemoveDir(t, testDir) diff --git a/pkg/cli/migrate/migrations.go b/pkg/cli/migrate/migrations.go index 0357dd2a..af5ae86e 100644 --- a/pkg/cli/migrate/migrations.go +++ b/pkg/cli/migrate/migrations.go @@ -539,7 +539,10 @@ var lm12 = migration{ return errors.Wrap(err, "reading config") } - cf.APIEndpoint = "https://api.getdnote.com" + // Only set if not already configured + if cf.APIEndpoint == "" { + cf.APIEndpoint = "https://api.getdnote.com" + } err = config.Write(ctx, cf) if err != nil { diff --git a/pkg/cli/testutils/main.go b/pkg/cli/testutils/main.go index afc12f59..9b4e945d 100644 --- a/pkg/cli/testutils/main.go +++ b/pkg/cli/testutils/main.go @@ -20,6 +20,7 @@ package testutils import ( + "bufio" "bytes" "encoding/json" "io" @@ -37,6 +38,16 @@ import ( "github.com/pkg/errors" ) +// Prompts for user input +const ( + PromptRemoveNote = "remove this note?" + PromptDeleteBook = "delete book" + PromptEmptyServer = "The server is empty but you have local data" +) + +// Timeout for waiting for prompts in tests +const promptTimeout = 10 * time.Second + // Login simulates a logged in user by inserting credentials in the local database func Login(t *testing.T, ctx *context.DnoteCtx) { db := ctx.DB @@ -153,58 +164,167 @@ func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg . t.Logf("\n%s", stdout) } -// WaitDnoteCmd runs a dnote command and waits until the command is exited -func WaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.WriteCloser) error, binaryName string, arg ...string) { +// WaitDnoteCmd runs a dnote command and passes stdout to the callback. +func WaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.Reader, io.WriteCloser) error, binaryName string, arg ...string) (string, error) { t.Logf("running: %s %s", binaryName, strings.Join(arg, " ")) - cmd, stderr, stdout, err := NewDnoteCmd(opts, binaryName, arg...) + binaryPath, err := filepath.Abs(binaryName) if err != nil { - t.Logf("\n%s", stdout) - t.Fatal(errors.Wrap(err, "getting command").Error()) + return "", errors.Wrap(err, "getting absolute path to test binary") + } + + cmd := exec.Command(binaryPath, arg...) + cmd.Env = opts.Env + + var stderr bytes.Buffer + cmd.Stderr = &stderr + + stdout, err := cmd.StdoutPipe() + if err != nil { + return "", errors.Wrap(err, "getting stdout pipe") } stdin, err := cmd.StdinPipe() if err != nil { - t.Logf("\n%s", stdout) - t.Fatal(errors.Wrap(err, "getting stdin %s")) + return "", errors.Wrap(err, "getting stdin") } defer stdin.Close() - // Start the program - err = cmd.Start() - if err != nil { - t.Logf("\n%s", stdout) - t.Fatal(errors.Wrap(err, "starting command")) + if err = cmd.Start(); err != nil { + return "", errors.Wrap(err, "starting command") } - err = runFunc(stdin) + var output bytes.Buffer + tee := io.TeeReader(stdout, &output) + + err = runFunc(tee, stdin) if err != nil { - t.Logf("\n%s", stdout) - t.Fatal(errors.Wrap(err, "running with stdin")) + t.Logf("\n%s", output.String()) + return output.String(), errors.Wrap(err, "running callback") } - err = cmd.Wait() - if err != nil { - t.Logf("\n%s", stdout) - t.Fatal(errors.Wrapf(err, "running command %s", stderr.String())) + io.Copy(&output, stdout) + + if err := cmd.Wait(); err != nil { + t.Logf("\n%s", output.String()) + return output.String(), errors.Wrapf(err, "command failed: %s", stderr.String()) } - // Print stdout if and only if test fails later - t.Logf("\n%s", stdout) + t.Logf("\n%s", output.String()) + return output.String(), nil } -// UserConfirm simulates confirmation from the user by writing to stdin -func UserConfirm(stdin io.WriteCloser) error { - // confirm - if _, err := io.WriteString(stdin, "y\n"); err != nil { - return errors.Wrap(err, "indicating confirmation in stdin") +func MustWaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.Reader, io.WriteCloser) error, binaryName string, arg ...string) string { + output, err := WaitDnoteCmd(t, opts, runFunc, binaryName, arg...) + if err != nil { + t.Fatal(err) + } + + return output +} + +// waitForPrompt waits for an expected prompt to appear in stdout with a timeout. +// Returns an error if the prompt is not found within the timeout period. +// Handles prompts with or without newlines by reading character by character. +func waitForPrompt(stdout io.Reader, expectedPrompt string, timeout time.Duration) error { + type result struct { + found bool + err error + } + resultCh := make(chan result, 1) + + go func() { + reader := bufio.NewReader(stdout) + var buffer strings.Builder + found := false + + for { + b, err := reader.ReadByte() + if err != nil { + resultCh <- result{found: found, err: err} + return + } + + buffer.WriteByte(b) + if strings.Contains(buffer.String(), expectedPrompt) { + found = true + break + } + } + + resultCh <- result{found: found, err: nil} + }() + + select { + case res := <-resultCh: + if res.err != nil && res.err != io.EOF { + return errors.Wrap(res.err, "reading stdout") + } + if !res.found { + return errors.Errorf("expected prompt '%s' not found in stdout", expectedPrompt) + } + return nil + case <-time.After(timeout): + return errors.Errorf("timeout waiting for prompt '%s'", expectedPrompt) + } +} + +// MustWaitForPrompt waits for an expected prompt with a default timeout. +// Fails the test if the prompt is not found or an error occurs. +func MustWaitForPrompt(t *testing.T, stdout io.Reader, expectedPrompt string) { + if err := waitForPrompt(stdout, expectedPrompt, promptTimeout); err != nil { + t.Fatal(err) + } +} + +// userRespondToPrompt is a helper that waits for a prompt and sends a response. +func userRespondToPrompt(stdout io.Reader, stdin io.WriteCloser, expectedPrompt, response, action string) error { + if err := waitForPrompt(stdout, expectedPrompt, promptTimeout); err != nil { + return err + } + + if _, err := io.WriteString(stdin, response); err != nil { + return errors.Wrapf(err, "indicating %s in stdin", action) } return nil } -// UserContent simulates content from the user by writing to stdin -func UserContent(stdin io.WriteCloser) error { +// userConfirmOutput simulates confirmation from the user by writing to stdin. +// It waits for the expected prompt with a timeout to prevent deadlocks. +func userConfirmOutput(stdout io.Reader, stdin io.WriteCloser, expectedPrompt string) error { + return userRespondToPrompt(stdout, stdin, expectedPrompt, "y\n", "confirmation") +} + +// userCancelOutput simulates cancellation from the user by writing to stdin. +// It waits for the expected prompt with a timeout to prevent deadlocks. +func userCancelOutput(stdout io.Reader, stdin io.WriteCloser, expectedPrompt string) error { + return userRespondToPrompt(stdout, stdin, expectedPrompt, "n\n", "cancellation") +} + +// ConfirmRemoveNote waits for prompt for removing a note and confirms. +func ConfirmRemoveNote(stdout io.Reader, stdin io.WriteCloser) error { + return userConfirmOutput(stdout, stdin, PromptRemoveNote) +} + +// ConfirmRemoveBook waits for prompt for deleting a book confirms. +func ConfirmRemoveBook(stdout io.Reader, stdin io.WriteCloser) error { + return userConfirmOutput(stdout, stdin, PromptDeleteBook) +} + +// UserConfirmEmptyServerSync waits for an empty server prompt and confirms. +func UserConfirmEmptyServerSync(stdout io.Reader, stdin io.WriteCloser) error { + return userConfirmOutput(stdout, stdin, PromptEmptyServer) +} + +// UserCancelEmptyServerSync waits for an empty server prompt and confirms. +func UserCancelEmptyServerSync(stdout io.Reader, stdin io.WriteCloser) error { + return userCancelOutput(stdout, stdin, PromptEmptyServer) +} + +// UserContent simulates content from the user by writing to stdin. +// This is used for piped input where no prompt is shown. +func UserContent(stdout io.Reader, stdin io.WriteCloser) error { longText := `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.` diff --git a/pkg/e2e/sync_test.go b/pkg/e2e/sync_test.go index 2ddf373e..b4fec91f 100644 --- a/pkg/e2e/sync_test.go +++ b/pkg/e2e/sync_test.go @@ -82,10 +82,9 @@ func clearTmp(t *testing.T) { } } -func TestMain(m *testing.M) { - // Set up server database - use file-based DB for e2e tests - dbPath := fmt.Sprintf("%s/server.db", testDir) - serverDb = apitest.InitDB(dbPath) +// setupTestServer creates a test server with its own database +func setupTestServer(dbPath string, serverTime time.Time) (*httptest.Server, *gorm.DB, error) { + db := apitest.InitDB(dbPath) mockClock := clock.NewMock() mockClock.SetNow(serverTime) @@ -94,12 +93,24 @@ func TestMain(m *testing.M) { a.Clock = mockClock a.EmailTemplates = mailer.Templates{} a.EmailBackend = &apitest.MockEmailbackendImplementation{} - a.DB = serverDb + a.DB = db + + server, err := controllers.NewServer(&a) + if err != nil { + return nil, nil, errors.Wrap(err, "initializing server") + } + + return server, db, nil +} + +func TestMain(m *testing.M) { + // Set up server database - use file-based DB for e2e tests + dbPath := fmt.Sprintf("%s/server.db", testDir) var err error - server, err = controllers.NewServer(&a) + server, serverDb, err = setupTestServer(dbPath, serverTime) if err != nil { - panic(errors.Wrap(err, "initializing router")) + panic(err) } defer server.Close() @@ -234,6 +245,10 @@ type systemState struct { // checkState compares the state of the client and the server with the given system state func checkState(t *testing.T, ctx context.DnoteCtx, user database.User, expected systemState) { + checkStateWithDB(t, ctx, user, serverDb, expected) +} + +func checkStateWithDB(t *testing.T, ctx context.DnoteCtx, user database.User, db *gorm.DB, expected systemState) { clientDB := ctx.DB var clientBookCount, clientNoteCount int @@ -250,12 +265,12 @@ func checkState(t *testing.T, ctx context.DnoteCtx, user database.User, expected assert.Equal(t, clientLastSyncAt, expected.clientLastSyncAt, "client last_sync_at mismatch") var serverBookCount, serverNoteCount int64 - apitest.MustExec(t, serverDb.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") - apitest.MustExec(t, serverDb.Model(&database.Book{}).Count(&serverBookCount), "counting api notes") + apitest.MustExec(t, db.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") + apitest.MustExec(t, db.Model(&database.Book{}).Count(&serverBookCount), "counting api notes") assert.Equal(t, serverNoteCount, expected.serverNoteCount, "server note count mismatch") assert.Equal(t, serverBookCount, expected.serverBookCount, "server book count mismatch") var serverUser database.User - apitest.MustExec(t, serverDb.Where("id = ?", user.ID).First(&serverUser), "finding user") + apitest.MustExec(t, db.Where("id = ?", user.ID).First(&serverUser), "finding user") assert.Equal(t, serverUser.MaxUSN, expected.serverUserMaxUSN, "user max_usn mismatch") } @@ -412,7 +427,7 @@ func TestSync_oneway(t *testing.T) { cliDatabase.MustScan(t, "getting id of note to delete", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "css2"), &nid2) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js3-edited") - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "css", nid2) + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "css", nid2) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css3") clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css4") @@ -777,9 +792,9 @@ func TestSync_twoway(t *testing.T) { var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js3"), &nid) - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "algorithms") + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "algorithms") clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css4") - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) return map[string]string{ "jsBookUUID": jsBookUUID, @@ -989,7 +1004,7 @@ func TestSync_twoway(t *testing.T) { // 2. on cli clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js2") - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js") + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "math", "-c", "math1") var nid string @@ -1337,7 +1352,7 @@ func TestSync(t *testing.T) { // 2. on cli clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js") + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1391,7 +1406,7 @@ func TestSync(t *testing.T) { clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2009,7 +2024,7 @@ func TestSync(t *testing.T) { apiDeleteBook(t, user, jsBookUUID, "deleting js book") // 4. on cli - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js") + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2069,7 +2084,7 @@ func TestSync(t *testing.T) { // 4. on cli var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js1"), &nid) - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2614,7 +2629,7 @@ func TestSync(t *testing.T) { clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) // 3. on server apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js note 1") @@ -2688,7 +2703,7 @@ func TestSync(t *testing.T) { clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) // 3. on server apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") @@ -2989,7 +3004,7 @@ func TestSync(t *testing.T) { // 2. on cli clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js") + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") // 3. on server apiPatchBook(t, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-edited"), "editing js book") @@ -3060,7 +3075,7 @@ func TestSync(t *testing.T) { apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js1 note") // 4. on cli - clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirm, cliBinaryName, "remove", "js") + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3862,3 +3877,565 @@ func TestFullSync(t *testing.T) { }) }) } + +func TestSync_EmptyServer(t *testing.T) { + t.Run("sync to empty server after syncing to non-empty server", func(t *testing.T) { + // Test server data loss/wipe scenario (disaster recovery): + // Verify empty server detection works when the server loses all its data + + // clean up + apitest.ClearData(serverDb) + defer apitest.ClearData(serverDb) + + clearTmp(t) + + ctx := context.InitTestCtx(t, paths, nil) + defer context.TeardownTestCtx(t, ctx) + + user := setupUser(t, &ctx) + + // Step 1: Create local data and sync to server + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + + // Verify sync succeeded + checkState(t, ctx, user, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Clear all server data to simulate switching to a completely new empty server + apitest.ClearData(serverDb) + // Recreate user and session (simulating a new server) + user = setupUser(t, &ctx) + + // Step 3: Sync again - should detect empty server and prompt user + // User confirms with "y" + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync") + + // Step 4: Verify data was uploaded to the empty server + checkState(t, ctx, user, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Verify the content is correct on both client and server + var cliNote1JS, cliNote1CSS cliDatabase.Note + var cliBookJS, cliBookCSS cliDatabase.Book + cliDatabase.MustScan(t, "finding cliNote1JS", ctx.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "js1"), &cliNote1JS.UUID, &cliNote1JS.Body) + cliDatabase.MustScan(t, "finding cliNote1CSS", ctx.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "css1"), &cliNote1CSS.UUID, &cliNote1CSS.Body) + cliDatabase.MustScan(t, "finding cliBookJS", ctx.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label) + cliDatabase.MustScan(t, "finding cliBookCSS", ctx.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label) + + assert.Equal(t, cliNote1JS.Body, "js1", "js note body mismatch") + assert.Equal(t, cliNote1CSS.Body, "css1", "css note body mismatch") + assert.Equal(t, cliBookJS.Label, "js", "js book label mismatch") + assert.Equal(t, cliBookCSS.Label, "css", "css book label mismatch") + + // Verify on server side + var serverNoteJS, serverNoteCSS database.Note + var serverBookJS, serverBookCSS database.Book + apitest.MustExec(t, serverDb.Where("body = ?", "js1").First(&serverNoteJS), "finding server note js1") + apitest.MustExec(t, serverDb.Where("body = ?", "css1").First(&serverNoteCSS), "finding server note css1") + apitest.MustExec(t, serverDb.Where("label = ?", "js").First(&serverBookJS), "finding server book js") + apitest.MustExec(t, serverDb.Where("label = ?", "css").First(&serverBookCSS), "finding server book css") + + assert.Equal(t, serverNoteJS.Body, "js1", "server js note body mismatch") + assert.Equal(t, serverNoteCSS.Body, "css1", "server css note body mismatch") + assert.Equal(t, serverBookJS.Label, "js", "server js book label mismatch") + assert.Equal(t, serverBookCSS.Label, "css", "server css book label mismatch") + }) + + t.Run("user cancels empty server prompt", func(t *testing.T) { + // clean up + apitest.ClearData(serverDb) + defer apitest.ClearData(serverDb) + + clearTmp(t) + + ctx := context.InitTestCtx(t, paths, nil) + defer context.TeardownTestCtx(t, ctx) + + user := setupUser(t, &ctx) + + // Step 1: Create local data and sync to server + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + + // Verify initial sync succeeded + checkState(t, ctx, user, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Clear all server data + apitest.ClearData(serverDb) + user = setupUser(t, &ctx) + + // Step 3: Sync again but user cancels with "n" + output, err := clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserCancelEmptyServerSync, cliBinaryName, "sync") + if err == nil { + t.Fatal("Expected sync to fail when user cancels, but it succeeded") + } + + // Verify the prompt appeared + if !strings.Contains(output, clitest.PromptEmptyServer) { + t.Fatalf("Expected empty server warning in output, got: %s", output) + } + + // Step 4: Verify local state unchanged (transaction rolled back) + checkState(t, ctx, user, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 0, + serverBookCount: 0, + serverUserMaxUSN: 0, + }) + + // Verify items still have original USN and dirty=false + var book cliDatabase.Book + var note cliDatabase.Note + cliDatabase.MustScan(t, "checking book state", ctx.DB.QueryRow("SELECT usn, dirty FROM books WHERE label = ?", "js"), &book.USN, &book.Dirty) + cliDatabase.MustScan(t, "checking note state", ctx.DB.QueryRow("SELECT usn, dirty FROM notes WHERE body = ?", "js1"), ¬e.USN, ¬e.Dirty) + + assert.NotEqual(t, book.USN, 0, "book USN should not be reset") + assert.NotEqual(t, note.USN, 0, "note USN should not be reset") + assert.Equal(t, book.Dirty, false, "book should not be marked dirty") + assert.Equal(t, note.Dirty, false, "note should not be marked dirty") + }) + + t.Run("all local data is marked deleted - should not upload", func(t *testing.T) { + // Test edge case: Server MaxUSN=0, local MaxUSN>0, but all items are deleted=true + // Should NOT prompt because there's nothing to upload + + // clean up + apitest.ClearData(serverDb) + defer apitest.ClearData(serverDb) + + clearTmp(t) + + ctx := context.InitTestCtx(t, paths, nil) + defer context.TeardownTestCtx(t, ctx) + + user := setupUser(t, &ctx) + + // Step 1: Create local data and sync to server + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + + // Verify initial sync succeeded + checkState(t, ctx, user, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Delete all local notes and books (mark as deleted) + cliDatabase.MustExec(t, "marking all books deleted", ctx.DB, "UPDATE books SET deleted = 1") + cliDatabase.MustExec(t, "marking all notes deleted", ctx.DB, "UPDATE notes SET deleted = 1") + + // Step 3: Clear server data to simulate switching to empty server + apitest.ClearData(serverDb) + user = setupUser(t, &ctx) + + // Step 4: Sync - should NOT prompt because bookCount=0 and noteCount=0 (counting only deleted=0) + // This should complete without user interaction + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + + // Verify no data was uploaded (server still empty, but client still has deleted items) + // Check server is empty + var serverNoteCount, serverBookCount int64 + apitest.MustExec(t, serverDb.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") + apitest.MustExec(t, serverDb.Model(&database.Book{}).Count(&serverBookCount), "counting server books") + assert.Equal(t, serverNoteCount, int64(0), "server should have no notes") + assert.Equal(t, serverBookCount, int64(0), "server should have no books") + + // Check client still has the deleted items locally + var clientNoteCount, clientBookCount int + cliDatabase.MustScan(t, "counting client notes", ctx.DB.QueryRow("SELECT count(*) FROM notes WHERE deleted = 1"), &clientNoteCount) + cliDatabase.MustScan(t, "counting client books", ctx.DB.QueryRow("SELECT count(*) FROM books WHERE deleted = 1"), &clientBookCount) + assert.Equal(t, clientNoteCount, 2, "client should still have 2 deleted notes") + assert.Equal(t, clientBookCount, 2, "client should still have 2 deleted books") + + // Verify lastMaxUSN was reset to 0 + var lastMaxUSN int + cliDatabase.MustScan(t, "getting lastMaxUSN", ctx.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) + assert.Equal(t, lastMaxUSN, 0, "lastMaxUSN should be reset to 0") + }) + + t.Run("race condition - other client uploads first", func(t *testing.T) { + // This test exercises a race condition that can occur during sync: + // While Client A is waiting for user input, Client B uploads data to the server. + // + // The empty server scenario is the natural place to test this because + // an empty server detection triggers a prompt, at which point the test + // can make client B upload data. We trigger the race condition deterministically. + // + // Test flow: + // - Client A detects empty server and prompts user + // - While waiting for confirmation, Client B uploads the same data via API + // - Client A continues and handles the 409 conflict gracefully by: + // 1. Detecting the 409 error when trying to CREATE books that already exist + // 2. Running stepSync to pull the server's books (js, css) + // 3. mergeBook renames local conflicts (js→js_2, css→css_2) + // 4. Retrying sendChanges to upload the renamed books + // - Result: Both clients' data is preserved (4 books total) + + // Clean up + apitest.ClearData(serverDb) + defer apitest.ClearData(serverDb) + clearTmp(t) + + ctx := context.InitTestCtx(t, paths, nil) + defer context.TeardownTestCtx(t, ctx) + + user := setupUser(t, &ctx) + + // Step 1: Create local data and sync to establish lastMaxUSN > 0 + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + + // Verify initial sync succeeded + checkState(t, ctx, user, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Clear server to simulate switching to empty server + apitest.ClearData(serverDb) + user = setupUser(t, &ctx) + + // Step 3: Trigger sync which will detect empty server and prompt user + // Inside the callback (before confirming), we simulate Client B uploading via API. + // We wait for the empty server prompt to ensure Client B uploads AFTER + // GetSyncState but BEFORE the sync decision, creating the race condition deterministically + raceCallback := func(stdout io.Reader, stdin io.WriteCloser) error { + // First, wait for the prompt to ensure Client A has obtained the sync state from the server. + clitest.MustWaitForPrompt(t, stdout, clitest.PromptEmptyServer) + + // Now Client B uploads the same data via API (after Client A got the sync state from the server + // but before its sync decision) + // This creates the race condition: Client A thinks server is empty, but Client B uploads data + jsBookUUID := apiCreateBook(t, user, "js", "client B creating js book") + cssBookUUID := apiCreateBook(t, user, "css", "client B creating css book") + apiCreateNote(t, user, jsBookUUID, "js1", "client B creating js note") + apiCreateNote(t, user, cssBookUUID, "css1", "client B creating css note") + + // Now user confirms + if _, err := io.WriteString(stdin, "y\n"); err != nil { + return errors.Wrap(err, "confirming sync") + } + + return nil + } + + // Step 4: Client A runs sync with race condition + // The 409 conflict is automatically handled: + // - When 409 is detected, isBehind flag is set + // - stepSync pulls Client B's data + // - mergeBook renames Client A's books to js_2, css_2 + // - Renamed books are uploaded + // - Both clients' data is preserved. + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, raceCallback, cliBinaryName, "sync") + + // Verify final state - both clients' data preserved + checkStateWithDB(t, ctx, user, serverDb, systemState{ + clientNoteCount: 4, // Both clients' notes + clientBookCount: 4, // js, css, js_2, css_2 + clientLastMaxUSN: 8, // 4 from Client B + 4 from Client A's renamed books/notes + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 4, + serverUserMaxUSN: 8, + }) + + // Verify server has both clients' books + var svrBookJS, svrBookCSS, svrBookJS2, svrBookCSS2 database.Book + apitest.MustExec(t, serverDb.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") + apitest.MustExec(t, serverDb.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") + apitest.MustExec(t, serverDb.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") + apitest.MustExec(t, serverDb.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") + + assert.Equal(t, svrBookJS.Label, "js", "server should have book 'js' (Client B)") + assert.Equal(t, svrBookCSS.Label, "css", "server should have book 'css' (Client B)") + assert.Equal(t, svrBookJS2.Label, "js_2", "server should have book 'js_2' (Client A renamed)") + assert.Equal(t, svrBookCSS2.Label, "css_2", "server should have book 'css_2' (Client A renamed)") + + // Verify client has all books + var cliBookJS, cliBookCSS, cliBookJS2, cliBookCSS2 cliDatabase.Book + cliDatabase.MustScan(t, "finding client book 'js'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) + cliDatabase.MustScan(t, "finding client book 'css'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) + cliDatabase.MustScan(t, "finding client book 'js_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) + cliDatabase.MustScan(t, "finding client book 'css_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) + + // Verify client UUIDs match server + assert.Equal(t, cliBookJS.UUID, svrBookJS.UUID, "client 'js' UUID should match server") + assert.Equal(t, cliBookCSS.UUID, svrBookCSS.UUID, "client 'css' UUID should match server") + assert.Equal(t, cliBookJS2.UUID, svrBookJS2.UUID, "client 'js_2' UUID should match server") + assert.Equal(t, cliBookCSS2.UUID, svrBookCSS2.UUID, "client 'css_2' UUID should match server") + + // Verify all items have non-zero USN (synced successfully) + assert.NotEqual(t, cliBookJS.USN, 0, "client 'js' should have non-zero USN") + assert.NotEqual(t, cliBookCSS.USN, 0, "client 'css' should have non-zero USN") + assert.NotEqual(t, cliBookJS2.USN, 0, "client 'js_2' should have non-zero USN") + assert.NotEqual(t, cliBookCSS2.USN, 0, "client 'css_2' should have non-zero USN") + }) + + t.Run("sync to server A, then B, then back to A, then back to B", func(t *testing.T) { + // Test switching between two actual servers to verify: + // 1. Empty server detection works when switching to empty server + // 2. No false detection when switching back to non-empty servers + // 3. Both servers maintain independent state across multiple switches + + // Clean up + clearTmp(t) + + ctx := context.InitTestCtx(t, paths, nil) + defer context.TeardownTestCtx(t, ctx) + + // Create Server A with its own database + dbPathA := fmt.Sprintf("%s/serverA.db", testDir) + defer os.Remove(dbPathA) + + serverA, serverDbA, err := setupTestServer(dbPathA, serverTime) + if err != nil { + t.Fatal(errors.Wrap(err, "setting up server A")) + } + defer serverA.Close() + + // Create Server B with its own database + dbPathB := fmt.Sprintf("%s/serverB.db", testDir) + defer os.Remove(dbPathB) + + serverB, serverDbB, err := setupTestServer(dbPathB, serverTime) + if err != nil { + t.Fatal(errors.Wrap(err, "setting up server B")) + } + defer serverB.Close() + + // Step 1: Set up user on Server A and sync + apiEndpointA := fmt.Sprintf("%s/api", serverA.URL) + + userA := apitest.SetupUserData(serverDbA) + apitest.SetupAccountData(serverDbA, userA, "alice@example.com", "pass1234") + sessionA := apitest.SetupSession(serverDbA, userA) + cliDatabase.MustExec(t, "inserting session_key", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, sessionA.Key) + cliDatabase.MustExec(t, "inserting session_key_expiry", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, sessionA.ExpiresAt.Unix()) + + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--api-endpoint", apiEndpointA, "sync") + + // Verify sync to Server A succeeded + checkStateWithDB(t, ctx, userA, serverDbA, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Switch to Server B (empty) and sync + apiEndpointB := fmt.Sprintf("%s/api", serverB.URL) + + // Set up user on Server B + userB := apitest.SetupUserData(serverDbB) + apitest.SetupAccountData(serverDbB, userB, "alice@example.com", "pass1234") + sessionB := apitest.SetupSession(serverDbB, userB) + cliDatabase.MustExec(t, "updating session_key for B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry for B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + + // Should detect empty server and prompt + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "--api-endpoint", apiEndpointB, "sync") + + // Verify Server B now has data + checkStateWithDB(t, ctx, userB, serverDbB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 3: Switch back to Server A and sync + cliDatabase.MustExec(t, "updating session_key back to A", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry back to A", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + + // Should NOT trigger empty server detection (Server A has MaxUSN > 0) + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--api-endpoint", apiEndpointA, "sync") + + // Verify Server A still has its data + checkStateWithDB(t, ctx, userA, serverDbA, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 4: Switch back to Server B and sync again + cliDatabase.MustExec(t, "updating session_key back to B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry back to B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + + // Should NOT trigger empty server detection (Server B now has MaxUSN > 0 from Step 2) + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--api-endpoint", apiEndpointB, "sync") + + // Verify both servers maintain independent state + checkStateWithDB(t, ctx, userB, serverDbB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + }) +} + +func TestSync_FreshClientConcurrent(t *testing.T) { + // Test the core issue: Fresh client (never synced, lastMaxUSN=0) syncing to a server + // that already has data uploaded by another client. + // + // Scenario: + // 1. Client A creates local notes (never synced, lastMaxUSN=0, lastSyncAt=0) + // 2. Client B uploads same book names to server first + // 3. Client A syncs + // + // Expected: Client A should pull server data first, detect duplicate book names, + // rename local books to avoid conflicts (js→js_2), then upload successfully. + + // Clean up + apitest.ClearData(serverDb) + defer apitest.ClearData(serverDb) + clearTmp(t) + + ctx := context.InitTestCtx(t, paths, nil) + defer context.TeardownTestCtx(t, ctx) + + user := setupUser(t, &ctx) + + // Client A: Create local data (never sync) + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + + // Client B: Upload same book names to server via API + jsBookUUID := apiCreateBook(t, user, "js", "client B creating js book") + cssBookUUID := apiCreateBook(t, user, "css", "client B creating css book") + apiCreateNote(t, user, jsBookUUID, "js2", "client B note") + apiCreateNote(t, user, cssBookUUID, "css2", "client B note") + + // Client A syncs - should handle the conflict gracefully + // Expected: pulls server data, renames local books to js_2/css_2, uploads successfully + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + + // Verify: Should have 4 books and 4 notes on both client and server + // USN breakdown: 2 books + 2 notes from Client B (USN 1-4), then 2 books + 2 notes from Client A (USN 5-8) + checkStateWithDB(t, ctx, user, serverDb, systemState{ + clientNoteCount: 4, + clientBookCount: 4, + clientLastMaxUSN: 8, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 4, + serverUserMaxUSN: 8, + }) + + // Verify server has all 4 books with correct names + var svrBookJS, svrBookCSS, svrBookJS2, svrBookCSS2 database.Book + apitest.MustExec(t, serverDb.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") + apitest.MustExec(t, serverDb.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") + apitest.MustExec(t, serverDb.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") + apitest.MustExec(t, serverDb.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") + + assert.Equal(t, svrBookJS.Label, "js", "server should have book 'js' (Client B)") + assert.Equal(t, svrBookCSS.Label, "css", "server should have book 'css' (Client B)") + assert.Equal(t, svrBookJS2.Label, "js_2", "server should have book 'js_2' (Client A renamed)") + assert.Equal(t, svrBookCSS2.Label, "css_2", "server should have book 'css_2' (Client A renamed)") + + // Verify server has all 4 notes with correct content + var svrNoteJS1, svrNoteJS2, svrNoteCSS1, svrNoteCSS2 database.Note + apitest.MustExec(t, serverDb.Where("body = ?", "js1").First(&svrNoteJS1), "finding server note 'js1'") + apitest.MustExec(t, serverDb.Where("body = ?", "js2").First(&svrNoteJS2), "finding server note 'js2'") + apitest.MustExec(t, serverDb.Where("body = ?", "css1").First(&svrNoteCSS1), "finding server note 'css1'") + apitest.MustExec(t, serverDb.Where("body = ?", "css2").First(&svrNoteCSS2), "finding server note 'css2'") + + assert.Equal(t, svrNoteJS1.BookUUID, svrBookJS2.UUID, "note 'js1' should belong to book 'js_2' (Client A)") + assert.Equal(t, svrNoteJS2.BookUUID, svrBookJS.UUID, "note 'js2' should belong to book 'js' (Client B)") + assert.Equal(t, svrNoteCSS1.BookUUID, svrBookCSS2.UUID, "note 'css1' should belong to book 'css_2' (Client A)") + assert.Equal(t, svrNoteCSS2.BookUUID, svrBookCSS.UUID, "note 'css2' should belong to book 'css' (Client B)") + + // Verify client has all 4 books + var cliBookJS, cliBookCSS, cliBookJS2, cliBookCSS2 cliDatabase.Book + cliDatabase.MustScan(t, "finding client book 'js'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) + cliDatabase.MustScan(t, "finding client book 'css'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) + cliDatabase.MustScan(t, "finding client book 'js_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) + cliDatabase.MustScan(t, "finding client book 'css_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) + + // Verify client UUIDs match server + assert.Equal(t, cliBookJS.UUID, svrBookJS.UUID, "client 'js' UUID should match server") + assert.Equal(t, cliBookCSS.UUID, svrBookCSS.UUID, "client 'css' UUID should match server") + assert.Equal(t, cliBookJS2.UUID, svrBookJS2.UUID, "client 'js_2' UUID should match server") + assert.Equal(t, cliBookCSS2.UUID, svrBookCSS2.UUID, "client 'css_2' UUID should match server") + + // Verify all books have non-zero USN (synced successfully) + assert.NotEqual(t, cliBookJS.USN, 0, "client 'js' should have non-zero USN") + assert.NotEqual(t, cliBookCSS.USN, 0, "client 'css' should have non-zero USN") + assert.NotEqual(t, cliBookJS2.USN, 0, "client 'js_2' should have non-zero USN") + assert.NotEqual(t, cliBookCSS2.USN, 0, "client 'css_2' should have non-zero USN") + + // Verify client has all 4 notes + var cliNoteJS1, cliNoteJS2, cliNoteCSS1, cliNoteCSS2 cliDatabase.Note + cliDatabase.MustScan(t, "finding client note 'js1'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "js1"), &cliNoteJS1.UUID, &cliNoteJS1.Body, &cliNoteJS1.USN) + cliDatabase.MustScan(t, "finding client note 'js2'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "js2"), &cliNoteJS2.UUID, &cliNoteJS2.Body, &cliNoteJS2.USN) + cliDatabase.MustScan(t, "finding client note 'css1'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "css1"), &cliNoteCSS1.UUID, &cliNoteCSS1.Body, &cliNoteCSS1.USN) + cliDatabase.MustScan(t, "finding client note 'css2'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "css2"), &cliNoteCSS2.UUID, &cliNoteCSS2.Body, &cliNoteCSS2.USN) + + // Verify client note UUIDs match server + assert.Equal(t, cliNoteJS1.UUID, svrNoteJS1.UUID, "client note 'js1' UUID should match server") + assert.Equal(t, cliNoteJS2.UUID, svrNoteJS2.UUID, "client note 'js2' UUID should match server") + assert.Equal(t, cliNoteCSS1.UUID, svrNoteCSS1.UUID, "client note 'css1' UUID should match server") + assert.Equal(t, cliNoteCSS2.UUID, svrNoteCSS2.UUID, "client note 'css2' UUID should match server") + + // Verify all notes have non-zero USN (synced successfully) + assert.NotEqual(t, cliNoteJS1.USN, 0, "client note 'js1' should have non-zero USN") + assert.NotEqual(t, cliNoteJS2.USN, 0, "client note 'js2' should have non-zero USN") + assert.NotEqual(t, cliNoteCSS1.USN, 0, "client note 'css1' should have non-zero USN") + assert.NotEqual(t, cliNoteCSS2.USN, 0, "client note 'css2' should have non-zero USN") +} From 74119b1d0b44ae38a38378cda07ae1e4cfdc5ad1 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 12 Oct 2025 13:02:59 -0700 Subject: [PATCH 09/33] Automate release process (#691) --- .github/workflows/release-cli.yml | 40 +++- .github/workflows/release-server.yml | 21 +- CHANGELOG.md | 300 --------------------------- scripts/generate-changelog.sh | 62 ++++++ 4 files changed, 121 insertions(+), 302 deletions(-) delete mode 100644 CHANGELOG.md create mode 100755 scripts/generate-changelog.sh diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 65b2fd0b..723c2d1a 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v5 + with: + fetch-depth: 0 - uses: actions/setup-go@v6 with: go-version: '>=1.25.0' @@ -36,6 +38,23 @@ jobs: - name: Build CLI run: make version=${{ steps.version.outputs.version }} build-cli + - name: Generate changelog + run: | + VERSION="${{ steps.version.outputs.version }}" + TAG="cli-v${VERSION}" + + # Find previous CLI tag + PREV_TAG=$(git tag --sort=-version:refname | grep "^cli-" | grep -v "^${TAG}$" | head -n 1) + + if [ -z "$PREV_TAG" ]; then + echo "Error: No previous CLI tag found" + echo "This appears to be the first release." + exit 1 + fi + + ./scripts/generate-changelog.sh cli "$TAG" "$PREV_TAG" > /tmp/changelog.txt + cat /tmp/changelog.txt + - name: Create GitHub release env: GH_TOKEN: ${{ github.token }} @@ -54,5 +73,24 @@ jobs: build/cli/*_checksums.txt \ $FLAGS \ --title="$TAG" \ - --notes="Please see the [CHANGELOG](https://github.com/dnote/dnote/blob/master/CHANGELOG.md)" \ + --notes-file=/tmp/changelog.txt \ --draft + + - name: Bump Homebrew formula + env: + HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_RELEASE_TOKEN }} + run: | + VERSION="${{ steps.version.outputs.version }}" + TAG="cli-v${VERSION}" + + # Only bump Homebrew for stable releases (not prereleases) + if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + brew update-reset + brew bump-formula-pr \ + --no-browse \ + --tag="$TAG" \ + --revision="${{ github.sha }}" \ + dnote + else + echo "Skipping Homebrew update for prerelease version: $VERSION" + fi diff --git a/.github/workflows/release-server.yml b/.github/workflows/release-server.yml index 25c6f88b..f52e1508 100644 --- a/.github/workflows/release-server.yml +++ b/.github/workflows/release-server.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v5 + with: + fetch-depth: 0 - uses: actions/setup-go@v6 with: go-version: '>=1.25.0' @@ -36,6 +38,23 @@ jobs: - name: Build server run: make version=${{ steps.version.outputs.version }} build-server + - name: Generate changelog + run: | + VERSION="${{ steps.version.outputs.version }}" + TAG="server-v${VERSION}" + + # Find previous server tag + PREV_TAG=$(git tag --sort=-version:refname | grep "^server-" | grep -v "^${TAG}$" | head -n 1) + + if [ -z "$PREV_TAG" ]; then + echo "Error: No previous server tag found" + echo "This appears to be the first release." + exit 1 + fi + + ./scripts/generate-changelog.sh server "$TAG" "$PREV_TAG" > /tmp/changelog.txt + cat /tmp/changelog.txt + - name: Prepare Docker build context run: | VERSION="${{ steps.version.outputs.version }}" @@ -76,5 +95,5 @@ jobs: build/server/*_checksums.txt \ $FLAGS \ --title="$TAG" \ - --notes="Please see the [CHANGELOG](https://github.com/dnote/dnote/blob/master/CHANGELOG.md)" \ + --notes-file=/tmp/changelog.txt \ --draft diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 431232b6..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,300 +0,0 @@ -# CHANAGELOG - -All notable changes to the projects under this repository will be documented in this file. - -* [Server](#server) -* [CLI](#cli) - -## Server - -The following log documents the history of the server project. - -### Unreleased - -### 3.0.0-rc1 2025-10-05 - -- Use SQLite instead of Postgres. Please use https://github.com/dnote/pg2sqlite to migrate. - -### 2.1.1 2023-03-04 - -#### Fixed - -- Added the missing CSS and JS in the server release - -### 2.1.0 2023-03-04 - -#### Changed - -- `OnPremise` environment variable is deprecated and is replaced with `OnPremises` -- Upgrade Go from 1.17 to 1.20. - -### 2.0.0 2022-05-09 - -#### Removed - -- The web interface for managing notes and books (#594) - -### 1.0.4 2020-05-23 - -#### Removed - -- Simplify the bundle by removing unnecessary payment logic - -#### Fixed - -- Fix timestamp in the note content view -- Invalidate existing sessions when password is changed - -### 1.0.3 2020-05-03 - -#### Fixed - -- Fix timeline grouping notes by added time rather than updated time. - -#### Changed - -- Sort notes by last activity to make it easier to see the most recently accessed information. - -### 1.0.2 2020-05-03 - -#### Changed - -* Support arm64. - -### 1.0.1 - 2020-03-29 - -- Fix fresh install running migrations against tables that no longer exists. - -### 1.0.0 - 2020-03-22 - -#### Fixed - -- Fix unsubscribe link from the inactive reminder (#433) - -#### Removed - -- Remove the deprecated features related to digests and repetition rules (#432) -- Remove the migration for the deprecated, encrypted Dnote (#433) - -#### Changed - -- Please set `OnPremise` environment to `true` in order to automatically use the Pro version. - -### 0.5.0 - 2020-02-06 - -#### Changed - -- **Deprecated** the digest and digest emails (#397) -- **Deprecated** the repetition rules (#397) - -#### Fixed - -- Fix refocusing to the end of the textarea input (#405) - -### 0.4.0 - 2020-01-09 - -#### Added - -- A web-based digest (#380) - -#### Fixed - -- Send inactive reminders with a correct email type (#385) -- Wrap words in note content (#389) - -### 0.3.4 - 2019-12-24 - -#### Added - -- Remind when the knowledge base stops growing (#375) -- Alert when a password is changed (#375) - -#### Fixed - -- Implement syntax highlighting for code blocks ($377) - -### 0.3.3 - 2019-12-17 - -#### Added - -- Send welcome email with login instructions upon reigstering (#352) -- Add an option to disable registration (#365) - -#### Changed - -- Send emails from the domain that hosts the application for on premise installations (#355) -- For on premise installations, automatically upgrade user accounts (#361) - -### 0.3.2 - 2019-11-20 - -#### Fixed - -- Fix server crash upon landing on a note page (#324). -- Allow to synchronize a large number of records (#321) - -### 0.3.1 - 2019-11-12 - -#### Fixed - -- Fix static files not being embedded in the binary. (#309) -- Fix mobile menu not covering the whole screen. (#308) - -### 0.3.0 - 2019-11-12 - -#### Added - -- Share notes (#300) -- Allow to recover from a missed repetition processing (#305) - -### 0.2.1 - 2019-11-04 - -#### Upgrade Guide - -* Please define the follwoing new environment variables: - - - `WebURL`: the URL to your Dnote server, without the trailing slash. (e.g. `https://my-server.com`) (Please see #290) - - `SmtpPort`: the SMTP port. (e.g. `465`) optional - required *if you want to configure email* - -#### Added - -- Display version number in the settings (#293) -- Allow unsecure database connection in production (#276) - -#### Fixed - -- Allow to customize the app URL in the emails (#290) -- Allow to customize the SMTP port (#292) - -### 0.2.0 - 2019-10-28 - -#### Added - -- Specify spaced repetition rule (#280) - -#### Changed - -- Treat a linebreak as a new line in the preview (#261) -- Allow to have multiple editor states for adding and editing notes (#260) - -#### Fixed - -- Fix jumping focus on editor (#265) - -### 0.1.1 - 2019-09-30 - -#### Fixed - -- Fix asset loading (#257) - - -### 0.1.0 - 2019-09-30 - -#### Added - -- Full-text search (#254) -- Password recovery (#254) -- Embedded notes in the digest emails (#254) - -#### Removed - -- **Breaking Change**: End-to-end encryption was removed. Existing users need to go to `/classic` and follow the automated migration steps. (#254) -- **Breaking Change**: `v1` and `v2` API endpoints were removed, and `v3` API was added as a replacement. - -#### Migration guide - -- In your application, navigate to `/classic` and follow the automated migration steps. - - -## CLI - -The following log documentes the history of the CLI project - -### Unreleased - -None - -### 0.15.2 - 2025-10-05 - -* Support for 32bit linux, freebsd amd64, mac arm64. -* Remove Pro. - -### 0.15.1 - 2024-02-03 - -* Upgrade `color` dependency (#660). -* Use Go 1.21 (#658). - -### 0.15.0 - 2023-05-27 - -* Add `enableUpgradeCheck` configuration to allow to opt out of automatic update check. - -### 0.14.0 - 2023-03-10 - -* Remove `autocomplete` subcommand that was accidentally added by a dependency (#637) - -### 0.13.0 - 2023-02-10 - -* Allow to add note from stdin. - -``` -echo "test" | dnote add mybook - -dnote add mybook << EOF -test line 1 -test line 2 -EOF -``` - -### 0.12.0 - 2020-01-03 - -#### Upgrade guide - -* **On Linux or macOS** Please move your Dnote files to new directories based on the XDG base directory specfication. **On Windows**, no action is required. - -``` -# Move the database file -mv ~/.dnote/dnote.db ~/.local/share/dnote/dnote.db - -# Move the config file -mv ~/.dnote/dnoterc ~/.config/dnote/dnoterc - -# Delete ~/.dnote. (it is safe to delete DNOTE_TMPCONTENT.md files, if they exist.) -rm -rf ~/.dnote -``` - -If `~/.dnote` directory exists, dnote will continue to use that directory for backward compatibility until the next major release. - -#### Added - -- Add `--content-only` flag to print the note content only (#528) - -#### Changed - -- Use XDG base directory on Linux and macOS (#527) - -### 0.11.1 - 2020-04-25 - -#### Fixed - -- Fix upgrade URL (#453) - -#### Changed - -- Display hostname of the self-hosted instance while logging in (#454) -- Display helpful error if endpoint is misconfigured (#455) - -### 0.11.0 - 2020-02-05 - -#### Added - -- Allow to pass credentials through flags while logging in (#403) - -### 0.10.0 - 2019-09-30 - -#### Removed - -- **Breaking Change**: End-to-end encryption was removed. Previous versions will no longer be able to interact with the web API, because `v1` and `v2` endpoints were replaced by a new `v3` endpoint to remove encryption. - -#### Migration guide - -- If you are using Dnote Pro, change the value of `apiEndpoint` in `~/.dnote/dnoterc` to `https://api.getdnote.com`. - diff --git a/scripts/generate-changelog.sh b/scripts/generate-changelog.sh new file mode 100755 index 00000000..8f24a8ec --- /dev/null +++ b/scripts/generate-changelog.sh @@ -0,0 +1,62 @@ +#!/bin/bash +set -e + +# Usage: ./generate-changelog.sh +# Example: ./generate-changelog.sh cli cli-v0.15.2 cli-v0.15.1 + +COMPONENT=$1 +CURRENT_TAG=$2 +PREV_TAG=$3 + +if [ -z "$COMPONENT" ] || [ -z "$CURRENT_TAG" ]; then + echo "Usage: $0 [previous-tag]" + echo "Example: $0 cli cli-v0.15.2 cli-v0.15.1" + exit 1 +fi + +# Validate that tags match the component +if [[ ! "$CURRENT_TAG" =~ ^${COMPONENT}- ]]; then + echo "Error: Current tag '$CURRENT_TAG' doesn't match component '$COMPONENT'" + echo "Expected tag to start with '${COMPONENT}-'" + exit 1 +fi + +if [ -n "$PREV_TAG" ] && [[ ! "$PREV_TAG" =~ ^${COMPONENT}- ]]; then + echo "Error: Previous tag '$PREV_TAG' doesn't match component '$COMPONENT'" + echo "Expected tag to start with '${COMPONENT}-'" + exit 1 +fi + +# Define paths for each component +# Shared paths that apply to both components +SHARED_PATHS="pkg/dirs/" + +if [ "$COMPONENT" == "cli" ]; then + FILTER_PATHS="pkg/cli/ cmd/cli/ $SHARED_PATHS" +elif [ "$COMPONENT" == "server" ]; then + FILTER_PATHS="pkg/server/ host/ $SHARED_PATHS" +else + echo "Unknown component: $COMPONENT" + echo "Valid components: cli, server" + exit 1 +fi + +# Determine commit range +if [ -z "$PREV_TAG" ]; then + echo "Error: No previous tag specified" + exit 1 +fi + +RANGE="$PREV_TAG..$CURRENT_TAG" + +# Get all commits that touched the relevant paths +# Warnings go to stderr (visible in logs), commits go to stdout (captured for file) +COMMITS=$( + for path in $FILTER_PATHS; do + git log --oneline --no-merges --pretty=format:"- %s%n" "$RANGE" -- "$path" 2>&2 + done | sort -u | grep -v "^$" +) + +echo "## What's Changed" +echo "" +echo "$COMMITS" From 346bd9afb1c83eb31282c84f65470ae974cbb936 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 12 Oct 2025 15:08:11 -0700 Subject: [PATCH 10/33] Add dbPath flag and update apiEndpoint flag (#692) * Allow to specify CLI db path as a flag * Make API endpoint flag per command and change case --- .github/workflows/release-cli.yml | 19 --------- pkg/cli/cmd/login/login.go | 8 +++- pkg/cli/cmd/logout/logout.go | 10 +++++ pkg/cli/cmd/root/root.go | 10 ++--- pkg/cli/cmd/sync/sync.go | 7 ++++ pkg/cli/infra/init.go | 48 +++++++++++++--------- pkg/cli/infra/init_test.go | 29 ++++--------- pkg/cli/main.go | 12 ++---- pkg/cli/main_test.go | 68 +++++++++++++++++++++++++++++++ pkg/e2e/sync_test.go | 8 ++-- 10 files changed, 141 insertions(+), 78 deletions(-) diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 723c2d1a..81a2ea5e 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -75,22 +75,3 @@ jobs: --title="$TAG" \ --notes-file=/tmp/changelog.txt \ --draft - - - name: Bump Homebrew formula - env: - HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_RELEASE_TOKEN }} - run: | - VERSION="${{ steps.version.outputs.version }}" - TAG="cli-v${VERSION}" - - # Only bump Homebrew for stable releases (not prereleases) - if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - brew update-reset - brew bump-formula-pr \ - --no-browse \ - --tag="$TAG" \ - --revision="${{ github.sha }}" \ - dnote - else - echo "Skipping Homebrew update for prerelease version: $VERSION" - fi diff --git a/pkg/cli/cmd/login/login.go b/pkg/cli/cmd/login/login.go index 1e667382..4d8ee392 100644 --- a/pkg/cli/cmd/login/login.go +++ b/pkg/cli/cmd/login/login.go @@ -37,7 +37,7 @@ import ( var example = ` dnote login` -var usernameFlag, passwordFlag string +var usernameFlag, passwordFlag, apiEndpointFlag string // NewCmd returns a new login command func NewCmd(ctx context.DnoteCtx) *cobra.Command { @@ -51,6 +51,7 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command { f := cmd.Flags() f.StringVarP(&usernameFlag, "username", "u", "", "email address for authentication") f.StringVarP(&passwordFlag, "password", "p", "", "password for authentication") + f.StringVar(&apiEndpointFlag, "apiEndpoint", "", "API endpoint to connect to (defaults to value in config)") return cmd } @@ -147,6 +148,11 @@ func getGreeting(ctx context.DnoteCtx) string { func newRun(ctx context.DnoteCtx) infra.RunEFunc { return func(cmd *cobra.Command, args []string) error { + // Override APIEndpoint if flag was provided + if apiEndpointFlag != "" { + ctx.APIEndpoint = apiEndpointFlag + } + greeting := getGreeting(ctx) log.Plain(greeting) diff --git a/pkg/cli/cmd/logout/logout.go b/pkg/cli/cmd/logout/logout.go index 0137e078..008c9652 100644 --- a/pkg/cli/cmd/logout/logout.go +++ b/pkg/cli/cmd/logout/logout.go @@ -37,6 +37,8 @@ var ErrNotLoggedIn = errors.New("not logged in") var example = ` dnote logout` +var apiEndpointFlag string + // NewCmd returns a new logout command func NewCmd(ctx context.DnoteCtx) *cobra.Command { cmd := &cobra.Command{ @@ -46,6 +48,9 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command { RunE: newRun(ctx), } + f := cmd.Flags() + f.StringVar(&apiEndpointFlag, "apiEndpoint", "", "API endpoint to connect to (defaults to value in config)") + return cmd } @@ -84,6 +89,11 @@ func Do(ctx context.DnoteCtx) error { func newRun(ctx context.DnoteCtx) infra.RunEFunc { return func(cmd *cobra.Command, args []string) error { + // Override APIEndpoint if flag was provided + if apiEndpointFlag != "" { + ctx.APIEndpoint = apiEndpointFlag + } + err := Do(ctx) if err == ErrNotLoggedIn { log.Error("not logged in\n") diff --git a/pkg/cli/cmd/root/root.go b/pkg/cli/cmd/root/root.go index 750629e4..604f7682 100644 --- a/pkg/cli/cmd/root/root.go +++ b/pkg/cli/cmd/root/root.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/cobra" ) -var apiEndpointFlag string +var dbPathFlag string var root = &cobra.Command{ Use: "dnote", @@ -35,7 +35,7 @@ var root = &cobra.Command{ } func init() { - root.PersistentFlags().StringVar(&apiEndpointFlag, "api-endpoint", "", "the API endpoint to connect to (defaults to value in config)") + root.PersistentFlags().StringVar(&dbPathFlag, "dbPath", "", "the path to the database file (defaults to standard location)") } // GetRoot returns the root command @@ -43,9 +43,9 @@ func GetRoot() *cobra.Command { return root } -// GetAPIEndpointFlag returns the value of the --api-endpoint flag -func GetAPIEndpointFlag() string { - return apiEndpointFlag +// GetDBPathFlag returns the value of the --dbPath flag +func GetDBPathFlag() string { + return dbPathFlag } // Register adds a new command diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index ff8e8a5f..a1fea893 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -44,6 +44,7 @@ var example = ` dnote sync` var isFullSync bool +var apiEndpointFlag string // NewCmd returns a new sync command func NewCmd(ctx context.DnoteCtx) *cobra.Command { @@ -57,6 +58,7 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command { f := cmd.Flags() f.BoolVarP(&isFullSync, "full", "f", false, "perform a full sync instead of incrementally syncing only the changed data.") + f.StringVar(&apiEndpointFlag, "apiEndpoint", "", "API endpoint to connect to (defaults to value in config)") return cmd } @@ -931,6 +933,11 @@ func prepareEmptyServerSync(tx *database.DB) error { func newRun(ctx context.DnoteCtx) infra.RunEFunc { return func(cmd *cobra.Command, args []string) error { + // Override APIEndpoint if flag was provided + if apiEndpointFlag != "" { + ctx.APIEndpoint = apiEndpointFlag + } + if ctx.SessionKey == "" { return errors.New("not logged in") } diff --git a/pkg/cli/infra/init.go b/pkg/cli/infra/init.go index 532f1f1e..0d2d767a 100644 --- a/pkg/cli/infra/init.go +++ b/pkg/cli/infra/init.go @@ -42,6 +42,11 @@ import ( "github.com/spf13/cobra" ) +const ( + // DefaultAPIEndpoint is the default API endpoint used when none is configured + DefaultAPIEndpoint = "http://localhost:3001/api" +) + // RunEFunc is a function type of dnote commands type RunEFunc func(*cobra.Command, []string) error @@ -59,7 +64,12 @@ func checkLegacyDBPath() (string, bool) { return "", false } -func getDBPath(paths context.Paths) string { +func getDBPath(paths context.Paths, customPath string) string { + // If custom path is provided, use it + if customPath != "" { + return customPath + } + legacyDnoteDir, ok := checkLegacyDBPath() if ok { return fmt.Sprintf("%s/%s", legacyDnoteDir, consts.DnoteDBFileName) @@ -71,7 +81,7 @@ func getDBPath(paths context.Paths) string { // newBaseCtx creates a minimal context with paths and database connection. // This base context is used for file and database initialization before // being enriched with config values by setupCtx. -func newBaseCtx(versionTag string) (context.DnoteCtx, error) { +func newBaseCtx(versionTag, customDBPath string) (context.DnoteCtx, error) { dnoteDir := getLegacyDnotePath(dirs.Home) paths := context.Paths{ Home: dirs.Home, @@ -81,7 +91,7 @@ func newBaseCtx(versionTag string) (context.DnoteCtx, error) { LegacyDnote: dnoteDir, } - dbPath := getDBPath(paths) + dbPath := getDBPath(paths, customDBPath) db, err := database.Open(dbPath) if err != nil { @@ -98,13 +108,14 @@ func newBaseCtx(versionTag string) (context.DnoteCtx, error) { } // Init initializes the Dnote environment and returns a new dnote context -func Init(versionTag, apiEndpoint string) (*context.DnoteCtx, error) { - ctx, err := newBaseCtx(versionTag) +// apiEndpoint is used when creating a new config file (e.g., from ldflags during tests) +func Init(versionTag, apiEndpoint, dbPath string) (*context.DnoteCtx, error) { + ctx, err := newBaseCtx(versionTag, dbPath) if err != nil { return nil, errors.Wrap(err, "initializing a context") } - if err := InitFiles(ctx, apiEndpoint); err != nil { + if err := initFiles(ctx, apiEndpoint); err != nil { return nil, errors.Wrap(err, "initializing files") } @@ -122,7 +133,7 @@ func Init(versionTag, apiEndpoint string) (*context.DnoteCtx, error) { return nil, errors.Wrap(err, "running migration") } - ctx, err = setupCtx(ctx, apiEndpoint) + ctx, err = setupCtx(ctx) if err != nil { return nil, errors.Wrap(err, "setting up the context") } @@ -134,8 +145,7 @@ func Init(versionTag, apiEndpoint string) (*context.DnoteCtx, error) { // setupCtx enriches the base context with values from config file and database. // This is called after files and database have been initialized. -// If apiEndpoint is provided, it overrides the value from config. -func setupCtx(ctx context.DnoteCtx, apiEndpoint string) (context.DnoteCtx, error) { +func setupCtx(ctx context.DnoteCtx) (context.DnoteCtx, error) { db := ctx.DB var sessionKey string @@ -155,19 +165,13 @@ func setupCtx(ctx context.DnoteCtx, apiEndpoint string) (context.DnoteCtx, error return ctx, errors.Wrap(err, "reading config") } - // Use override if provided, otherwise use config value - endpoint := cf.APIEndpoint - if apiEndpoint != "" { - endpoint = apiEndpoint - } - ret := context.DnoteCtx{ Paths: ctx.Paths, Version: ctx.Version, DB: ctx.DB, SessionKey: sessionKey, SessionKeyExpiry: sessionKeyExpiry, - APIEndpoint: endpoint, + APIEndpoint: cf.APIEndpoint, Editor: cf.Editor, Clock: clock.New(), EnableUpgradeCheck: cf.EnableUpgradeCheck, @@ -367,9 +371,15 @@ func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error { editor := getEditorCommand() + // Use default API endpoint if none provided + endpoint := apiEndpoint + if endpoint == "" { + endpoint = DefaultAPIEndpoint + } + cf := config.Config{ Editor: editor, - APIEndpoint: apiEndpoint, + APIEndpoint: endpoint, EnableUpgradeCheck: true, } @@ -380,8 +390,8 @@ func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error { return nil } -// InitFiles creates, if necessary, the dnote directory and files inside -func InitFiles(ctx context.DnoteCtx, apiEndpoint string) error { +// initFiles creates, if necessary, the dnote directory and files inside +func initFiles(ctx context.DnoteCtx, apiEndpoint string) error { if err := initDnoteDir(ctx); err != nil { return errors.Wrap(err, "creating the dnote dir") } diff --git a/pkg/cli/infra/init_test.go b/pkg/cli/infra/init_test.go index cb50a95f..5fff1c93 100644 --- a/pkg/cli/infra/init_test.go +++ b/pkg/cli/infra/init_test.go @@ -95,7 +95,7 @@ func TestInitSystemKV_existing(t *testing.T) { assert.Equal(t, val, "testVal", "system value should not have been updated") } -func TestInit_APIEndpointChange(t *testing.T) { +func TestInit_APIEndpoint(t *testing.T) { // Create a temporary directory for test tmpDir, err := os.MkdirTemp("", "dnote-init-test-*") if err != nil { @@ -108,35 +108,20 @@ func TestInit_APIEndpointChange(t *testing.T) { t.Setenv("XDG_DATA_HOME", fmt.Sprintf("%s/data", tmpDir)) t.Setenv("XDG_CACHE_HOME", fmt.Sprintf("%s/cache", tmpDir)) - // First init. - endpoint1 := "http://127.0.0.1:3001" - ctx, err := Init("test-version", endpoint1) + // Initialize - should create config with default apiEndpoint + ctx, err := Init("test-version", "", "") if err != nil { t.Fatal(errors.Wrap(err, "initializing")) } defer ctx.DB.Close() - assert.Equal(t, ctx.APIEndpoint, endpoint1, "should use endpoint1 API endpoint") - // Test that config was written with endpoint1. + // Read the config that was created cf, err := config.Read(*ctx) if err != nil { t.Fatal(errors.Wrap(err, "reading config")) } - // Second init with different endpoint. - endpoint2 := "http://127.0.0.1:3002" - ctx2, err := Init("test-version", endpoint2) - if err != nil { - t.Fatal(errors.Wrap(err, "initializing with override")) - } - defer ctx2.DB.Close() - // Context must be using that endpoint. - assert.Equal(t, ctx2.APIEndpoint, endpoint2, "should use endpoint2 API endpoint") - - // The config file shouldn't have been modified. - cf2, err := config.Read(*ctx2) - if err != nil { - t.Fatal(errors.Wrap(err, "reading config after override")) - } - assert.Equal(t, cf2.APIEndpoint, cf.APIEndpoint, "config should still have original endpoint, not endpoint2") + // Context should use the apiEndpoint from config + assert.Equal(t, ctx.APIEndpoint, DefaultAPIEndpoint, "context should use apiEndpoint from config") + assert.Equal(t, cf.APIEndpoint, DefaultAPIEndpoint, "context should use apiEndpoint from config") } diff --git a/pkg/cli/main.go b/pkg/cli/main.go index 31c81dd5..1ba97358 100644 --- a/pkg/cli/main.go +++ b/pkg/cli/main.go @@ -46,16 +46,12 @@ var apiEndpoint string var versionTag = "master" func main() { - // Parse flags early to check if --api-endpoint was provided + // Parse flags early to get --dbPath before initializing database root.GetRoot().ParseFlags(os.Args[1:]) + dbPath := root.GetDBPathFlag() - // Use flag value if provided, otherwise use ldflags value - endpoint := apiEndpoint - if flagValue := root.GetAPIEndpointFlag(); flagValue != "" { - endpoint = flagValue - } - - ctx, err := infra.Init(versionTag, endpoint) + // Initialize context - defaultAPIEndpoint is used when creating new config file + ctx, err := infra.Init(versionTag, apiEndpoint, dbPath) if err != nil { panic(errors.Wrap(err, "initializing context")) } diff --git a/pkg/cli/main_test.go b/pkg/cli/main_test.go index 151d4cbf..63a95d87 100644 --- a/pkg/cli/main_test.go +++ b/pkg/cli/main_test.go @@ -501,3 +501,71 @@ func TestRemoveBook(t *testing.T) { }) } } + +func TestDBPathFlag(t *testing.T) { + // Helper function to verify database contents + verifyDatabase := func(t *testing.T, dbPath, expectedBook, expectedNote string) *database.DB { + ok, err := utils.FileExists(dbPath) + if err != nil { + t.Fatal(errors.Wrapf(err, "checking if custom db exists at %s", dbPath)) + } + if !ok { + t.Errorf("custom database was not created at %s", dbPath) + } + + db, err := database.Open(dbPath) + if err != nil { + t.Fatal(errors.Wrapf(err, "opening db at %s", dbPath)) + } + + var noteCount, bookCount int + database.MustScan(t, "counting books", db.QueryRow("SELECT count(*) FROM books"), &bookCount) + database.MustScan(t, "counting notes", db.QueryRow("SELECT count(*) FROM notes"), ¬eCount) + + assert.Equalf(t, bookCount, 1, fmt.Sprintf("%s book count mismatch", dbPath)) + assert.Equalf(t, noteCount, 1, fmt.Sprintf("%s note count mismatch", dbPath)) + + var book database.Book + database.MustScan(t, "getting book", db.QueryRow("SELECT label FROM books"), &book.Label) + assert.Equalf(t, book.Label, expectedBook, fmt.Sprintf("%s book label mismatch", dbPath)) + + var note database.Note + database.MustScan(t, "getting note", db.QueryRow("SELECT body FROM notes"), ¬e.Body) + assert.Equalf(t, note.Body, expectedNote, fmt.Sprintf("%s note body mismatch", dbPath)) + + return db + } + + // Setup - use two different custom database paths + customDBPath1 := "./tmp/custom-test1.db" + customDBPath2 := "./tmp/custom-test2.db" + defer testutils.RemoveDir(t, "./tmp") + + customOpts := testutils.RunDnoteCmdOptions{ + Env: []string{ + fmt.Sprintf("XDG_CONFIG_HOME=%s", testDir), + fmt.Sprintf("XDG_DATA_HOME=%s", testDir), + fmt.Sprintf("XDG_CACHE_HOME=%s", testDir), + }, + } + + // Execute - add different notes to each database + testutils.RunDnoteCmd(t, customOpts, binaryName, "--dbPath", customDBPath1, "add", "db1-book", "-c", "content in db1") + testutils.RunDnoteCmd(t, customOpts, binaryName, "--dbPath", customDBPath2, "add", "db2-book", "-c", "content in db2") + + // Test both databases + db1 := verifyDatabase(t, customDBPath1, "db1-book", "content in db1") + defer db1.Close() + + db2 := verifyDatabase(t, customDBPath2, "db2-book", "content in db2") + defer db2.Close() + + // Verify that the databases are independent + var db1HasDB2Book int + db1.QueryRow("SELECT count(*) FROM books WHERE label = ?", "db2-book").Scan(&db1HasDB2Book) + assert.Equal(t, db1HasDB2Book, 0, "db1 should not have db2's book") + + var db2HasDB1Book int + db2.QueryRow("SELECT count(*) FROM books WHERE label = ?", "db1-book").Scan(&db2HasDB1Book) + assert.Equal(t, db2HasDB1Book, 0, "db2 should not have db1's book") +} diff --git a/pkg/e2e/sync_test.go b/pkg/e2e/sync_test.go index b4fec91f..40fe976c 100644 --- a/pkg/e2e/sync_test.go +++ b/pkg/e2e/sync_test.go @@ -4254,7 +4254,7 @@ func TestSync_EmptyServer(t *testing.T) { clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--api-endpoint", apiEndpointA, "sync") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) // Verify sync to Server A succeeded checkStateWithDB(t, ctx, userA, serverDbA, systemState{ @@ -4278,7 +4278,7 @@ func TestSync_EmptyServer(t *testing.T) { cliDatabase.MustExec(t, "updating session_key_expiry for B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) // Should detect empty server and prompt - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "--api-endpoint", apiEndpointB, "sync") + clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) // Verify Server B now has data checkStateWithDB(t, ctx, userB, serverDbB, systemState{ @@ -4296,7 +4296,7 @@ func TestSync_EmptyServer(t *testing.T) { cliDatabase.MustExec(t, "updating session_key_expiry back to A", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) // Should NOT trigger empty server detection (Server A has MaxUSN > 0) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--api-endpoint", apiEndpointA, "sync") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) // Verify Server A still has its data checkStateWithDB(t, ctx, userA, serverDbA, systemState{ @@ -4314,7 +4314,7 @@ func TestSync_EmptyServer(t *testing.T) { cliDatabase.MustExec(t, "updating session_key_expiry back to B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) // Should NOT trigger empty server detection (Server B now has MaxUSN > 0 from Step 2) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--api-endpoint", apiEndpointB, "sync") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) // Verify both servers maintain independent state checkStateWithDB(t, ctx, userB, serverDbB, systemState{ From c8238aa327aa16a9a05f9113da6e0a64d4939f25 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 12 Oct 2025 16:17:01 -0700 Subject: [PATCH 11/33] Handle errors (#693) --- pkg/cli/cmd/sync/sync.go | 4 +++- pkg/cli/infra/init.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index a1fea893..1db3848e 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -1060,7 +1060,9 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc { } } - tx.Commit() + if err := tx.Commit(); err != nil { + return errors.Wrap(err, "committing transaction") + } log.Success("success\n") diff --git a/pkg/cli/infra/init.go b/pkg/cli/infra/init.go index 0d2d767a..4bbaae6e 100644 --- a/pkg/cli/infra/init.go +++ b/pkg/cli/infra/init.go @@ -291,7 +291,9 @@ func InitSystem(ctx context.DnoteCtx) error { return errors.Wrapf(err, "initializing system config for %s", consts.SystemLastSyncAt) } - tx.Commit() + if err := tx.Commit(); err != nil { + return errors.Wrap(err, "committing transaction") + } return nil } From 03889a3d7e1a72ca5d65b6272cac58c22ae422d6 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 18 Oct 2025 16:03:12 -0700 Subject: [PATCH 12/33] Converge if using same book names while syncing (#694) * Add healthcheck for Docker * Prevent nil pointer if endpoint is wrong * Converge if using same book names while syncing --- host/docker/Dockerfile | 3 + pkg/cli/client/client.go | 10 +- pkg/cli/client/client_test.go | 12 +++ pkg/cli/cmd/sync/sync.go | 2 +- pkg/cli/infra/init_test.go | 4 + pkg/cli/testutils/main.go | 9 ++ pkg/e2e/sync_test.go | 181 +++++++++++++++++++++++++++------- 7 files changed, 182 insertions(+), 39 deletions(-) diff --git a/host/docker/Dockerfile b/host/docker/Dockerfile index cd93f6ca..88681591 100644 --- a/host/docker/Dockerfile +++ b/host/docker/Dockerfile @@ -14,3 +14,6 @@ ENTRYPOINT ["./entrypoint.sh"] CMD ./dnote-server start EXPOSE 3001 + +HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \ + CMD wget --no-verbose --tries=1 -O /dev/null http://localhost:3001/health || exit 1 diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index 021afe7d..86df4374 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -579,10 +579,12 @@ func Signin(ctx context.DnoteCtx, email, password string) (SigninResponse, error return SigninResponse{}, errors.Wrap(err, "marshaling payload") } res, err := doReq(ctx, "POST", "/v3/signin", string(b), nil) - - if res.StatusCode == http.StatusUnauthorized { - return SigninResponse{}, ErrInvalidLogin - } else if err != nil { + if err != nil { + // Check if this is a 401 Unauthorized error + var httpErr *HTTPError + if errors.As(err, &httpErr) && httpErr.StatusCode == http.StatusUnauthorized { + return SigninResponse{}, ErrInvalidLogin + } return SigninResponse{}, errors.Wrap(err, "making http request") } diff --git a/pkg/cli/client/client_test.go b/pkg/cli/client/client_test.go index 31b6d6c8..3bb99e93 100644 --- a/pkg/cli/client/client_test.go +++ b/pkg/cli/client/client_test.go @@ -124,6 +124,18 @@ func TestSignIn(t *testing.T) { assert.Equal(t, result.Key, "", "Key mismatch") assert.Equal(t, result.ExpiresAt, int64(0), "ExpiresAt mismatch") }) + + t.Run("network error", func(t *testing.T) { + // Use an invalid endpoint that will fail to connect + endpoint := "http://localhost:99999/api" + result, err := Signin(context.DnoteCtx{APIEndpoint: endpoint, HTTPClient: testClient}, "alice@example.com", "pass1234") + + if err == nil { + t.Error("error should have been returned for network failure") + } + assert.Equal(t, result.Key, "", "Key mismatch") + assert.Equal(t, result.ExpiresAt, int64(0), "ExpiresAt mismatch") + }) } func TestSignOut(t *testing.T) { diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index 1db3848e..28ec71a7 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -222,7 +222,7 @@ func mergeBook(tx *database.DB, b client.SyncFragBook, mode int) error { return errors.Wrap(err, "getting a new book label for conflict resolution") } - if _, err := tx.Exec("UPDATE books SET label = ?, dirty = ? WHERE label = ?", newLabel, true, b.Label); err != nil { + if _, err := tx.Exec("UPDATE books SET label = ?, dirty = ? WHERE label = ? AND uuid != ?", newLabel, true, b.Label, b.UUID); err != nil { return errors.Wrap(err, "resolving duplicate book label") } } diff --git a/pkg/cli/infra/init_test.go b/pkg/cli/infra/init_test.go index 5fff1c93..546baab0 100644 --- a/pkg/cli/infra/init_test.go +++ b/pkg/cli/infra/init_test.go @@ -26,6 +26,7 @@ import ( "github.com/dnote/dnote/pkg/assert" "github.com/dnote/dnote/pkg/cli/config" "github.com/dnote/dnote/pkg/cli/database" + "github.com/dnote/dnote/pkg/dirs" "github.com/pkg/errors" ) @@ -108,6 +109,9 @@ func TestInit_APIEndpoint(t *testing.T) { t.Setenv("XDG_DATA_HOME", fmt.Sprintf("%s/data", tmpDir)) t.Setenv("XDG_CACHE_HOME", fmt.Sprintf("%s/cache", tmpDir)) + // Force dirs package to reload with new environment + dirs.Reload() + // Initialize - should create config with default apiEndpoint ctx, err := Init("test-version", "", "") if err != nil { diff --git a/pkg/cli/testutils/main.go b/pkg/cli/testutils/main.go index 9b4e945d..ee853b48 100644 --- a/pkg/cli/testutils/main.go +++ b/pkg/cli/testutils/main.go @@ -368,3 +368,12 @@ func MustGenerateUUID(t *testing.T) string { return ret } + +func MustOpenDatabase(t *testing.T, dbPath string) *database.DB { + db, err := database.Open(dbPath) + if err != nil { + t.Fatal(errors.Wrap(err, "opening database")) + } + + return db +} diff --git a/pkg/e2e/sync_test.go b/pkg/e2e/sync_test.go index 40fe976c..c2a1c4ee 100644 --- a/pkg/e2e/sync_test.go +++ b/pkg/e2e/sync_test.go @@ -36,6 +36,7 @@ import ( "github.com/dnote/dnote/pkg/cli/consts" "github.com/dnote/dnote/pkg/cli/context" cliDatabase "github.com/dnote/dnote/pkg/cli/database" + "github.com/dnote/dnote/pkg/cli/testutils" clitest "github.com/dnote/dnote/pkg/cli/testutils" "github.com/dnote/dnote/pkg/clock" "github.com/dnote/dnote/pkg/server/app" @@ -134,18 +135,28 @@ func TestMain(m *testing.M) { } // helpers -func setupUser(t *testing.T, ctx *context.DnoteCtx) database.User { +func setupUser(t *testing.T, db *cliDatabase.DB) database.User { user := apitest.SetupUserData(serverDb) apitest.SetupAccountData(serverDb, user, "alice@example.com", "pass1234") - // log in the user in CLI - session := apitest.SetupSession(serverDb, user) - cliDatabase.MustExec(t, "inserting session_key", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, session.Key) - cliDatabase.MustExec(t, "inserting session_key_expiry", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, session.ExpiresAt.Unix()) + return user +} + +func setupUserAndLogin(t *testing.T, db *cliDatabase.DB) database.User { + user := setupUser(t, db) + login(t, db, user) return user } +// log in the user in CLI +func login(t *testing.T, db *cliDatabase.DB, user database.User) { + session := apitest.SetupSession(serverDb, user) + + cliDatabase.MustExec(t, "inserting session_key", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, session.Key) + cliDatabase.MustExec(t, "inserting session_key_expiry", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, session.ExpiresAt.Unix()) +} + func apiCreateBook(t *testing.T, user database.User, name, message string) string { res := doHTTPReq(t, "POST", "/v3/books", fmt.Sprintf(`{"name": "%s"}`, name), message, user) @@ -221,7 +232,7 @@ func testSyncCmd(t *testing.T, fullSync bool, setup setupFunc, assert assertFunc ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) ids := setup(t, ctx, user) if fullSync { @@ -245,12 +256,10 @@ type systemState struct { // checkState compares the state of the client and the server with the given system state func checkState(t *testing.T, ctx context.DnoteCtx, user database.User, expected systemState) { - checkStateWithDB(t, ctx, user, serverDb, expected) + checkStateWithDB(t, ctx.DB, user, serverDb, expected) } -func checkStateWithDB(t *testing.T, ctx context.DnoteCtx, user database.User, db *gorm.DB, expected systemState) { - clientDB := ctx.DB - +func checkStateWithDB(t *testing.T, clientDB *cliDatabase.DB, user database.User, serverDB *gorm.DB, expected systemState) { var clientBookCount, clientNoteCount int cliDatabase.MustScan(t, "counting client notes", clientDB.QueryRow("SELECT count(*) FROM notes"), &clientNoteCount) cliDatabase.MustScan(t, "counting client books", clientDB.QueryRow("SELECT count(*) FROM books"), &clientBookCount) @@ -265,12 +274,12 @@ func checkStateWithDB(t *testing.T, ctx context.DnoteCtx, user database.User, db assert.Equal(t, clientLastSyncAt, expected.clientLastSyncAt, "client last_sync_at mismatch") var serverBookCount, serverNoteCount int64 - apitest.MustExec(t, db.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") - apitest.MustExec(t, db.Model(&database.Book{}).Count(&serverBookCount), "counting api notes") + apitest.MustExec(t, serverDB.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") + apitest.MustExec(t, serverDB.Model(&database.Book{}).Count(&serverBookCount), "counting api notes") assert.Equal(t, serverNoteCount, expected.serverNoteCount, "server note count mismatch") assert.Equal(t, serverBookCount, expected.serverBookCount, "server book count mismatch") var serverUser database.User - apitest.MustExec(t, db.Where("id = ?", user.ID).First(&serverUser), "finding user") + apitest.MustExec(t, serverDB.Where("id = ?", user.ID).First(&serverUser), "finding user") assert.Equal(t, serverUser.MaxUSN, expected.serverUserMaxUSN, "user max_usn mismatch") } @@ -387,7 +396,7 @@ func TestSync_oneway(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) setup(t, ctx, user) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") @@ -401,7 +410,7 @@ func TestSync_oneway(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) setup(t, ctx, user) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") @@ -543,7 +552,7 @@ func TestSync_oneway(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) setup(t, ctx, user) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") @@ -557,7 +566,7 @@ func TestSync_oneway(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) setup(t, ctx, user) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") @@ -3849,7 +3858,7 @@ func TestFullSync(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) ids := setup(t, ctx, user) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") @@ -3867,7 +3876,7 @@ func TestFullSync(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) ids := setup(t, ctx, user) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") @@ -3892,7 +3901,7 @@ func TestSync_EmptyServer(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) // Step 1: Create local data and sync to server clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") @@ -3913,7 +3922,7 @@ func TestSync_EmptyServer(t *testing.T) { // Step 2: Clear all server data to simulate switching to a completely new empty server apitest.ClearData(serverDb) // Recreate user and session (simulating a new server) - user = setupUser(t, &ctx) + user = setupUserAndLogin(t, ctx.DB) // Step 3: Sync again - should detect empty server and prompt user // User confirms with "y" @@ -3967,7 +3976,7 @@ func TestSync_EmptyServer(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) // Step 1: Create local data and sync to server clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") @@ -3987,7 +3996,7 @@ func TestSync_EmptyServer(t *testing.T) { // Step 2: Clear all server data apitest.ClearData(serverDb) - user = setupUser(t, &ctx) + user = setupUserAndLogin(t, ctx.DB) // Step 3: Sync again but user cancels with "n" output, err := clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserCancelEmptyServerSync, cliBinaryName, "sync") @@ -4036,7 +4045,7 @@ func TestSync_EmptyServer(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) // Step 1: Create local data and sync to server clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") @@ -4060,7 +4069,7 @@ func TestSync_EmptyServer(t *testing.T) { // Step 3: Clear server data to simulate switching to empty server apitest.ClearData(serverDb) - user = setupUser(t, &ctx) + user = setupUserAndLogin(t, ctx.DB) // Step 4: Sync - should NOT prompt because bookCount=0 and noteCount=0 (counting only deleted=0) // This should complete without user interaction @@ -4113,7 +4122,7 @@ func TestSync_EmptyServer(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) // Step 1: Create local data and sync to establish lastMaxUSN > 0 clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") @@ -4133,7 +4142,7 @@ func TestSync_EmptyServer(t *testing.T) { // Step 2: Clear server to simulate switching to empty server apitest.ClearData(serverDb) - user = setupUser(t, &ctx) + user = setupUserAndLogin(t, ctx.DB) // Step 3: Trigger sync which will detect empty server and prompt user // Inside the callback (before confirming), we simulate Client B uploading via API. @@ -4169,7 +4178,7 @@ func TestSync_EmptyServer(t *testing.T) { clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, raceCallback, cliBinaryName, "sync") // Verify final state - both clients' data preserved - checkStateWithDB(t, ctx, user, serverDb, systemState{ + checkStateWithDB(t, ctx.DB, user, serverDb, systemState{ clientNoteCount: 4, // Both clients' notes clientBookCount: 4, // js, css, js_2, css_2 clientLastMaxUSN: 8, // 4 from Client B + 4 from Client A's renamed books/notes @@ -4257,7 +4266,7 @@ func TestSync_EmptyServer(t *testing.T) { clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) // Verify sync to Server A succeeded - checkStateWithDB(t, ctx, userA, serverDbA, systemState{ + checkStateWithDB(t, ctx.DB, userA, serverDbA, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4281,7 +4290,7 @@ func TestSync_EmptyServer(t *testing.T) { clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) // Verify Server B now has data - checkStateWithDB(t, ctx, userB, serverDbB, systemState{ + checkStateWithDB(t, ctx.DB, userB, serverDbB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4299,7 +4308,7 @@ func TestSync_EmptyServer(t *testing.T) { clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) // Verify Server A still has its data - checkStateWithDB(t, ctx, userA, serverDbA, systemState{ + checkStateWithDB(t, ctx.DB, userA, serverDbA, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4317,7 +4326,7 @@ func TestSync_EmptyServer(t *testing.T) { clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) // Verify both servers maintain independent state - checkStateWithDB(t, ctx, userB, serverDbB, systemState{ + checkStateWithDB(t, ctx.DB, userB, serverDbB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4349,7 +4358,7 @@ func TestSync_FreshClientConcurrent(t *testing.T) { ctx := context.InitTestCtx(t, paths, nil) defer context.TeardownTestCtx(t, ctx) - user := setupUser(t, &ctx) + user := setupUserAndLogin(t, ctx.DB) // Client A: Create local data (never sync) clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") @@ -4367,7 +4376,7 @@ func TestSync_FreshClientConcurrent(t *testing.T) { // Verify: Should have 4 books and 4 notes on both client and server // USN breakdown: 2 books + 2 notes from Client B (USN 1-4), then 2 books + 2 notes from Client A (USN 5-8) - checkStateWithDB(t, ctx, user, serverDb, systemState{ + checkStateWithDB(t, ctx.DB, user, serverDb, systemState{ clientNoteCount: 4, clientBookCount: 4, clientLastMaxUSN: 8, @@ -4439,3 +4448,107 @@ func TestSync_FreshClientConcurrent(t *testing.T) { assert.NotEqual(t, cliNoteCSS1.USN, 0, "client note 'css1' should have non-zero USN") assert.NotEqual(t, cliNoteCSS2.USN, 0, "client note 'css2' should have non-zero USN") } + +// TestSync_ConvergeSameBookNames tests that two clients don't enter an infinite sync loop if they +// try to sync books with the same names. Books shouldn't get marked dirty when re-downloaded from server. +func TestSync_ConvergeSameBookNames(t *testing.T) { + // Clean up and prepare server + apitest.ClearData(serverDb) + defer apitest.ClearData(serverDb) + + clearTmp(t) + + ctx := context.InitTestCtx(t, paths, nil) + defer context.TeardownTestCtx(t, ctx) + + // Setup two separate client databases + client1DB := fmt.Sprintf("%s/client1.db", tmpDirPath) + client2DB := fmt.Sprintf("%s/client2.db", tmpDirPath) + defer os.Remove(client1DB) + defer os.Remove(client2DB) + + // Set up sessions + user := setupUser(t, ctx.DB) + db1 := testutils.MustOpenDatabase(t, client1DB) + db2 := testutils.MustOpenDatabase(t, client2DB) + defer db1.Close() + defer db2.Close() + + // Client 1: First sync to empty server + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "add", "testbook", "-c", "client1 note1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "add", "anotherbook", "-c", "client1 note2") + login(t, db1, user) + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") + checkStateWithDB(t, db1, user, serverDb, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Client 2: Sync (downloads client 1's data, adds own notes) ===== + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "add", "testbook", "-c", "client2 note1") + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "add", "anotherbook", "-c", "client2 note2") + login(t, db2, user) + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "sync") + // Verify state after client2 sync + checkStateWithDB(t, db2, user, serverDb, systemState{ + clientNoteCount: 4, + clientBookCount: 2, + clientLastMaxUSN: 8, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 2, + serverUserMaxUSN: 8, + }) + + // Client 1: Sync again. It downloads client2's changes (2 extra notes). + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") + + // Verify MaxUSN did not increase (client1 should only download, not upload) + // Client1 still has: 2 original books + 4 notes (2 own + 2 from client2) + checkStateWithDB(t, db1, user, serverDb, systemState{ + clientNoteCount: 4, + clientBookCount: 2, + clientLastMaxUSN: 8, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 2, + serverUserMaxUSN: 8, + }) + + // Verify no infinite loop: alternate syncing + // Both clients should be able to sync without any changes (MaxUSN stays at 8) + for range 3 { + // Client 2 syncs + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "sync") + + // Verify client2 state unchanged + checkStateWithDB(t, db2, user, serverDb, systemState{ + clientNoteCount: 4, + clientBookCount: 2, + clientLastMaxUSN: 8, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 2, + serverUserMaxUSN: 8, + }) + + // Client 1 syncs + clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") + + // Verify client1 state unchanged + checkStateWithDB(t, db1, user, serverDb, systemState{ + clientNoteCount: 4, + clientBookCount: 2, + clientLastMaxUSN: 8, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 2, + serverUserMaxUSN: 8, + }) + } +} From 41f25514f0c2c9c21db848315fbf1aae956fc03d Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 01:01:26 -0700 Subject: [PATCH 13/33] Link to the doc (#695) --- README.md | 4 +- SELF_HOSTING.md | 124 +++++++++--------------------------------- host/docker/README.md | 30 ---------- 3 files changed, 29 insertions(+), 129 deletions(-) delete mode 100644 host/docker/README.md diff --git a/README.md b/README.md index e9469d83..fbe46e26 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ services: restart: unless-stopped ``` -Or see the [guide](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) for binary installation and configuration options. +Or see the [guide](https://www.getdnote.com/docs/server/manual) for binary installation. ## Documentation -See the [Dnote wiki](https://github.com/dnote/dnote/wiki) for full documentation. +See the [Dnote doc](https://www.getdnote.com/docs). diff --git a/SELF_HOSTING.md b/SELF_HOSTING.md index d033b45e..3638cb01 100644 --- a/SELF_HOSTING.md +++ b/SELF_HOSTING.md @@ -1,8 +1,33 @@ # Self-Hosting Dnote Server -For Docker installation, see [the Docker guide](https://github.com/dnote/dnote/blob/master/host/docker/README.md). +Please see the [doc](https://www.getdnote.com/docs/server) for more. -## Quick Start +## Docker Installation + +1. Install [Docker](https://docs.docker.com/install/). +2. Install Docker [Compose plugin](https://docs.docker.com/compose/install/linux/). +3. Download the [compose.yml](https://raw.githubusercontent.com/dnote/dnote/master/host/docker/compose.yml) file by running: + +``` +curl https://raw.githubusercontent.com/dnote/dnote/master/host/docker/compose.yml > compose.yml +``` + +4. Run the following to download the images and run the containers + +``` +docker compose pull +docker compose up -d +``` + +Visit http://localhost:3001 in your browser to see Dnote running. + +### Supported platform + +Currently, the official Docker image for Dnote supports Linux running AMD64 CPU architecture. + +If you run ARM64, please install Dnote server by downloading a binary distribution (see below). + +## Manual Installation Download from [releases](https://github.com/dnote/dnote/releases), extract, and run: @@ -15,98 +40,3 @@ dnote-server start --webUrl=https://your.server You're up and running. Database: `~/.local/share/dnote/server.db` (customize with `--dbPath`). Run `dnote-server start --help` for options. Set `apiEndpoint: https://your.server/api` in `~/.config/dnote/dnoterc` to connect your CLI to the server. - -## Optional guide - -### Nginx - -Create `/etc/nginx/sites-enabled/dnote`: - -``` -server { - server_name my-dnote-server.com; - - location / { - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header Host $host; - proxy_pass http://127.0.0.1:3001; - } -} -``` - -Replace `my-dnote-server.com` with your domain, then reload: - -```bash -sudo service nginx reload -``` - -### Apache2 - -Enable `mod_proxy`, then create `/etc/apache2/sites-available/dnote.conf`: - -``` - - ServerName notes.example.com - - ProxyRequests Off - ProxyPreserveHost On - ProxyPass / http://127.0.0.1:3001/ keepalive=On - ProxyPassReverse / http://127.0.0.1:3001/ - RequestHeader set X-Forwarded-HTTPS "0" - -``` - -Enable and restart: - -```bash -a2ensite dnote -sudo service apache2 restart -``` - -### TLS - -Use LetsEncrypt to obtain a certificate and configure HTTPS in your reverse proxy. - -### systemd Daemon - -Create `/etc/systemd/system/dnote.service`: - -``` -[Unit] -Description=Starts the dnote server -Requires=network.target -After=network.target - -[Service] -Type=simple -User=$user -Restart=always -RestartSec=3 -WorkingDirectory=/home/$user -ExecStart=/usr/local/bin/dnote-server start --webUrl=$WebURL - -[Install] -WantedBy=multi-user.target -``` - -Replace `$user` and `$WebURL`. Add `--dbPath` to `ExecStart` if you want a custom database location. - -Enable and start: - -```bash -sudo systemctl daemon-reload -sudo systemctl enable dnote -sudo systemctl start dnote -``` - -### Email Support - -If you want emails, add these environment variables: - -- `SmtpHost` - SMTP hostname -- `SmtpPort` - SMTP port -- `SmtpUsername` - SMTP username -- `SmtpPassword` - SMTP password - -For systemd, add as `Environment=` lines in the service file. diff --git a/host/docker/README.md b/host/docker/README.md deleted file mode 100644 index 179492b6..00000000 --- a/host/docker/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Dnote Docker Image - -The official Dnote docker image. - -## Installing Dnote Server Using Docker - -1. Install [Docker](https://docs.docker.com/install/). -2. Install Docker [Compose plugin](https://docs.docker.com/compose/install/linux/). -3. Download the [compose.yml](https://raw.githubusercontent.com/dnote/dnote/master/host/docker/compose.yml) file by running: - -``` -curl https://raw.githubusercontent.com/dnote/dnote/master/host/docker/compose.yml > compose.yml -``` - -4. Run the following to download the images and run the containers - -``` -docker compose pull -docker compose up -d -``` - -Visit http://localhost:3001 in your browser to see Dnote running. - -Please see [the installation guide](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) for further configuration. - -## Supported platform - -Currently, the official Docker image for Dnote supports Linux running AMD64 CPU architecture. - -If you run ARM64, please install Dnote server by downloading a binary distribution by following [the guide](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md). From 850f9cc6c9fbe6785d8aaf4f57961745d2588afd Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 11:01:48 -0700 Subject: [PATCH 14/33] Manage users with server CLI (#696) --- .gitignore | 2 +- pkg/assert/prompt.go | 87 ++++++++++ pkg/cli/testutils/main.go | 85 +-------- pkg/cli/ui/terminal.go | 21 +-- pkg/e2e/server_test.go | 140 +++++++++++++++ pkg/prompt/prompt.go | 56 ++++++ pkg/prompt/prompt_test.go | 148 ++++++++++++++++ pkg/server/app/errors.go | 3 + pkg/server/app/testutils.go | 2 +- pkg/server/app/users.go | 99 ++++++++++- pkg/server/app/users_test.go | 299 ++++++++++++++++++++++++++++++++ pkg/server/cmd/helpers.go | 111 ++++++++++++ pkg/server/cmd/root.go | 60 +++++++ pkg/server/cmd/start.go | 91 ++++++++++ pkg/server/cmd/user.go | 190 ++++++++++++++++++++ pkg/server/cmd/user_test.go | 114 ++++++++++++ pkg/server/cmd/version.go | 29 ++++ pkg/server/controllers/users.go | 37 +--- pkg/server/log/log_test.go | 38 ++++ pkg/server/main.go | 151 +--------------- 20 files changed, 1484 insertions(+), 279 deletions(-) create mode 100644 pkg/assert/prompt.go create mode 100644 pkg/prompt/prompt.go create mode 100644 pkg/prompt/prompt_test.go create mode 100644 pkg/server/cmd/helpers.go create mode 100644 pkg/server/cmd/root.go create mode 100644 pkg/server/cmd/start.go create mode 100644 pkg/server/cmd/user.go create mode 100644 pkg/server/cmd/user_test.go create mode 100644 pkg/server/cmd/version.go create mode 100644 pkg/server/log/log_test.go diff --git a/.gitignore b/.gitignore index 57d82ddc..2847e75d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ node_modules /test tmp *.db -server +/server diff --git a/pkg/assert/prompt.go b/pkg/assert/prompt.go new file mode 100644 index 00000000..d4ec5d25 --- /dev/null +++ b/pkg/assert/prompt.go @@ -0,0 +1,87 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package assert + +import ( + "bufio" + "io" + "strings" + "time" + + "github.com/pkg/errors" +) + +// WaitForPrompt waits for an expected prompt to appear in stdout with a timeout. +// Returns an error if the prompt is not found within the timeout period. +// Handles prompts with or without newlines by reading character by character. +func WaitForPrompt(stdout io.Reader, expectedPrompt string, timeout time.Duration) error { + type result struct { + found bool + err error + } + resultCh := make(chan result, 1) + + go func() { + reader := bufio.NewReader(stdout) + var buffer strings.Builder + found := false + + for { + b, err := reader.ReadByte() + if err != nil { + resultCh <- result{found: found, err: err} + return + } + + buffer.WriteByte(b) + if strings.Contains(buffer.String(), expectedPrompt) { + found = true + break + } + } + + resultCh <- result{found: found, err: nil} + }() + + select { + case res := <-resultCh: + if res.err != nil && res.err != io.EOF { + return errors.Wrap(res.err, "reading stdout") + } + if !res.found { + return errors.Errorf("expected prompt '%s' not found in stdout", expectedPrompt) + } + return nil + case <-time.After(timeout): + return errors.Errorf("timeout waiting for prompt '%s'", expectedPrompt) + } +} + +// RespondToPrompt is a helper that waits for a prompt and sends a response. +func RespondToPrompt(stdout io.Reader, stdin io.WriteCloser, expectedPrompt, response string, timeout time.Duration) error { + if err := WaitForPrompt(stdout, expectedPrompt, timeout); err != nil { + return err + } + + if _, err := io.WriteString(stdin, response); err != nil { + return errors.Wrap(err, "writing response to stdin") + } + + return nil +} diff --git a/pkg/cli/testutils/main.go b/pkg/cli/testutils/main.go index ee853b48..6c6caa64 100644 --- a/pkg/cli/testutils/main.go +++ b/pkg/cli/testutils/main.go @@ -20,7 +20,6 @@ package testutils import ( - "bufio" "bytes" "encoding/json" "io" @@ -31,6 +30,7 @@ import ( "testing" "time" + "github.com/dnote/dnote/pkg/assert" "github.com/dnote/dnote/pkg/cli/consts" "github.com/dnote/dnote/pkg/cli/context" "github.com/dnote/dnote/pkg/cli/database" @@ -223,103 +223,32 @@ func MustWaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.Rea return output } -// waitForPrompt waits for an expected prompt to appear in stdout with a timeout. -// Returns an error if the prompt is not found within the timeout period. -// Handles prompts with or without newlines by reading character by character. -func waitForPrompt(stdout io.Reader, expectedPrompt string, timeout time.Duration) error { - type result struct { - found bool - err error - } - resultCh := make(chan result, 1) - - go func() { - reader := bufio.NewReader(stdout) - var buffer strings.Builder - found := false - - for { - b, err := reader.ReadByte() - if err != nil { - resultCh <- result{found: found, err: err} - return - } - - buffer.WriteByte(b) - if strings.Contains(buffer.String(), expectedPrompt) { - found = true - break - } - } - - resultCh <- result{found: found, err: nil} - }() - - select { - case res := <-resultCh: - if res.err != nil && res.err != io.EOF { - return errors.Wrap(res.err, "reading stdout") - } - if !res.found { - return errors.Errorf("expected prompt '%s' not found in stdout", expectedPrompt) - } - return nil - case <-time.After(timeout): - return errors.Errorf("timeout waiting for prompt '%s'", expectedPrompt) - } -} - // MustWaitForPrompt waits for an expected prompt with a default timeout. // Fails the test if the prompt is not found or an error occurs. func MustWaitForPrompt(t *testing.T, stdout io.Reader, expectedPrompt string) { - if err := waitForPrompt(stdout, expectedPrompt, promptTimeout); err != nil { + if err := assert.WaitForPrompt(stdout, expectedPrompt, promptTimeout); err != nil { t.Fatal(err) } } -// userRespondToPrompt is a helper that waits for a prompt and sends a response. -func userRespondToPrompt(stdout io.Reader, stdin io.WriteCloser, expectedPrompt, response, action string) error { - if err := waitForPrompt(stdout, expectedPrompt, promptTimeout); err != nil { - return err - } - - if _, err := io.WriteString(stdin, response); err != nil { - return errors.Wrapf(err, "indicating %s in stdin", action) - } - - return nil -} - -// userConfirmOutput simulates confirmation from the user by writing to stdin. -// It waits for the expected prompt with a timeout to prevent deadlocks. -func userConfirmOutput(stdout io.Reader, stdin io.WriteCloser, expectedPrompt string) error { - return userRespondToPrompt(stdout, stdin, expectedPrompt, "y\n", "confirmation") -} - -// userCancelOutput simulates cancellation from the user by writing to stdin. -// It waits for the expected prompt with a timeout to prevent deadlocks. -func userCancelOutput(stdout io.Reader, stdin io.WriteCloser, expectedPrompt string) error { - return userRespondToPrompt(stdout, stdin, expectedPrompt, "n\n", "cancellation") -} - // ConfirmRemoveNote waits for prompt for removing a note and confirms. func ConfirmRemoveNote(stdout io.Reader, stdin io.WriteCloser) error { - return userConfirmOutput(stdout, stdin, PromptRemoveNote) + return assert.RespondToPrompt(stdout, stdin, PromptRemoveNote, "y\n", promptTimeout) } // ConfirmRemoveBook waits for prompt for deleting a book confirms. func ConfirmRemoveBook(stdout io.Reader, stdin io.WriteCloser) error { - return userConfirmOutput(stdout, stdin, PromptDeleteBook) + return assert.RespondToPrompt(stdout, stdin, PromptDeleteBook, "y\n", promptTimeout) } // UserConfirmEmptyServerSync waits for an empty server prompt and confirms. func UserConfirmEmptyServerSync(stdout io.Reader, stdin io.WriteCloser) error { - return userConfirmOutput(stdout, stdin, PromptEmptyServer) + return assert.RespondToPrompt(stdout, stdin, PromptEmptyServer, "y\n", promptTimeout) } -// UserCancelEmptyServerSync waits for an empty server prompt and confirms. +// UserCancelEmptyServerSync waits for an empty server prompt and cancels. func UserCancelEmptyServerSync(stdout io.Reader, stdin io.WriteCloser) error { - return userCancelOutput(stdout, stdin, PromptEmptyServer) + return assert.RespondToPrompt(stdout, stdin, PromptEmptyServer, "n\n", promptTimeout) } // UserContent simulates content from the user by writing to stdin. diff --git a/pkg/cli/ui/terminal.go b/pkg/cli/ui/terminal.go index ab52873d..899060c7 100644 --- a/pkg/cli/ui/terminal.go +++ b/pkg/cli/ui/terminal.go @@ -26,6 +26,7 @@ import ( "syscall" "github.com/dnote/dnote/pkg/cli/log" + "github.com/dnote/dnote/pkg/prompt" "github.com/pkg/errors" "golang.org/x/crypto/ssh/terminal" ) @@ -73,26 +74,16 @@ func PromptPassword(message string, dest *string) error { // Confirm prompts for user input to confirm a choice func Confirm(question string, optimistic bool) (bool, error) { - var choices string - if optimistic { - choices = "(Y/n)" - } else { - choices = "(y/N)" - } + message := prompt.FormatQuestion(question, optimistic) - message := fmt.Sprintf("%s %s", question, choices) + // Use log.Askf for colored prompt in CLI + log.Askf(message, false) - var input string - if err := PromptInput(message, &input); err != nil { + confirmed, err := prompt.ReadYesNo(os.Stdin, optimistic) + if err != nil { return false, errors.Wrap(err, "Failed to get user input") } - confirmed := input == "y" - - if optimistic { - confirmed = confirmed || input == "" - } - return confirmed, nil } diff --git a/pkg/e2e/server_test.go b/pkg/e2e/server_test.go index c37b7320..cfe6a711 100644 --- a/pkg/e2e/server_test.go +++ b/pkg/e2e/server_test.go @@ -19,6 +19,7 @@ package main import ( + "bytes" "fmt" "net/http" "os" @@ -181,3 +182,142 @@ func TestServerUnknownCommand(t *testing.T) { assert.Equal(t, strings.Contains(outputStr, "Unknown command"), true, "output should contain unknown command message") assert.Equal(t, strings.Contains(outputStr, "Dnote server - a simple command line notebook"), true, "output should show help") } + +func TestServerUserCreate(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + cmd := exec.Command(testServerBinary, "user", "create", + "--dbPath", tmpDB, + "--email", "test@example.com", + "--password", "password123") + output, err := cmd.CombinedOutput() + + if err != nil { + t.Fatalf("user create failed: %v\nOutput: %s", err, output) + } + + outputStr := string(output) + assert.Equal(t, strings.Contains(outputStr, "User created successfully"), true, "output should show success message") + assert.Equal(t, strings.Contains(outputStr, "test@example.com"), true, "output should show email") + + // Verify user exists in database + db, err := gorm.Open(sqlite.Open(tmpDB), &gorm.Config{}) + if err != nil { + t.Fatalf("failed to open database: %v", err) + } + defer func() { + sqlDB, _ := db.DB() + sqlDB.Close() + }() + + var count int64 + db.Table("users").Count(&count) + assert.Equal(t, count, int64(1), "should have created 1 user") +} + +func TestServerUserCreateShortPassword(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + cmd := exec.Command(testServerBinary, "user", "create", + "--dbPath", tmpDB, + "--email", "test@example.com", + "--password", "short") + output, err := cmd.CombinedOutput() + + // Should fail with short password + if err == nil { + t.Fatal("expected command to fail with short password") + } + + outputStr := string(output) + assert.Equal(t, strings.Contains(outputStr, "password should be longer than 8 characters"), true, "output should show password error") +} + +func TestServerUserResetPassword(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Create user first + createCmd := exec.Command(testServerBinary, "user", "create", + "--dbPath", tmpDB, + "--email", "test@example.com", + "--password", "oldpassword123") + if output, err := createCmd.CombinedOutput(); err != nil { + t.Fatalf("failed to create user: %v\nOutput: %s", err, output) + } + + // Reset password + resetCmd := exec.Command(testServerBinary, "user", "reset-password", + "--dbPath", tmpDB, + "--email", "test@example.com", + "--password", "newpassword123") + output, err := resetCmd.CombinedOutput() + + if err != nil { + t.Fatalf("reset-password failed: %v\nOutput: %s", err, output) + } + + outputStr := string(output) + assert.Equal(t, strings.Contains(outputStr, "Password reset successfully"), true, "output should show success message") +} + +func TestServerUserRemove(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Create user first + createCmd := exec.Command(testServerBinary, "user", "create", + "--dbPath", tmpDB, + "--email", "test@example.com", + "--password", "password123") + if output, err := createCmd.CombinedOutput(); err != nil { + t.Fatalf("failed to create user: %v\nOutput: %s", err, output) + } + + // Remove user with confirmation + removeCmd := exec.Command(testServerBinary, "user", "remove", + "--dbPath", tmpDB, + "--email", "test@example.com") + + // Pipe "y" to stdin to confirm removal + stdin, err := removeCmd.StdinPipe() + if err != nil { + t.Fatalf("failed to create stdin pipe: %v", err) + } + + // Capture output + stdout, err := removeCmd.StdoutPipe() + if err != nil { + t.Fatalf("failed to create stdout pipe: %v", err) + } + + var stderr bytes.Buffer + removeCmd.Stderr = &stderr + + // Start command + if err := removeCmd.Start(); err != nil { + t.Fatalf("failed to start remove command: %v", err) + } + + // Wait for prompt and send "y" to confirm + if err := assert.RespondToPrompt(stdout, stdin, "Remove user test@example.com?", "y\n", 10*time.Second); err != nil { + t.Fatalf("failed to confirm removal: %v", err) + } + + // Wait for command to finish + if err := removeCmd.Wait(); err != nil { + t.Fatalf("user remove failed: %v\nStderr: %s", err, stderr.String()) + } + + // Verify user was removed + db, err := gorm.Open(sqlite.Open(tmpDB), &gorm.Config{}) + if err != nil { + t.Fatalf("failed to open database: %v", err) + } + defer func() { + sqlDB, _ := db.DB() + sqlDB.Close() + }() + + var count int64 + db.Table("users").Count(&count) + assert.Equal(t, count, int64(0), "should have 0 users after removal") +} diff --git a/pkg/prompt/prompt.go b/pkg/prompt/prompt.go new file mode 100644 index 00000000..1d413a27 --- /dev/null +++ b/pkg/prompt/prompt.go @@ -0,0 +1,56 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +// Package prompt provides utilities for interactive yes/no prompts +package prompt + +import ( + "bufio" + "fmt" + "io" + "strings" +) + +// FormatQuestion formats a yes/no question with the appropriate choice indicator +func FormatQuestion(question string, optimistic bool) string { + choices := "(y/N)" + if optimistic { + choices = "(Y/n)" + } + return fmt.Sprintf("%s %s", question, choices) +} + +// ReadYesNo reads and parses a yes/no response from the given reader. +// Returns true if confirmed, respecting optimistic mode. +// In optimistic mode, empty input is treated as confirmation. +func ReadYesNo(r io.Reader, optimistic bool) (bool, error) { + reader := bufio.NewReader(r) + input, err := reader.ReadString('\n') + if err != nil { + return false, err + } + + input = strings.ToLower(strings.TrimSpace(input)) + confirmed := input == "y" + + if optimistic { + confirmed = confirmed || input == "" + } + + return confirmed, nil +} diff --git a/pkg/prompt/prompt_test.go b/pkg/prompt/prompt_test.go new file mode 100644 index 00000000..f0df9480 --- /dev/null +++ b/pkg/prompt/prompt_test.go @@ -0,0 +1,148 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package prompt + +import ( + "strings" + "testing" + + "github.com/dnote/dnote/pkg/assert" +) + +func TestFormatQuestion(t *testing.T) { + testCases := []struct { + question string + optimistic bool + expected string + }{ + { + question: "Are you sure?", + optimistic: false, + expected: "Are you sure? (y/N)", + }, + { + question: "Continue?", + optimistic: true, + expected: "Continue? (Y/n)", + }, + } + + for _, tc := range testCases { + t.Run(tc.question, func(t *testing.T) { + result := FormatQuestion(tc.question, tc.optimistic) + assert.Equal(t, result, tc.expected, "formatted question mismatch") + }) + } +} + +func TestReadYesNo(t *testing.T) { + testCases := []struct { + name string + input string + optimistic bool + expected bool + }{ + { + name: "pessimistic with y", + input: "y\n", + optimistic: false, + expected: true, + }, + { + name: "pessimistic with Y (uppercase)", + input: "Y\n", + optimistic: false, + expected: true, + }, + { + name: "pessimistic with n", + input: "n\n", + optimistic: false, + expected: false, + }, + { + name: "pessimistic with empty", + input: "\n", + optimistic: false, + expected: false, + }, + { + name: "pessimistic with whitespace", + input: " \n", + optimistic: false, + expected: false, + }, + { + name: "optimistic with y", + input: "y\n", + optimistic: true, + expected: true, + }, + { + name: "optimistic with n", + input: "n\n", + optimistic: true, + expected: false, + }, + { + name: "optimistic with empty", + input: "\n", + optimistic: true, + expected: true, + }, + { + name: "optimistic with whitespace", + input: " \n", + optimistic: true, + expected: true, + }, + { + name: "invalid input defaults to no", + input: "maybe\n", + optimistic: false, + expected: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + // Create a reader with test input + reader := strings.NewReader(tc.input) + + // Test ReadYesNo + result, err := ReadYesNo(reader, tc.optimistic) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + assert.Equal(t, result, tc.expected, "ReadYesNo result mismatch") + }) + } +} + +func TestReadYesNo_Error(t *testing.T) { + // Test error case with EOF (empty reader) + reader := strings.NewReader("") + + _, err := ReadYesNo(reader, false) + if err == nil { + t.Fatal("expected error when reading from empty reader") + } +} + diff --git a/pkg/server/app/errors.go b/pkg/server/app/errors.go index 895fc40f..48f193b9 100644 --- a/pkg/server/app/errors.go +++ b/pkg/server/app/errors.go @@ -79,4 +79,7 @@ var ( ErrInvalidPassword appError = "Invalid currnet password." // ErrEmailTooLong is an error for email length exceeding the limit ErrEmailTooLong appError = "Email is too long." + + // ErrUserHasExistingResources is an error for attempting to remove a user with existing notes or books + ErrUserHasExistingResources appError = "cannot remove user with existing notes or books" ) diff --git a/pkg/server/app/testutils.go b/pkg/server/app/testutils.go index 06664c5f..45dbd5bb 100644 --- a/pkg/server/app/testutils.go +++ b/pkg/server/app/testutils.go @@ -36,7 +36,7 @@ func NewTest() App { WebURL: "http://127.0.0.0.1", Port: "3000", DisableRegistration: false, - DBPath: ":memory:", + DBPath: "", AssetBaseURL: "", } } diff --git a/pkg/server/app/users.go b/pkg/server/app/users.go index 5c9d7f1f..b3993d55 100644 --- a/pkg/server/app/users.go +++ b/pkg/server/app/users.go @@ -29,6 +29,15 @@ import ( "gorm.io/gorm" ) +// validatePassword validates a password +func validatePassword(password string) error { + if len(password) < 8 { + return ErrPasswordTooShort + } + + return nil +} + // TouchLastLoginAt updates the last login timestamp func (a *App) TouchLastLoginAt(user database.User, tx *gorm.DB) error { t := a.Clock.Now() @@ -45,8 +54,8 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d return database.User{}, ErrEmailRequired } - if len(password) < 8 { - return database.User{}, ErrPasswordTooShort + if err := validatePassword(password); err != nil { + return database.User{}, err } if password != passwordConfirmation { @@ -102,8 +111,8 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d return user, nil } -// Authenticate authenticates a user -func (a *App) Authenticate(email, password string) (*database.User, error) { +// GetAccountByEmail finds an account by email +func (a *App) GetAccountByEmail(email string) (*database.Account, error) { var account database.Account err := a.DB.Where("email = ?", email).First(&account).Error if errors.Is(err, gorm.ErrRecordNotFound) { @@ -112,6 +121,16 @@ func (a *App) Authenticate(email, password string) (*database.User, error) { return nil, err } + return &account, nil +} + +// Authenticate authenticates a user +func (a *App) Authenticate(email, password string) (*database.User, error) { + account, err := a.GetAccountByEmail(email) + if err != nil { + return nil, err + } + err = bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte(password)) if err != nil { return nil, ErrLoginInvalid @@ -126,6 +145,78 @@ func (a *App) Authenticate(email, password string) (*database.User, error) { return &user, nil } +// UpdateAccountPassword updates an account's password with validation +func UpdateAccountPassword(db *gorm.DB, account *database.Account, newPassword string) error { + // Validate password + if err := validatePassword(newPassword); err != nil { + return err + } + + // Hash the password + hashedPassword, err := bcrypt.GenerateFromPassword([]byte(newPassword), bcrypt.DefaultCost) + if err != nil { + return pkgErrors.Wrap(err, "hashing password") + } + + // Update the password + if err := db.Model(&account).Update("password", string(hashedPassword)).Error; err != nil { + return pkgErrors.Wrap(err, "updating password") + } + + return nil +} + +// RemoveUser removes a user and their account from the system +// Returns an error if the user has any notes or books +func (a *App) RemoveUser(email string) error { + // Find the account and user + account, err := a.GetAccountByEmail(email) + if err != nil { + return err + } + + // Check if user has any notes + var noteCount int64 + if err := a.DB.Model(&database.Note{}).Where("user_id = ? AND deleted = ?", account.UserID, false).Count(¬eCount).Error; err != nil { + return pkgErrors.Wrap(err, "counting notes") + } + if noteCount > 0 { + return ErrUserHasExistingResources + } + + // Check if user has any books + var bookCount int64 + if err := a.DB.Model(&database.Book{}).Where("user_id = ? AND deleted = ?", account.UserID, false).Count(&bookCount).Error; err != nil { + return pkgErrors.Wrap(err, "counting books") + } + if bookCount > 0 { + return ErrUserHasExistingResources + } + + // Delete account and user in a transaction + tx := a.DB.Begin() + + if err := tx.Delete(&account).Error; err != nil { + tx.Rollback() + return pkgErrors.Wrap(err, "deleting account") + } + + var user database.User + if err := tx.Where("id = ?", account.UserID).First(&user).Error; err != nil { + tx.Rollback() + return pkgErrors.Wrap(err, "finding user") + } + + if err := tx.Delete(&user).Error; err != nil { + tx.Rollback() + return pkgErrors.Wrap(err, "deleting user") + } + + tx.Commit() + + return nil +} + // SignIn signs in a user func (a *App) SignIn(user *database.User) (*database.Session, error) { err := a.TouchLastLoginAt(*user, a.DB) diff --git a/pkg/server/app/users_test.go b/pkg/server/app/users_test.go index 45c43514..a4c3a60d 100644 --- a/pkg/server/app/users_test.go +++ b/pkg/server/app/users_test.go @@ -28,6 +28,42 @@ import ( "golang.org/x/crypto/bcrypt" ) +func TestValidatePassword(t *testing.T) { + testCases := []struct { + name string + password string + wantErr error + }{ + { + name: "valid password", + password: "password123", + wantErr: nil, + }, + { + name: "valid password exactly 8 chars", + password: "12345678", + wantErr: nil, + }, + { + name: "password too short", + password: "1234567", + wantErr: ErrPasswordTooShort, + }, + { + name: "empty password", + password: "", + wantErr: ErrPasswordTooShort, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + err := validatePassword(tc.password) + assert.Equal(t, err, tc.wantErr, "error mismatch") + }) + } +} + func TestCreateUser_ProValue(t *testing.T) { db := testutils.InitMemoryDB(t) @@ -46,6 +82,36 @@ func TestCreateUser_ProValue(t *testing.T) { } +func TestGetAccountByEmail(t *testing.T) { + t.Run("success", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "alice@example.com", "password123") + + a := NewTest() + a.DB = db + + account, err := a.GetAccountByEmail("alice@example.com") + + assert.Equal(t, err, nil, "should not error") + assert.Equal(t, account.Email.String, "alice@example.com", "email mismatch") + assert.Equal(t, account.UserID, user.ID, "user ID mismatch") + }) + + t.Run("not found", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + a := NewTest() + a.DB = db + + account, err := a.GetAccountByEmail("nonexistent@example.com") + + assert.Equal(t, err, ErrNotFound, "should return ErrNotFound") + assert.Equal(t, account, (*database.Account)(nil), "account should be nil") + }) +} + func TestCreateUser(t *testing.T) { t.Run("success", func(t *testing.T) { db := testutils.InitMemoryDB(t) @@ -92,3 +158,236 @@ func TestCreateUser(t *testing.T) { assert.Equal(t, accountCount, int64(1), "account count mismatch") }) } + +func TestUpdateAccountPassword(t *testing.T) { + t.Run("success", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + + err := UpdateAccountPassword(db, &account, "newpassword123") + + assert.Equal(t, err, nil, "should not error") + + // Verify password was updated in database + var updatedAccount database.Account + testutils.MustExec(t, db.Where("id = ?", account.ID).First(&updatedAccount), "finding updated account") + + // Verify new password works + passwordErr := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("newpassword123")) + assert.Equal(t, passwordErr, nil, "New password should match") + + // Verify old password no longer works + oldPasswordErr := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("oldpassword123")) + assert.NotEqual(t, oldPasswordErr, nil, "Old password should not match") + }) + + t.Run("password too short", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + + err := UpdateAccountPassword(db, &account, "short") + + assert.Equal(t, err, ErrPasswordTooShort, "should return ErrPasswordTooShort") + + // Verify password was NOT updated in database + var unchangedAccount database.Account + testutils.MustExec(t, db.Where("id = ?", account.ID).First(&unchangedAccount), "finding unchanged account") + + // Verify old password still works + passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedAccount.Password.String), []byte("oldpassword123")) + assert.Equal(t, passwordErr, nil, "Old password should still match") + }) + + t.Run("empty password", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + + err := UpdateAccountPassword(db, &account, "") + + assert.Equal(t, err, ErrPasswordTooShort, "should return ErrPasswordTooShort") + + // Verify password was NOT updated in database + var unchangedAccount database.Account + testutils.MustExec(t, db.Where("id = ?", account.ID).First(&unchangedAccount), "finding unchanged account") + + // Verify old password still works + passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedAccount.Password.String), []byte("oldpassword123")) + assert.Equal(t, passwordErr, nil, "Old password should still match") + }) + + t.Run("transaction rollback", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + + // Start a transaction and rollback to verify UpdateAccountPassword respects transactions + tx := db.Begin() + err := UpdateAccountPassword(tx, &account, "newpassword123") + assert.Equal(t, err, nil, "should not error") + tx.Rollback() + + // Verify password was NOT updated after rollback + var unchangedAccount database.Account + testutils.MustExec(t, db.Where("id = ?", account.ID).First(&unchangedAccount), "finding unchanged account") + + // Verify old password still works + passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedAccount.Password.String), []byte("oldpassword123")) + assert.Equal(t, passwordErr, nil, "Old password should still match after rollback") + }) + + t.Run("transaction commit", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + + // Start a transaction and commit to verify UpdateAccountPassword respects transactions + tx := db.Begin() + err := UpdateAccountPassword(tx, &account, "newpassword123") + assert.Equal(t, err, nil, "should not error") + tx.Commit() + + // Verify password was updated after commit + var updatedAccount database.Account + testutils.MustExec(t, db.Where("id = ?", account.ID).First(&updatedAccount), "finding updated account") + + // Verify new password works + passwordErr := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("newpassword123")) + assert.Equal(t, passwordErr, nil, "New password should match after commit") + }) +} + +func TestRemoveUser(t *testing.T) { + t.Run("success", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "alice@example.com", "password123") + + a := NewTest() + a.DB = db + + err := a.RemoveUser("alice@example.com") + + assert.Equal(t, err, nil, "should not error") + + // Verify user was deleted + var userCount int64 + testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") + assert.Equal(t, userCount, int64(0), "user should be deleted") + + // Verify account was deleted + var accountCount int64 + testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") + assert.Equal(t, accountCount, int64(0), "account should be deleted") + }) + + t.Run("user not found", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + a := NewTest() + a.DB = db + + err := a.RemoveUser("nonexistent@example.com") + + assert.Equal(t, err, ErrNotFound, "should return ErrNotFound") + }) + + t.Run("user has notes", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "alice@example.com", "password123") + + book := database.Book{UserID: user.ID, Label: "testbook", Deleted: false} + testutils.MustExec(t, db.Save(&book), "creating book") + + note := database.Note{UserID: user.ID, BookUUID: book.UUID, Body: "test note", Deleted: false} + testutils.MustExec(t, db.Save(¬e), "creating note") + + a := NewTest() + a.DB = db + + err := a.RemoveUser("alice@example.com") + + assert.Equal(t, err, ErrUserHasExistingResources, "should return ErrUserHasExistingResources") + + // Verify user was NOT deleted + var userCount int64 + testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") + assert.Equal(t, userCount, int64(1), "user should not be deleted") + + // Verify account was NOT deleted + var accountCount int64 + testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") + assert.Equal(t, accountCount, int64(1), "account should not be deleted") + }) + + t.Run("user has books", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "alice@example.com", "password123") + + book := database.Book{UserID: user.ID, Label: "testbook", Deleted: false} + testutils.MustExec(t, db.Save(&book), "creating book") + + a := NewTest() + a.DB = db + + err := a.RemoveUser("alice@example.com") + + assert.Equal(t, err, ErrUserHasExistingResources, "should return ErrUserHasExistingResources") + + // Verify user was NOT deleted + var userCount int64 + testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") + assert.Equal(t, userCount, int64(1), "user should not be deleted") + + // Verify account was NOT deleted + var accountCount int64 + testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") + assert.Equal(t, accountCount, int64(1), "account should not be deleted") + }) + + t.Run("user has deleted notes and books", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "alice@example.com", "password123") + + book := database.Book{UserID: user.ID, Label: "testbook", Deleted: false} + testutils.MustExec(t, db.Save(&book), "creating book") + + note := database.Note{UserID: user.ID, BookUUID: book.UUID, Body: "test note", Deleted: false} + testutils.MustExec(t, db.Save(¬e), "creating note") + + // Soft delete the note and book + testutils.MustExec(t, db.Model(¬e).Update("deleted", true), "soft deleting note") + testutils.MustExec(t, db.Model(&book).Update("deleted", true), "soft deleting book") + + a := NewTest() + a.DB = db + + err := a.RemoveUser("alice@example.com") + + assert.Equal(t, err, nil, "should not error when user only has deleted notes and books") + + // Verify user was deleted + var userCount int64 + testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") + assert.Equal(t, userCount, int64(0), "user should be deleted") + + // Verify account was deleted + var accountCount int64 + testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") + assert.Equal(t, accountCount, int64(0), "account should be deleted") + }) +} diff --git a/pkg/server/cmd/helpers.go b/pkg/server/cmd/helpers.go new file mode 100644 index 00000000..a22c8721 --- /dev/null +++ b/pkg/server/cmd/helpers.go @@ -0,0 +1,111 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package cmd + +import ( + "flag" + "fmt" + "os" + + "github.com/dnote/dnote/pkg/clock" + "github.com/dnote/dnote/pkg/server/app" + "github.com/dnote/dnote/pkg/server/config" + "github.com/dnote/dnote/pkg/server/database" + "github.com/dnote/dnote/pkg/server/log" + "github.com/dnote/dnote/pkg/server/mailer" + "gorm.io/gorm" +) + +func initDB(dbPath string) *gorm.DB { + db := database.Open(dbPath) + database.InitSchema(db) + database.Migrate(db) + + return db +} + +func initApp(cfg config.Config) app.App { + db := initDB(cfg.DBPath) + + emailBackend, err := mailer.NewDefaultBackend(cfg.IsProd()) + if err != nil { + emailBackend = &mailer.DefaultBackend{Enabled: false} + } else { + log.Info("Email backend configured") + } + + return app.App{ + DB: db, + Clock: clock.New(), + EmailTemplates: mailer.NewTemplates(), + EmailBackend: emailBackend, + HTTP500Page: cfg.HTTP500Page, + AppEnv: cfg.AppEnv, + WebURL: cfg.WebURL, + DisableRegistration: cfg.DisableRegistration, + Port: cfg.Port, + DBPath: cfg.DBPath, + AssetBaseURL: cfg.AssetBaseURL, + } +} + +// setupFlagSet creates a FlagSet with standard usage format +func setupFlagSet(name, usageCmd string) *flag.FlagSet { + fs := flag.NewFlagSet(name, flag.ExitOnError) + fs.Usage = func() { + fmt.Printf(`Usage: + %s [flags] + +Flags: +`, usageCmd) + fs.PrintDefaults() + } + return fs +} + +// requireString validates that a required string flag is not empty +func requireString(fs *flag.FlagSet, value, fieldName string) { + if value == "" { + fmt.Printf("Error: %s is required\n", fieldName) + fs.Usage() + os.Exit(1) + } +} + +// setupAppWithDB creates config, initializes app, and returns cleanup function +func setupAppWithDB(fs *flag.FlagSet, dbPath string) (*app.App, func()) { + cfg, err := config.New(config.Params{ + DBPath: dbPath, + }) + if err != nil { + fmt.Printf("Error: %s\n\n", err) + fs.Usage() + os.Exit(1) + } + + a := initApp(cfg) + cleanup := func() { + sqlDB, err := a.DB.DB() + if err == nil { + sqlDB.Close() + } + } + + return &a, cleanup +} diff --git a/pkg/server/cmd/root.go b/pkg/server/cmd/root.go new file mode 100644 index 00000000..1ed2129f --- /dev/null +++ b/pkg/server/cmd/root.go @@ -0,0 +1,60 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package cmd + +import ( + "fmt" + "os" +) + +func rootCmd() { + fmt.Printf(`Dnote server - a simple command line notebook + +Usage: + dnote-server [command] [flags] + +Available commands: + start: Start the server (use 'dnote-server start --help' for flags) + user: Manage users (use 'dnote-server user' for subcommands) + version: Print the version +`) +} + +// Execute is the main entry point for the CLI +func Execute() { + if len(os.Args) < 2 { + rootCmd() + return + } + + cmd := os.Args[1] + + switch cmd { + case "start": + startCmd(os.Args[2:]) + case "user": + userCmd(os.Args[2:]) + case "version": + versionCmd() + default: + fmt.Printf("Unknown command %s\n", cmd) + rootCmd() + os.Exit(1) + } +} diff --git a/pkg/server/cmd/start.go b/pkg/server/cmd/start.go new file mode 100644 index 00000000..cbbc60ed --- /dev/null +++ b/pkg/server/cmd/start.go @@ -0,0 +1,91 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package cmd + +import ( + "fmt" + "net/http" + "os" + + "github.com/dnote/dnote/pkg/server/buildinfo" + "github.com/dnote/dnote/pkg/server/config" + "github.com/dnote/dnote/pkg/server/controllers" + "github.com/dnote/dnote/pkg/server/log" + "github.com/pkg/errors" +) + +func startCmd(args []string) { + fs := setupFlagSet("start", "dnote-server start") + + appEnv := fs.String("appEnv", "", "Application environment (env: APP_ENV, default: PRODUCTION)") + port := fs.String("port", "", "Server port (env: PORT, default: 3001)") + webURL := fs.String("webUrl", "", "Full URL to server without trailing slash (env: WebURL, default: http://localhost:3001)") + dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") + disableRegistration := fs.Bool("disableRegistration", false, "Disable user registration (env: DisableRegistration, default: false)") + logLevel := fs.String("logLevel", "", "Log level: debug, info, warn, or error (env: LOG_LEVEL, default: info)") + + fs.Parse(args) + + cfg, err := config.New(config.Params{ + AppEnv: *appEnv, + Port: *port, + WebURL: *webURL, + DBPath: *dbPath, + DisableRegistration: *disableRegistration, + LogLevel: *logLevel, + }) + if err != nil { + fmt.Printf("Error: %s\n\n", err) + fs.Usage() + os.Exit(1) + } + + // Set log level + log.SetLevel(cfg.LogLevel) + + app := initApp(cfg) + defer func() { + sqlDB, err := app.DB.DB() + if err == nil { + sqlDB.Close() + } + }() + + ctl := controllers.New(&app) + rc := controllers.RouteConfig{ + WebRoutes: controllers.NewWebRoutes(&app, ctl), + APIRoutes: controllers.NewAPIRoutes(&app, ctl), + Controllers: ctl, + } + + r, err := controllers.NewRouter(&app, rc) + if err != nil { + panic(errors.Wrap(err, "initializing router")) + } + + log.WithFields(log.Fields{ + "version": buildinfo.Version, + "port": cfg.Port, + }).Info("Dnote server starting") + + if err := http.ListenAndServe(fmt.Sprintf(":%s", cfg.Port), r); err != nil { + log.ErrorWrap(err, "server failed") + os.Exit(1) + } +} diff --git a/pkg/server/cmd/user.go b/pkg/server/cmd/user.go new file mode 100644 index 00000000..6123cdae --- /dev/null +++ b/pkg/server/cmd/user.go @@ -0,0 +1,190 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package cmd + +import ( + "fmt" + "io" + "os" + + "github.com/dnote/dnote/pkg/prompt" + "github.com/dnote/dnote/pkg/server/app" + "github.com/dnote/dnote/pkg/server/log" + "github.com/pkg/errors" +) + +// confirm prompts for user input to confirm a choice +func confirm(r io.Reader, question string, optimistic bool) (bool, error) { + message := prompt.FormatQuestion(question, optimistic) + fmt.Print(message + " ") + + confirmed, err := prompt.ReadYesNo(r, optimistic) + if err != nil { + return false, errors.Wrap(err, "reading stdin") + } + + return confirmed, nil +} + +func userCreateCmd(args []string) { + fs := setupFlagSet("create", "dnote-server user create") + + email := fs.String("email", "", "User email address (required)") + password := fs.String("password", "", "User password (required)") + dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") + + fs.Parse(args) + + requireString(fs, *email, "email") + requireString(fs, *password, "password") + + a, cleanup := setupAppWithDB(fs, *dbPath) + defer cleanup() + + _, err := a.CreateUser(*email, *password, *password) + if err != nil { + log.ErrorWrap(err, "creating user") + os.Exit(1) + } + + fmt.Printf("User created successfully\n") + fmt.Printf("Email: %s\n", *email) +} + +func userRemoveCmd(args []string, stdin io.Reader) { + fs := setupFlagSet("remove", "dnote-server user remove") + + email := fs.String("email", "", "User email address (required)") + dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") + + fs.Parse(args) + + requireString(fs, *email, "email") + + a, cleanup := setupAppWithDB(fs, *dbPath) + defer cleanup() + + // Check if user exists first + _, err := a.GetAccountByEmail(*email) + if err != nil { + if errors.Is(err, app.ErrNotFound) { + fmt.Printf("Error: user with email %s not found\n", *email) + } else { + log.ErrorWrap(err, "finding account") + } + os.Exit(1) + } + + // Show confirmation prompt + ok, err := confirm(stdin, fmt.Sprintf("Remove user %s?", *email), false) + if err != nil { + log.ErrorWrap(err, "getting confirmation") + os.Exit(1) + } + if !ok { + fmt.Println("Aborted by user") + os.Exit(0) + } + + // Remove the user + if err := a.RemoveUser(*email); err != nil { + if errors.Is(err, app.ErrNotFound) { + fmt.Printf("Error: user with email %s not found\n", *email) + } else if errors.Is(err, app.ErrUserHasExistingResources) { + fmt.Printf("Error: %s\n", err) + } else { + log.ErrorWrap(err, "removing user") + } + os.Exit(1) + } + + fmt.Printf("User removed successfully\n") + fmt.Printf("Email: %s\n", *email) +} + +func userResetPasswordCmd(args []string) { + fs := setupFlagSet("reset-password", "dnote-server user reset-password") + + email := fs.String("email", "", "User email address (required)") + password := fs.String("password", "", "New password (required)") + dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") + + fs.Parse(args) + + requireString(fs, *email, "email") + requireString(fs, *password, "password") + + a, cleanup := setupAppWithDB(fs, *dbPath) + defer cleanup() + + // Find the account + account, err := a.GetAccountByEmail(*email) + if err != nil { + if errors.Is(err, app.ErrNotFound) { + fmt.Printf("Error: user with email %s not found\n", *email) + } else { + log.ErrorWrap(err, "finding account") + } + os.Exit(1) + } + + // Update the password + if err := app.UpdateAccountPassword(a.DB, account, *password); err != nil { + log.ErrorWrap(err, "updating password") + os.Exit(1) + } + + fmt.Printf("Password reset successfully\n") + fmt.Printf("Email: %s\n", *email) +} + +func userCmd(args []string) { + if len(args) < 1 { + fmt.Println(`Usage: + dnote-server user [command] + +Available commands: + create: Create a new user + remove: Remove a user + reset-password: Reset a user's password`) + os.Exit(1) + } + + subcommand := args[0] + subArgs := []string{} + if len(args) > 1 { + subArgs = args[1:] + } + + switch subcommand { + case "create": + userCreateCmd(subArgs) + case "remove": + userRemoveCmd(subArgs, os.Stdin) + case "reset-password": + userResetPasswordCmd(subArgs) + default: + fmt.Printf("Unknown subcommand: %s\n\n", subcommand) + fmt.Println(`Available commands: + create: Create a new user + remove: Remove a user (only if they have no notes or books) + reset-password: Reset a user's password`) + os.Exit(1) + } +} diff --git a/pkg/server/cmd/user_test.go b/pkg/server/cmd/user_test.go new file mode 100644 index 00000000..d3536d52 --- /dev/null +++ b/pkg/server/cmd/user_test.go @@ -0,0 +1,114 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package cmd + +import ( + "strings" + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/server/database" + "github.com/dnote/dnote/pkg/server/testutils" + "golang.org/x/crypto/bcrypt" +) + +func TestUserCreateCmd(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Call the function directly + userCreateCmd([]string{"--dbPath", tmpDB, "--email", "test@example.com", "--password", "password123"}) + + // Verify user was created in database + db := testutils.InitDB(tmpDB) + defer func() { + sqlDB, _ := db.DB() + sqlDB.Close() + }() + + var count int64 + testutils.MustExec(t, db.Model(&database.User{}).Count(&count), "counting users") + assert.Equal(t, count, int64(1), "should have 1 user") + + var account database.Account + testutils.MustExec(t, db.Where("email = ?", "test@example.com").First(&account), "finding account") + assert.Equal(t, account.Email.String, "test@example.com", "email mismatch") +} + +func TestUserRemoveCmd(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Create a user first + db := testutils.InitDB(tmpDB) + user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "test@example.com", "password123") + sqlDB, _ := db.DB() + sqlDB.Close() + + // Remove the user with mock stdin that responds "y" + mockStdin := strings.NewReader("y\n") + userRemoveCmd([]string{"--dbPath", tmpDB, "--email", "test@example.com"}, mockStdin) + + // Verify user was removed + db2 := testutils.InitDB(tmpDB) + defer func() { + sqlDB2, _ := db2.DB() + sqlDB2.Close() + }() + + var count int64 + testutils.MustExec(t, db2.Model(&database.User{}).Count(&count), "counting users") + assert.Equal(t, count, int64(0), "should have 0 users") +} + +func TestUserResetPasswordCmd(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Create a user first + db := testutils.InitDB(tmpDB) + user := testutils.SetupUserData(db) + account := testutils.SetupAccountData(db, user, "test@example.com", "oldpassword123") + oldPasswordHash := account.Password.String + sqlDB, _ := db.DB() + sqlDB.Close() + + // Reset password + userResetPasswordCmd([]string{"--dbPath", tmpDB, "--email", "test@example.com", "--password", "newpassword123"}) + + // Verify password was changed + db2 := testutils.InitDB(tmpDB) + defer func() { + sqlDB2, _ := db2.DB() + sqlDB2.Close() + }() + + var updatedAccount database.Account + testutils.MustExec(t, db2.Where("email = ?", "test@example.com").First(&updatedAccount), "finding account") + + // Verify password hash changed + assert.Equal(t, updatedAccount.Password.String != oldPasswordHash, true, "password hash should be different") + assert.Equal(t, len(updatedAccount.Password.String) > 0, true, "password should be set") + + // Verify new password works + err := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("newpassword123")) + assert.Equal(t, err, nil, "new password should match") + + // Verify old password doesn't work + err = bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("oldpassword123")) + assert.Equal(t, err != nil, true, "old password should not match") +} diff --git a/pkg/server/cmd/version.go b/pkg/server/cmd/version.go new file mode 100644 index 00000000..99c68429 --- /dev/null +++ b/pkg/server/cmd/version.go @@ -0,0 +1,29 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package cmd + +import ( + "fmt" + + "github.com/dnote/dnote/pkg/server/buildinfo" +) + +func versionCmd() { + fmt.Printf("dnote-server-%s\n", buildinfo.Version) +} diff --git a/pkg/server/controllers/users.go b/pkg/server/controllers/users.go index 67baca6a..b1945d8f 100644 --- a/pkg/server/controllers/users.go +++ b/pkg/server/controllers/users.go @@ -396,27 +396,21 @@ func (u *Users) PasswordReset(w http.ResponseWriter, r *http.Request) { return } - tx := u.app.DB.Begin() - - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(params.Password), bcrypt.DefaultCost) - if err != nil { - tx.Rollback() - handleHTMLError(w, r, err, "hashing password", u.PasswordResetConfirmView, vd) - return - } - var account database.Account if err := u.app.DB.Where("user_id = ?", token.UserID).First(&account).Error; err != nil { - tx.Rollback() handleHTMLError(w, r, err, "finding user", u.PasswordResetConfirmView, vd) return } - if err := tx.Model(&account).Update("password", string(hashedPassword)).Error; err != nil { + tx := u.app.DB.Begin() + + // Update the password + if err := app.UpdateAccountPassword(tx, &account, params.Password); err != nil { tx.Rollback() handleHTMLError(w, r, err, "updating password", u.PasswordResetConfirmView, vd) return } + if err := tx.Model(&token).Update("used_at", time.Now()).Error; err != nil { tx.Rollback() handleHTMLError(w, r, err, "updating password reset token", u.PasswordResetConfirmView, vd) @@ -514,18 +508,7 @@ func (u *Users) PasswordUpdate(w http.ResponseWriter, r *http.Request) { return } - if err := validatePassword(form.NewPassword); err != nil { - handleHTMLError(w, r, err, "invalid password", u.SettingView, vd) - return - } - - hashedNewPassword, err := bcrypt.GenerateFromPassword([]byte(form.NewPassword), bcrypt.DefaultCost) - if err != nil { - handleHTMLError(w, r, err, "hashing password", u.SettingView, vd) - return - } - - if err := u.app.DB.Model(&account).Update("password", string(hashedNewPassword)).Error; err != nil { + if err := app.UpdateAccountPassword(u.app.DB, &account, form.NewPassword); err != nil { handleHTMLError(w, r, err, "updating password", u.SettingView, vd) return } @@ -537,14 +520,6 @@ func (u *Users) PasswordUpdate(w http.ResponseWriter, r *http.Request) { views.RedirectAlert(w, r, "/", http.StatusFound, alert) } -func validatePassword(password string) error { - if len(password) < 8 { - return app.ErrPasswordTooShort - } - - return nil -} - type updateProfileForm struct { Email string `schema:"email"` Password string `schema:"password"` diff --git a/pkg/server/log/log_test.go b/pkg/server/log/log_test.go new file mode 100644 index 00000000..3df63b3a --- /dev/null +++ b/pkg/server/log/log_test.go @@ -0,0 +1,38 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * 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. + * + * Dnote 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 Dnote. If not, see . + */ + +package log + +import ( + "testing" +) + +func TestSetLevel(t *testing.T) { + // Reset to default after test + defer SetLevel(LevelInfo) + + SetLevel(LevelDebug) + if currentLevel != LevelDebug { + t.Errorf("Expected level %s, got %s", LevelDebug, currentLevel) + } + + SetLevel(LevelError) + if currentLevel != LevelError { + t.Errorf("Expected level %s, got %s", LevelError, currentLevel) + } +} diff --git a/pkg/server/main.go b/pkg/server/main.go index e8fa1aa8..701912ea 100644 --- a/pkg/server/main.go +++ b/pkg/server/main.go @@ -19,156 +19,9 @@ package main import ( - "flag" - "fmt" - "net/http" - "os" - - "github.com/dnote/dnote/pkg/clock" - "github.com/dnote/dnote/pkg/server/app" - "github.com/dnote/dnote/pkg/server/buildinfo" - "github.com/dnote/dnote/pkg/server/config" - "github.com/dnote/dnote/pkg/server/controllers" - "github.com/dnote/dnote/pkg/server/database" - "github.com/dnote/dnote/pkg/server/log" - "github.com/dnote/dnote/pkg/server/mailer" - "github.com/pkg/errors" - "gorm.io/gorm" + "github.com/dnote/dnote/pkg/server/cmd" ) -func initDB(dbPath string) *gorm.DB { - db := database.Open(dbPath) - database.InitSchema(db) - database.Migrate(db) - - return db -} - -func initApp(cfg config.Config) app.App { - db := initDB(cfg.DBPath) - - emailBackend, err := mailer.NewDefaultBackend(cfg.IsProd()) - if err != nil { - emailBackend = &mailer.DefaultBackend{Enabled: false} - } else { - log.Info("Email backend configured") - } - - return app.App{ - DB: db, - Clock: clock.New(), - EmailTemplates: mailer.NewTemplates(), - EmailBackend: emailBackend, - HTTP500Page: cfg.HTTP500Page, - AppEnv: cfg.AppEnv, - WebURL: cfg.WebURL, - DisableRegistration: cfg.DisableRegistration, - Port: cfg.Port, - DBPath: cfg.DBPath, - AssetBaseURL: cfg.AssetBaseURL, - } -} - -func startCmd(args []string) { - startFlags := flag.NewFlagSet("start", flag.ExitOnError) - startFlags.Usage = func() { - fmt.Printf(`Usage: - dnote-server start [flags] - -Flags: -`) - startFlags.PrintDefaults() - } - - appEnv := startFlags.String("appEnv", "", "Application environment (env: APP_ENV, default: PRODUCTION)") - port := startFlags.String("port", "", "Server port (env: PORT, default: 3001)") - webURL := startFlags.String("webUrl", "", "Full URL to server without trailing slash (env: WebURL, default: http://localhost:3001)") - dbPath := startFlags.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") - disableRegistration := startFlags.Bool("disableRegistration", false, "Disable user registration (env: DisableRegistration, default: false)") - logLevel := startFlags.String("logLevel", "", "Log level: debug, info, warn, or error (env: LOG_LEVEL, default: info)") - - startFlags.Parse(args) - - cfg, err := config.New(config.Params{ - AppEnv: *appEnv, - Port: *port, - WebURL: *webURL, - DBPath: *dbPath, - DisableRegistration: *disableRegistration, - LogLevel: *logLevel, - }) - if err != nil { - fmt.Printf("Error: %s\n\n", err) - startFlags.Usage() - os.Exit(1) - } - - // Set log level - log.SetLevel(cfg.LogLevel) - - app := initApp(cfg) - defer func() { - sqlDB, err := app.DB.DB() - if err == nil { - sqlDB.Close() - } - }() - - ctl := controllers.New(&app) - rc := controllers.RouteConfig{ - WebRoutes: controllers.NewWebRoutes(&app, ctl), - APIRoutes: controllers.NewAPIRoutes(&app, ctl), - Controllers: ctl, - } - - r, err := controllers.NewRouter(&app, rc) - if err != nil { - panic(errors.Wrap(err, "initializing router")) - } - - log.WithFields(log.Fields{ - "version": buildinfo.Version, - "port": cfg.Port, - }).Info("Dnote server starting") - - if err := http.ListenAndServe(fmt.Sprintf(":%s", cfg.Port), r); err != nil { - log.ErrorWrap(err, "server failed") - os.Exit(1) - } -} - -func versionCmd() { - fmt.Printf("dnote-server-%s\n", buildinfo.Version) -} - -func rootCmd() { - fmt.Printf(`Dnote server - a simple command line notebook - -Usage: - dnote-server [command] [flags] - -Available commands: - start: Start the server (use 'dnote-server start --help' for flags) - version: Print the version -`) -} - func main() { - if len(os.Args) < 2 { - rootCmd() - return - } - - cmd := os.Args[1] - - switch cmd { - case "start": - startCmd(os.Args[2:]) - case "version": - versionCmd() - default: - fmt.Printf("Unknown command %s\n", cmd) - rootCmd() - os.Exit(1) - } + cmd.Execute() } From 7d44c541a4da9c8cd6d842f891af8d5c0b76a704 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 14:30:55 -0700 Subject: [PATCH 15/33] Add Docker images for linux arm64, armv7, 386 (#697) * Add multi-platform Docker support for ARM64, ARMv7, and 386 * Support freebsd amd64 for server * Build docker images locally --- .github/workflows/release-server.yml | 12 ++++- Makefile | 56 ++++--------------- host/docker/Dockerfile | 28 ++++++++-- host/docker/build.sh | 80 ++++++++++++++++++++++++++-- host/docker/release.sh | 13 ----- scripts/cli/release-homebrew.sh | 53 ------------------ scripts/release.sh | 57 -------------------- scripts/server/build.sh | 3 ++ 8 files changed, 122 insertions(+), 180 deletions(-) delete mode 100755 host/docker/release.sh delete mode 100755 scripts/cli/release-homebrew.sh delete mode 100755 scripts/release.sh diff --git a/.github/workflows/release-server.yml b/.github/workflows/release-server.yml index f52e1508..a5f52933 100644 --- a/.github/workflows/release-server.yml +++ b/.github/workflows/release-server.yml @@ -55,10 +55,19 @@ jobs: ./scripts/generate-changelog.sh server "$TAG" "$PREV_TAG" > /tmp/changelog.txt cat /tmp/changelog.txt + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Prepare Docker build context run: | VERSION="${{ steps.version.outputs.version }}" cp build/server/dnote_server_${VERSION}_linux_amd64.tar.gz host/docker/ + cp build/server/dnote_server_${VERSION}_linux_arm64.tar.gz host/docker/ + cp build/server/dnote_server_${VERSION}_linux_arm.tar.gz host/docker/ + cp build/server/dnote_server_${VERSION}_linux_386.tar.gz host/docker/ - name: Login to Docker Hub uses: docker/login-action@v3 @@ -71,11 +80,12 @@ jobs: with: context: ./host/docker push: true + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 tags: | dnote/dnote:${{ steps.version.outputs.version }} dnote/dnote:latest build-args: | - tarballName=dnote_server_${{ steps.version.outputs.version }}_linux_amd64.tar.gz + version=${{ steps.version.outputs.version }} - name: Create GitHub release env: diff --git a/Makefile b/Makefile index 12cf32cf..5037c408 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,15 @@ endif @${currentDir}/scripts/server/build.sh $(version) .PHONY: build-server +build-server-docker: build-server +ifndef version + $(error version is required. Usage: make version=0.1.0 [platform=linux/amd64] build-server-docker) +endif + + @echo "==> building Docker image" + @(cd ${currentDir}/host/docker && ./build.sh $(version) $(platform)) +.PHONY: build-server-docker + build-cli: ifeq ($(debug), true) @echo "==> building cli in dev mode" @@ -82,53 +91,6 @@ endif endif .PHONY: build-cli -## release -release-cli: clean build-cli -ifndef version - $(error version is required. Usage: make version=0.1.0 release-cli) -endif -ifndef GH - $(error please install github-cli) -endif - - @echo "==> releasing cli" - @${currentDir}/scripts/release.sh cli $(version) ${cliOutputDir} -.PHONY: release-cli - -release-cli-homebrew: -ifndef version - $(error version is required. Usage: make version=0.1.0 release-cli-homebrew) -endif - - @echo "==> releasing cli on Homebrew" - @${currentDir}/scripts/cli/release-homebrew.sh $(version) -.PHONY: release-cli - -release-server: -ifndef version - $(error version is required. Usage: make version=0.1.0 release-server) -endif -ifndef GH - $(error please install github-cli) -endif - - @echo "==> releasing server" - @${currentDir}/scripts/release.sh server $(version) ${serverOutputDir} - - @echo "==> building and releasing docker image" - @(cd ${currentDir}/host/docker && ./build.sh $(version)) - @(cd ${currentDir}/host/docker && ./release.sh $(version)) -.PHONY: release-server - -# migrations -create-migration: -ifndef filename - $(error filename is required. Usage: make filename=your-filename create-migration) -endif - - @(cd ${currentDir}/pkg/server/database && ./scripts/create-migration.sh $(filename)) -.PHONY: create-migration - clean: @git clean -f @rm -rf build diff --git a/host/docker/Dockerfile b/host/docker/Dockerfile index 88681591..e67da318 100644 --- a/host/docker/Dockerfile +++ b/host/docker/Dockerfile @@ -1,12 +1,30 @@ FROM busybox:glibc -ARG tarballName -RUN test -n "$tarballName" +ARG TARGETPLATFORM +ARG version -WORKDIR dnote +RUN test -n "$TARGETPLATFORM" || (echo "TARGETPLATFORM is required" && exit 1) +RUN test -n "$version" || (echo "version is required" && exit 1) -COPY "$tarballName" . -RUN tar -xvzf "$tarballName" +WORKDIR /tmp/tarballs + +# Copy all architecture tarballs +COPY dnote_server_*.tar.gz ./ + +# Select and extract the correct tarball based on target platform +RUN case "$TARGETPLATFORM" in \ + "linux/amd64") ARCH="amd64" ;; \ + "linux/arm64") ARCH="arm64" ;; \ + "linux/arm/v7") ARCH="arm" ;; \ + "linux/386") ARCH="386" ;; \ + *) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \ + esac && \ + TARBALL="dnote_server_${version}_linux_${ARCH}.tar.gz" && \ + echo "Extracting $TARBALL for $TARGETPLATFORM" && \ + mkdir -p /dnote && \ + tar -xvzf "$TARBALL" -C /dnote + +WORKDIR /dnote COPY entrypoint.sh . ENTRYPOINT ["./entrypoint.sh"] diff --git a/host/docker/build.sh b/host/docker/build.sh index 3ea9c143..add55578 100755 --- a/host/docker/build.sh +++ b/host/docker/build.sh @@ -1,13 +1,85 @@ #!/usr/bin/env bash +# Build Docker image for local testing +# +# Usage: +# # builds for host platform (auto-detected) +# ./build.sh 1.0.0 +# +# # builds arm64 +# ./build.sh 1.0.0 linux/arm64 +# +# # builds multiple platforms +# ./build.sh 1.0.0 "linux/amd64,linux/arm64,linux/arm/v7,linux/386" set -eux version=$1 +# Detect host platform if not specified +if [ -z "${2:-}" ]; then + HOST_ARCH=$(uname -m) + case "$HOST_ARCH" in + x86_64) platform="linux/amd64" ;; + aarch64|arm64) platform="linux/arm64" ;; + armv7l) platform="linux/arm/v7" ;; + i386|i686) platform="linux/386" ;; + *) + echo "Warning: Unsupported architecture: $HOST_ARCH, defaulting to linux/amd64" + platform="linux/amd64" + ;; + esac + echo "Auto-detected platform: $platform" +else + platform=$2 +fi + dir=$(dirname "${BASH_SOURCE[0]}") projectDir="$dir/../.." -tarballName="dnote_server_${version}_linux_amd64.tar.gz" -# copy over the build artifact to the Docker build context -cp "$projectDir/build/server/$tarballName" "$dir" +# Copy all Linux tarballs to Docker build context +cp "$projectDir/build/server/dnote_server_${version}_linux_amd64.tar.gz" "$dir/" +cp "$projectDir/build/server/dnote_server_${version}_linux_arm64.tar.gz" "$dir/" +cp "$projectDir/build/server/dnote_server_${version}_linux_arm.tar.gz" "$dir/" +cp "$projectDir/build/server/dnote_server_${version}_linux_386.tar.gz" "$dir/" -docker build --network=host -t dnote/dnote:"$version" --build-arg tarballName="$tarballName" . +# Count platforms (check for comma) +if [[ "$platform" == *","* ]]; then + echo "Building for multiple platforms: $platform" + + # Check if multiarch builder exists, create if not + if ! docker buildx ls | grep -q "multiarch"; then + echo "Creating multiarch builder for multi-platform builds..." + docker buildx create --name multiarch --use + docker buildx inspect --bootstrap + else + echo "Using existing multiarch builder" + docker buildx use multiarch + fi + echo "" + + docker buildx build \ + --platform "$platform" \ + -t dnote/dnote:"$version" \ + -t dnote/dnote:latest \ + --build-arg version="$version" \ + "$dir" + + # Switch back to default builder + docker buildx use default +else + echo "Building for single platform: $platform" + echo "Image will be loaded to local Docker daemon" + + docker buildx build \ + --platform "$platform" \ + -t dnote/dnote:"$version" \ + -t dnote/dnote:latest \ + --build-arg version="$version" \ + --load \ + "$dir" +fi + +echo "" +echo "Build complete!" +if [[ "$platform" != *","* ]]; then + echo "Test with: docker run --rm dnote/dnote:$version ./dnote-server version" +fi diff --git a/host/docker/release.sh b/host/docker/release.sh deleted file mode 100755 index 4c2be4af..00000000 --- a/host/docker/release.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -eux - -version=$1 - -docker login - -# tag the release -docker tag dnote/dnote:"$version" dnote/dnote:latest - -# publish -docker push dnote/dnote:"$version" -docker push dnote/dnote:latest diff --git a/scripts/cli/release-homebrew.sh b/scripts/cli/release-homebrew.sh deleted file mode 100755 index f48f16dc..00000000 --- a/scripts/cli/release-homebrew.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -set -eux - -currentDir=$(dirname "${BASH_SOURCE[0]}") -cliHomebrewDir=${currentDir}/../../homebrew-dnote - -if [ ! -d "$cliHomebrewDir" ]; then - echo "homebrew-dnote not found locally. Cloning." - git clone git@github.com:dnote/homebrew-dnote.git "$cliHomebrewDir" -fi - -version=$1 - -echo "version: $version" - -# Download source tarball and calculate SHA256 -source_url="https://github.com/dnote/dnote/archive/refs/tags/cli-v${version}.tar.gz" -echo "Calculating SHA256 for: $source_url" -sha=$(curl -L "$source_url" | shasum -a 256 | cut -d ' ' -f 1) - -pushd "$cliHomebrewDir" - -echo "pulling latest dnote-homebrew repo" -git checkout master -git pull origin master - -cat > ./Formula/dnote.rb << EOF -class Dnote < Formula - desc "Simple command line notebook for programmers" - homepage "https://www.getdnote.com" - url "https://github.com/dnote/dnote/archive/refs/tags/cli-v${version}.tar.gz" - sha256 "${sha}" - license "GPL-3.0" - head "https://github.com/dnote/dnote.git", branch: "master" - - depends_on "go" => :build - - def install - ldflags = "-s -w -X main.apiEndpoint=https://api.getdnote.com -X main.versionTag=#{version}" - system "go", "build", *std_go_args(ldflags: ldflags), "-tags", "fts5", "./pkg/cli" - end - - test do - system "#{bin}/dnote", "version" - end -end -EOF - -git add . -git commit --author="Bot " -m "Release ${version}" -git push origin master - -popd diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index 3cda5897..00000000 --- a/scripts/release.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash -# -# release.sh releases the tarballs and checksum in the build directory -# to GitHub and brew. A prerequisite is to build those files using build.sh. -# use: ./scripts/release.sh cli v0.4.8 path/to/assets - -set -euxo pipefail - -project=$1 -version=$2 -assetPath=$3 - -if [ "$project" != "cli" ] && [ "$project" != "server" ]; then - echo "unrecognized project '$project'" - exit 1 -fi -if [ -z "$version" ]; then - echo "no version specified." - exit 1 -fi -if [[ $version == v* ]]; then - echo "do not prefix version with v" - exit 1 -fi - -# 1. push tag -version_tag="$project-v$version" - -echo "* tagging and pushing the tag" -git tag -a "$version_tag" -m "Release $version_tag" -git push --tags - -# 2. release on GitHub -files=("$assetPath"/*) -file_flags=() -for file in "${files[@]}"; do - file_flags+=("$file") -done - -# mark as prerelease if version is not in a form of major.minor.patch -# e.g. 1.0.1-beta.1 -flags=() -if [[ ! "$version" =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then - flags+=("--prerelease") -fi - -echo "* creating release" -set -x - -# Create release -gh release create \ - "$version_tag" \ - "${file_flags[@]}" \ - "${flags[@]}" \ - --title="$version_tag"\ - --notes="Please see the [CHANGELOG](https://github.com/dnote/dnote/blob/master/CHANGELOG.md)" \ - --draft diff --git a/scripts/server/build.sh b/scripts/server/build.sh index a4e24df5..8ee95164 100755 --- a/scripts/server/build.sh +++ b/scripts/server/build.sh @@ -74,3 +74,6 @@ go install src.techknowlogick.com/xgo@latest build linux amd64 build linux arm64 +build linux arm +build linux 386 +build freebsd amd64 From 505fc679660d44a55777f05ffd504e9f83804cbd Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 14:57:29 -0700 Subject: [PATCH 16/33] Fix server release for freebsd (#698) --- scripts/server/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/server/build.sh b/scripts/server/build.sh index 8ee95164..f9c6428e 100755 --- a/scripts/server/build.sh +++ b/scripts/server/build.sh @@ -51,7 +51,7 @@ build() { popd - mv "$destDir/server-${platform}-"* "$destDir/dnote-server" + mv "$destDir/server-${platform}"* "$destDir/dnote-server" # build tarball tarballName="dnote_server_${version}_${platform}_${arch}.tar.gz" From 83ac43b737f9351eb0cf0af4220d34ad2fa0bd04 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 15:38:52 -0700 Subject: [PATCH 17/33] Specify DBPath for docker (#699) --- host/docker/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/host/docker/Dockerfile b/host/docker/Dockerfile index e67da318..71b3d1fa 100644 --- a/host/docker/Dockerfile +++ b/host/docker/Dockerfile @@ -26,6 +26,9 @@ RUN case "$TARGETPLATFORM" in \ WORKDIR /dnote +# Set default database path for all processes (main server, docker exec, shells) +ENV DBPath=/data/dnote.db + COPY entrypoint.sh . ENTRYPOINT ["./entrypoint.sh"] From b03ca999a52f0dcbd4be2c560af76ae7487fdf5d Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 18:32:20 -0700 Subject: [PATCH 18/33] Remove the unused encrypted and public fields (#700) * Remove encrypted fields from notes and books * Remove public from notes * Use consistent flags --- pkg/cli/cmd/sync/sync.go | 3 +- pkg/cli/crypt/crypto.go | 123 -------------- pkg/cli/crypt/crypto_test.go | 118 ------------- pkg/e2e/server_test.go | 30 +++- pkg/server/app/books.go | 13 +- pkg/server/app/notes.go | 53 ++---- pkg/server/app/notes_test.go | 49 +++--- pkg/server/cmd/helpers.go | 25 ++- pkg/server/controllers/books.go | 11 -- pkg/server/controllers/notes.go | 27 +-- pkg/server/controllers/notes_test.go | 185 ++------------------- pkg/server/controllers/routes.go | 2 +- pkg/server/controllers/sync.go | 2 - pkg/server/database/models.go | 3 - pkg/server/middleware/auth.go | 6 +- pkg/server/middleware/auth_test.go | 34 ++++ pkg/server/operations/notes_test.go | 51 ++---- pkg/server/permissions/permissions.go | 3 - pkg/server/permissions/permissions_test.go | 44 +---- pkg/server/presenters/note.go | 2 - pkg/server/presenters/note_test.go | 4 - pkg/server/tmpl/app_test.go | 40 ----- 22 files changed, 175 insertions(+), 653 deletions(-) delete mode 100644 pkg/cli/crypt/crypto.go delete mode 100644 pkg/cli/crypt/crypto_test.go diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index 28ec71a7..ec66a2cb 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -97,8 +97,7 @@ func (l syncList) getLength() int { return len(l.Notes) + len(l.Books) + len(l.ExpungedNotes) + len(l.ExpungedBooks) } -// processFragments categorizes items in sync fragments into a sync list. It also decrypts any -// encrypted data in sync fragments. +// processFragments categorizes items in sync fragments into a sync list. func processFragments(fragments []client.SyncFragment) (syncList, error) { notes := map[string]client.SyncFragNote{} books := map[string]client.SyncFragBook{} diff --git a/pkg/cli/crypt/crypto.go b/pkg/cli/crypt/crypto.go deleted file mode 100644 index 3637c7ca..00000000 --- a/pkg/cli/crypt/crypto.go +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . - */ - -// Package crypt provides cryptographic funcitonalities -package crypt - -import ( - "crypto/aes" - "crypto/cipher" - "crypto/rand" - "crypto/sha256" - "encoding/base64" - "io" - - "github.com/pkg/errors" - "golang.org/x/crypto/hkdf" - "golang.org/x/crypto/pbkdf2" -) - -var aesGcmNonceSize = 12 - -func runHkdf(secret, salt, info []byte) ([]byte, error) { - r := hkdf.New(sha256.New, secret, salt, info) - - ret := make([]byte, 32) - _, err := io.ReadFull(r, ret) - if err != nil { - return []byte{}, errors.Wrap(err, "reading key bytes") - } - - return ret, nil -} - -// MakeKeys derives, from the given credential, a key set comprising of an encryption key -// and an authentication key -func MakeKeys(password, email []byte, iteration int) ([]byte, []byte, error) { - masterKey := pbkdf2.Key([]byte(password), []byte(email), iteration, 32, sha256.New) - - authKey, err := runHkdf(masterKey, email, []byte("auth")) - if err != nil { - return nil, nil, errors.Wrap(err, "deriving auth key") - } - - return masterKey, authKey, nil -} - -// AesGcmEncrypt encrypts the plaintext using AES in a GCM mode. It returns -// a ciphertext prepended by a 12 byte pseudo-random nonce, encoded in base64. -func AesGcmEncrypt(key, plaintext []byte) (string, error) { - if key == nil { - return "", errors.New("no key provided") - } - - block, err := aes.NewCipher(key) - if err != nil { - return "", errors.Wrap(err, "initializing aes") - } - - aesgcm, err := cipher.NewGCM(block) - if err != nil { - return "", errors.Wrap(err, "initializing gcm") - } - - nonce := make([]byte, aesGcmNonceSize) - if _, err := io.ReadFull(rand.Reader, nonce); err != nil { - return "", errors.Wrap(err, "generating nonce") - } - - ciphertext := aesgcm.Seal(nonce, nonce, []byte(plaintext), nil) - cipherKeyB64 := base64.StdEncoding.EncodeToString(ciphertext) - - return cipherKeyB64, nil -} - -// AesGcmDecrypt decrypts the encrypted data using AES in a GCM mode. The data should be -// a base64 encoded string in the format of 12 byte nonce followed by a ciphertext. -func AesGcmDecrypt(key []byte, dataB64 string) ([]byte, error) { - if key == nil { - return nil, errors.New("no key provided") - } - - data, err := base64.StdEncoding.DecodeString(dataB64) - if err != nil { - return nil, errors.Wrap(err, "decoding base64 data") - } - - block, err := aes.NewCipher(key) - if err != nil { - return nil, errors.Wrap(err, "initializing aes") - } - - aesgcm, err := cipher.NewGCM(block) - if err != nil { - return nil, errors.Wrap(err, "initializing gcm") - } - - if len(data) < aesGcmNonceSize { - return nil, errors.Wrap(err, "malformed data") - } - - nonce, ciphertext := data[:aesGcmNonceSize], data[aesGcmNonceSize:] - plaintext, err := aesgcm.Open(nil, nonce, ciphertext, nil) - if err != nil { - return nil, errors.Wrap(err, "decrypting") - } - - return plaintext, nil -} diff --git a/pkg/cli/crypt/crypto_test.go b/pkg/cli/crypt/crypto_test.go deleted file mode 100644 index 805e2724..00000000 --- a/pkg/cli/crypt/crypto_test.go +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . - */ - -package crypt - -import ( - "crypto/aes" - "crypto/cipher" - "encoding/base64" - "fmt" - "testing" - - "github.com/dnote/dnote/pkg/assert" - "github.com/pkg/errors" -) - -func TestAesGcmEncrypt(t *testing.T) { - testCases := []struct { - key []byte - plaintext []byte - }{ - { - key: []byte("AES256Key-32Characters1234567890"), - plaintext: []byte("foo bar baz quz"), - }, - { - key: []byte("AES256Key-32Charactersabcdefghij"), - plaintext: []byte("1234 foo 5678 bar 7890 baz"), - }, - } - - for _, tc := range testCases { - t.Run(fmt.Sprintf("key %s plaintext %s", tc.key, tc.plaintext), func(t *testing.T) { - // encrypt - dataB64, err := AesGcmEncrypt(tc.key, tc.plaintext) - if err != nil { - t.Fatal(errors.Wrap(err, "performing encryption")) - } - - // test that data can be decrypted - data, err := base64.StdEncoding.DecodeString(dataB64) - if err != nil { - t.Fatal(errors.Wrap(err, "decoding data from base64")) - } - - nonce, ciphertext := data[:12], data[12:] - - fmt.Println(string(data)) - - block, err := aes.NewCipher([]byte(tc.key)) - if err != nil { - t.Fatal(errors.Wrap(err, "initializing aes")) - } - - aesgcm, err := cipher.NewGCM(block) - if err != nil { - t.Fatal(errors.Wrap(err, "initializing gcm")) - } - - plaintext, err := aesgcm.Open(nil, nonce, ciphertext, nil) - if err != nil { - t.Fatal(errors.Wrap(err, "decode")) - } - - assert.DeepEqual(t, plaintext, tc.plaintext, "plaintext mismatch") - }) - } -} - -func TestAesGcmDecrypt(t *testing.T) { - testCases := []struct { - key []byte - ciphertextB64 string - expectedPlaintext string - }{ - { - key: []byte("AES256Key-32Characters1234567890"), - ciphertextB64: "M2ov9hWMQ52v1S/zigwX3bJt4cVCV02uiRm/grKqN/rZxNkJrD7vK4Ii0g==", - expectedPlaintext: "foo bar baz quz", - }, - { - key: []byte("AES256Key-32Characters1234567890"), - ciphertextB64: "M4csFKUIUbD1FBEzLgHjscoKgN0lhMGJ0n2nKWiCkE/qSKlRP7kS", - expectedPlaintext: "foo\n1\nbar\n2", - }, - { - key: []byte("AES256Key-32Characters1234567890"), - ciphertextB64: "pe/fnw73MR1clmVIlRSJ5gDwBdnPly/DF7DsR5dJVz4dHZlv0b10WzvJEGOCHZEr+Q==", - expectedPlaintext: "föo\nbār\nbåz & qūz", - }, - } - - for _, tc := range testCases { - t.Run(fmt.Sprintf("key %s ciphertext %s", tc.key, tc.ciphertextB64), func(t *testing.T) { - plaintext, err := AesGcmDecrypt(tc.key, tc.ciphertextB64) - if err != nil { - t.Fatal(errors.Wrap(err, "performing decryption")) - } - - assert.DeepEqual(t, plaintext, []byte(tc.expectedPlaintext), "plaintext mismatch") - }) - } -} diff --git a/pkg/e2e/server_test.go b/pkg/e2e/server_test.go index cfe6a711..39da46de 100644 --- a/pkg/e2e/server_test.go +++ b/pkg/e2e/server_test.go @@ -50,7 +50,7 @@ func TestServerStart(t *testing.T) { port := "13456" // Use different port to avoid conflicts with main test server // Start server in background - cmd := exec.Command(testServerBinary, "start", "-port", port) + cmd := exec.Command(testServerBinary, "start", "--port", port) cmd.Env = append(os.Environ(), "DBPath="+tmpDB, "WebURL=http://localhost:"+port, @@ -143,11 +143,11 @@ func TestServerStartHelp(t *testing.T) { outputStr := string(output) assert.Equal(t, strings.Contains(outputStr, "dnote-server start [flags]"), true, "output should contain usage") - assert.Equal(t, strings.Contains(outputStr, "-appEnv"), true, "output should contain appEnv flag") - assert.Equal(t, strings.Contains(outputStr, "-port"), true, "output should contain port flag") - assert.Equal(t, strings.Contains(outputStr, "-webUrl"), true, "output should contain webUrl flag") - assert.Equal(t, strings.Contains(outputStr, "-dbPath"), true, "output should contain dbPath flag") - assert.Equal(t, strings.Contains(outputStr, "-disableRegistration"), true, "output should contain disableRegistration flag") + assert.Equal(t, strings.Contains(outputStr, "--appEnv"), true, "output should contain appEnv flag") + assert.Equal(t, strings.Contains(outputStr, "--port"), true, "output should contain port flag") + assert.Equal(t, strings.Contains(outputStr, "--webUrl"), true, "output should contain webUrl flag") + assert.Equal(t, strings.Contains(outputStr, "--dbPath"), true, "output should contain dbPath flag") + assert.Equal(t, strings.Contains(outputStr, "--disableRegistration"), true, "output should contain disableRegistration flag") } func TestServerStartInvalidConfig(t *testing.T) { @@ -166,7 +166,7 @@ func TestServerStartInvalidConfig(t *testing.T) { assert.Equal(t, strings.Contains(outputStr, "Error:"), true, "output should contain error message") assert.Equal(t, strings.Contains(outputStr, "Invalid WebURL"), true, "output should mention invalid WebURL") assert.Equal(t, strings.Contains(outputStr, "dnote-server start [flags]"), true, "output should show usage") - assert.Equal(t, strings.Contains(outputStr, "-webUrl"), true, "output should show flags") + assert.Equal(t, strings.Contains(outputStr, "--webUrl"), true, "output should show flags") } func TestServerUnknownCommand(t *testing.T) { @@ -321,3 +321,19 @@ func TestServerUserRemove(t *testing.T) { db.Table("users").Count(&count) assert.Equal(t, count, int64(0), "should have 0 users after removal") } + +func TestServerUserCreateHelp(t *testing.T) { + cmd := exec.Command(testServerBinary, "user", "create", "--help") + output, err := cmd.CombinedOutput() + + if err != nil { + t.Fatalf("help command failed: %v\nOutput: %s", err, output) + } + + outputStr := string(output) + + // Verify help shows double-dash flags for consistency with CLI + assert.Equal(t, strings.Contains(outputStr, "--email"), true, "help should show --email (double dash)") + assert.Equal(t, strings.Contains(outputStr, "--password"), true, "help should show --password (double dash)") + assert.Equal(t, strings.Contains(outputStr, "--dbPath"), true, "help should show --dbPath (double dash)") +} diff --git a/pkg/server/app/books.go b/pkg/server/app/books.go index c3b89ec0..a476a0c4 100644 --- a/pkg/server/app/books.go +++ b/pkg/server/app/books.go @@ -41,12 +41,11 @@ func (a *App) CreateBook(user database.User, name string) (database.Book, error) } book := database.Book{ - UUID: uuid, - UserID: user.ID, - Label: name, - AddedOn: a.Clock.Now().UnixNano(), - USN: nextUSN, - Encrypted: false, + UUID: uuid, + UserID: user.ID, + Label: name, + AddedOn: a.Clock.Now().UnixNano(), + USN: nextUSN, } if err := tx.Create(&book).Error; err != nil { tx.Rollback() @@ -99,8 +98,6 @@ func (a *App) UpdateBook(tx *gorm.DB, user database.User, book database.Book, la book.USN = nextUSN book.EditedOn = a.Clock.Now().UnixNano() book.Deleted = false - // TODO: remove after all users have been migrated - book.Encrypted = false if err := tx.Save(&book).Error; err != nil { return book, errors.Wrap(err, "updating the book") diff --git a/pkg/server/app/notes.go b/pkg/server/app/notes.go index 7773953d..e9f6f60b 100644 --- a/pkg/server/app/notes.go +++ b/pkg/server/app/notes.go @@ -30,7 +30,7 @@ import ( // CreateNote creates a note with the next usn and updates the user's max_usn. // It returns the created note. -func (a *App) CreateNote(user database.User, bookUUID, content string, addedOn *int64, editedOn *int64, public bool, client string) (database.Note, error) { +func (a *App) CreateNote(user database.User, bookUUID, content string, addedOn *int64, editedOn *int64, client string) (database.Note, error) { tx := a.DB.Begin() nextUSN, err := incrementUserUSN(tx, user.ID) @@ -59,16 +59,14 @@ func (a *App) CreateNote(user database.User, bookUUID, content string, addedOn * } note := database.Note{ - UUID: uuid, - BookUUID: bookUUID, - UserID: user.ID, - AddedOn: noteAddedOn, - EditedOn: noteEditedOn, - USN: nextUSN, - Body: content, - Public: public, - Encrypted: false, - Client: client, + UUID: uuid, + BookUUID: bookUUID, + UserID: user.ID, + AddedOn: noteAddedOn, + EditedOn: noteEditedOn, + USN: nextUSN, + Body: content, + Client: client, } if err := tx.Create(¬e).Error; err != nil { tx.Rollback() @@ -84,7 +82,6 @@ func (a *App) CreateNote(user database.User, bookUUID, content string, addedOn * type UpdateNoteParams struct { BookUUID *string Content *string - Public *bool } // GetBookUUID gets the bookUUID from the UpdateNoteParams @@ -105,15 +102,6 @@ func (r UpdateNoteParams) GetContent() string { return *r.Content } -// GetPublic gets the public field from the UpdateNoteParams -func (r UpdateNoteParams) GetPublic() bool { - if r.Public == nil { - return false - } - - return *r.Public -} - // UpdateNote creates a note with the next usn and updates the user's max_usn func (a *App) UpdateNote(tx *gorm.DB, user database.User, note database.Note, p *UpdateNoteParams) (database.Note, error) { nextUSN, err := incrementUserUSN(tx, user.ID) @@ -127,15 +115,10 @@ func (a *App) UpdateNote(tx *gorm.DB, user database.User, note database.Note, p if p.Content != nil { note.Body = p.GetContent() } - if p.Public != nil { - note.Public = p.GetPublic() - } note.USN = nextUSN note.EditedOn = a.Clock.Now().UnixNano() note.Deleted = false - // TODO: remove after all users are migrated - note.Encrypted = false if err := tx.Save(¬e).Error; err != nil { return note, pkgErrors.Wrap(err, "editing note") @@ -180,13 +163,12 @@ func (a *App) GetUserNoteByUUID(userID int, uuid string) (*database.Note, error) // GetNotesParams is params for finding notes type GetNotesParams struct { - Year int - Month int - Page int - Books []string - Search string - Encrypted bool - PerPage int + Year int + Month int + Page int + Books []string + Search string + PerPage int } type ftsParams struct { @@ -215,14 +197,13 @@ notes.added_on, notes.edited_on, notes.usn, notes.deleted, -notes.encrypted, ` + bodyExpr) } func getNotesBaseQuery(db *gorm.DB, userID int, q GetNotesParams) *gorm.DB { conn := db.Where( - "notes.user_id = ? AND notes.deleted = ? AND notes.encrypted = ?", - userID, false, q.Encrypted, + "notes.user_id = ? AND notes.deleted = ?", + userID, false, ) if q.Search != "" { diff --git a/pkg/server/app/notes_test.go b/pkg/server/app/notes_test.go index 7813c54b..42a0bd8a 100644 --- a/pkg/server/app/notes_test.go +++ b/pkg/server/app/notes_test.go @@ -91,7 +91,7 @@ func TestCreateNote(t *testing.T) { a.DB = db a.Clock = mockClock - if _, err := a.CreateNote(user, b1.UUID, "note content", tc.addedOn, tc.editedOn, false, ""); err != nil { + if _, err := a.CreateNote(user, b1.UUID, "note content", tc.addedOn, tc.editedOn, ""); err != nil { t.Fatal(errors.Wrapf(err, "creating note for test case %d", idx)) } @@ -139,7 +139,7 @@ func TestCreateNote_EmptyBody(t *testing.T) { a.Clock = clock.NewMock() // Create note with empty body - note, err := a.CreateNote(user, b1.UUID, "", nil, nil, false, "") + note, err := a.CreateNote(user, b1.UUID, "", nil, nil, "") if err != nil { t.Fatal(errors.Wrap(err, "creating note with empty body")) } @@ -188,7 +188,6 @@ func TestUpdateNote(t *testing.T) { c := clock.NewMock() content := "updated test content" - public := true a := NewTest() a.DB = db @@ -197,7 +196,6 @@ func TestUpdateNote(t *testing.T) { tx := db.Begin() if _, err := a.UpdateNote(tx, user, note, &UpdateNoteParams{ Content: &content, - Public: &public, }); err != nil { tx.Rollback() t.Fatal(errors.Wrap(err, "updating note")) @@ -218,7 +216,6 @@ func TestUpdateNote(t *testing.T) { assert.Equal(t, noteCount, int64(1), "note count mismatch") assert.Equal(t, noteRecord.UserID, user.ID, "note UserID mismatch") assert.Equal(t, noteRecord.Body, content, "note Body mismatch") - assert.Equal(t, noteRecord.Public, public, "note Public mismatch") assert.Equal(t, noteRecord.Deleted, false, "note Deleted mismatch") assert.Equal(t, noteRecord.USN, expectedUSN, "note USN mismatch") assert.Equal(t, userRecord.MaxUSN, expectedUSN, "user MaxUSN mismatch") @@ -374,10 +371,9 @@ func TestGetNotes_FTSSearch(t *testing.T) { // Search "baz" result, err := a.GetNotes(user.ID, GetNotesParams{ - Search: "baz", - Encrypted: false, - Page: 1, - PerPage: 30, + Search: "baz", + Page: 1, + PerPage: 30, }) if err != nil { t.Fatal(errors.Wrap(err, "getting notes with FTS search")) @@ -390,10 +386,9 @@ func TestGetNotes_FTSSearch(t *testing.T) { // Search for "running" - should return 1 note result, err = a.GetNotes(user.ID, GetNotesParams{ - Search: "running", - Encrypted: false, - Page: 1, - PerPage: 30, + Search: "running", + Page: 1, + PerPage: 30, }) if err != nil { t.Fatal(errors.Wrap(err, "getting notes with FTS search for review")) @@ -405,10 +400,9 @@ func TestGetNotes_FTSSearch(t *testing.T) { // Search for non-existent term - should return 0 notes result, err = a.GetNotes(user.ID, GetNotesParams{ - Search: "nonexistent", - Encrypted: false, - Page: 1, - PerPage: 30, + Search: "nonexistent", + Page: 1, + PerPage: 30, }) if err != nil { t.Fatal(errors.Wrap(err, "getting notes with FTS search for nonexistent")) @@ -437,10 +431,9 @@ func TestGetNotes_FTSSearch_Snippet(t *testing.T) { // Search for "keyword" in long note - should return snippet with "..." result, err := a.GetNotes(user.ID, GetNotesParams{ - Search: "keyword", - Encrypted: false, - Page: 1, - PerPage: 30, + Search: "keyword", + Page: 1, + PerPage: 30, }) if err != nil { t.Fatal(errors.Wrap(err, "getting notes with FTS search for keyword")) @@ -472,10 +465,9 @@ func TestGetNotes_FTSSearch_ShortWord(t *testing.T) { a.Clock = clock.NewMock() result, err := a.GetNotes(user.ID, GetNotesParams{ - Search: "a", - Encrypted: false, - Page: 1, - PerPage: 30, + Search: "a", + Page: 1, + PerPage: 30, }) if err != nil { t.Fatal(errors.Wrap(err, "getting notes with FTS search for 'a'")) @@ -504,10 +496,9 @@ func TestGetNotes_All(t *testing.T) { a.Clock = clock.NewMock() result, err := a.GetNotes(user.ID, GetNotesParams{ - Search: "", - Encrypted: false, - Page: 1, - PerPage: 30, + Search: "", + Page: 1, + PerPage: 30, }) if err != nil { t.Fatal(errors.Wrap(err, "getting notes with FTS search for 'a'")) diff --git a/pkg/server/cmd/helpers.go b/pkg/server/cmd/helpers.go index a22c8721..eb58c318 100644 --- a/pkg/server/cmd/helpers.go +++ b/pkg/server/cmd/helpers.go @@ -65,6 +65,29 @@ func initApp(cfg config.Config) app.App { } } +// printFlags prints flags with -- prefix for consistency with CLI +func printFlags(fs *flag.FlagSet) { + fs.VisitAll(func(f *flag.Flag) { + fmt.Printf(" --%s", f.Name) + + // Print type hint for non-boolean flags + name, usage := flag.UnquoteUsage(f) + if name != "" { + fmt.Printf(" %s", name) + } + fmt.Println() + + // Print usage description with indentation + if usage != "" { + fmt.Printf(" \t%s", usage) + if f.DefValue != "" && f.DefValue != "false" { + fmt.Printf(" (default: %s)", f.DefValue) + } + fmt.Println() + } + }) +} + // setupFlagSet creates a FlagSet with standard usage format func setupFlagSet(name, usageCmd string) *flag.FlagSet { fs := flag.NewFlagSet(name, flag.ExitOnError) @@ -74,7 +97,7 @@ func setupFlagSet(name, usageCmd string) *flag.FlagSet { Flags: `, usageCmd) - fs.PrintDefaults() + printFlags(fs) } return fs } diff --git a/pkg/server/controllers/books.go b/pkg/server/controllers/books.go index e2aa6de0..1b4f3810 100644 --- a/pkg/server/controllers/books.go +++ b/pkg/server/controllers/books.go @@ -56,22 +56,11 @@ func (b *Books) getBooks(r *http.Request) ([]database.Book, error) { query := r.URL.Query() name := query.Get("name") - encryptedStr := query.Get("encrypted") if name != "" { part := fmt.Sprintf("%%%s%%", name) conn = conn.Where("LOWER(label) LIKE ?", part) } - if encryptedStr != "" { - var encrypted bool - if encryptedStr == "true" { - encrypted = true - } else { - encrypted = false - } - - conn = conn.Where("encrypted = ?", encrypted) - } var books []database.Book if err := conn.Find(&books).Error; err != nil { diff --git a/pkg/server/controllers/notes.go b/pkg/server/controllers/notes.go index a7434366..dd34a78d 100644 --- a/pkg/server/controllers/notes.go +++ b/pkg/server/controllers/notes.go @@ -73,7 +73,6 @@ func parseGetNotesQuery(q url.Values) (app.GetNotesParams, error) { yearStr := q.Get("year") monthStr := q.Get("month") books := q["book"] - encryptedStr := q.Get("encrypted") pageStr := q.Get("page") page, err := parsePageQuery(q) @@ -107,21 +106,13 @@ func parseGetNotesQuery(q url.Values) (app.GetNotesParams, error) { month = m } - var encrypted bool - if strings.ToLower(encryptedStr) == "true" { - encrypted = true - } else { - encrypted = false - } - ret := app.GetNotesParams{ - Year: year, - Month: month, - Page: page, - Search: parseSearchQuery(q), - Books: books, - Encrypted: encrypted, - PerPage: notesPerPage, + Year: year, + Month: month, + Page: page, + Search: parseSearchQuery(q), + Books: books, + PerPage: notesPerPage, } return ret, nil @@ -231,7 +222,7 @@ func (n *Notes) create(r *http.Request) (database.Note, error) { } client := getClientType(r) - note, err := n.app.CreateNote(*user, params.BookUUID, params.Content, params.AddedOn, params.EditedOn, false, client) + note, err := n.app.CreateNote(*user, params.BookUUID, params.Content, params.AddedOn, params.EditedOn, client) if err != nil { return database.Note{}, errors.Wrap(err, "creating note") } @@ -310,11 +301,10 @@ func (n *Notes) V3Delete(w http.ResponseWriter, r *http.Request) { type updateNotePayload struct { BookUUID *string `schema:"book_uuid" json:"book_uuid"` Content *string `schema:"content" json:"content"` - Public *bool `schema:"public" json:"public"` } func validateUpdateNotePayload(p updateNotePayload) error { - if p.BookUUID == nil && p.Content == nil && p.Public == nil { + if p.BookUUID == nil && p.Content == nil { return app.ErrEmptyUpdate } @@ -350,7 +340,6 @@ func (n *Notes) update(r *http.Request) (database.Note, error) { note, err = n.app.UpdateNote(tx, *user, note, &app.UpdateNoteParams{ BookUUID: params.BookUUID, Content: params.Content, - Public: params.Public, }) if err != nil { tx.Rollback() diff --git a/pkg/server/controllers/notes_test.go b/pkg/server/controllers/notes_test.go index 6bf3c06b..ce3f20c7 100644 --- a/pkg/server/controllers/notes_test.go +++ b/pkg/server/controllers/notes_test.go @@ -42,7 +42,6 @@ func getExpectedNotePayload(n database.Note, b database.Book, u database.User) p UpdatedAt: truncateMicro(n.UpdatedAt), Body: n.Body, AddedOn: n.AddedOn, - Public: n.Public, USN: n.USN, Book: presenters.NoteBook{ UUID: b.UUID, @@ -189,7 +188,9 @@ func TestGetNote(t *testing.T) { defer server.Close() user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "user@test.com", "pass1234") anotherUser := testutils.SetupUserData(db) + testutils.SetupAccountData(db, anotherUser, "another@test.com", "pass1234") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -198,22 +199,13 @@ func TestGetNote(t *testing.T) { } testutils.MustExec(t, db.Save(&b1), "preparing b1") - privateNote := database.Note{ + note := database.Note{ UUID: testutils.MustUUID(t), UserID: user.ID, BookUUID: b1.UUID, - Body: "privateNote content", - Public: false, + Body: "note content", } - testutils.MustExec(t, db.Save(&privateNote), "preparing privateNote") - publicNote := database.Note{ - UUID: testutils.MustUUID(t), - UserID: user.ID, - BookUUID: b1.UUID, - Body: "publicNote content", - Public: true, - } - testutils.MustExec(t, db.Save(&publicNote), "preparing publicNote") + testutils.MustExec(t, db.Save(¬e), "preparing note") deletedNote := database.Note{ UUID: testutils.MustUUID(t), UserID: user.ID, @@ -226,9 +218,9 @@ func TestGetNote(t *testing.T) { return fmt.Sprintf("/api/v3/notes/%s", noteUUID) } - t.Run("owner accessing private note", func(t *testing.T) { + t.Run("owner accessing note", func(t *testing.T) { // Execute - url := getURL(publicNote.UUID) + url := getURL(note.UUID) req := testutils.MakeReq(server.URL, "GET", url, "") res := testutils.HTTPAuthDo(t, db, req, user) @@ -240,58 +232,16 @@ func TestGetNote(t *testing.T) { t.Fatal(errors.Wrap(err, "decoding payload")) } - var n2Record database.Note - testutils.MustExec(t, db.Where("uuid = ?", publicNote.UUID).First(&n2Record), "finding n2Record") + var noteRecord database.Note + testutils.MustExec(t, db.Where("uuid = ?", note.UUID).First(¬eRecord), "finding noteRecord") - expected := getExpectedNotePayload(n2Record, b1, user) + expected := getExpectedNotePayload(noteRecord, b1, user) assert.DeepEqual(t, payload, expected, "payload mismatch") }) - t.Run("owner accessing public note", func(t *testing.T) { + t.Run("non-owner accessing note", func(t *testing.T) { // Execute - url := getURL(publicNote.UUID) - req := testutils.MakeReq(server.URL, "GET", url, "") - res := testutils.HTTPAuthDo(t, db, req, user) - - // Test - assert.StatusCodeEquals(t, res, http.StatusOK, "") - - var payload presenters.Note - if err := json.NewDecoder(res.Body).Decode(&payload); err != nil { - t.Fatal(errors.Wrap(err, "decoding payload")) - } - - var n2Record database.Note - testutils.MustExec(t, db.Where("uuid = ?", publicNote.UUID).First(&n2Record), "finding n2Record") - - expected := getExpectedNotePayload(n2Record, b1, user) - assert.DeepEqual(t, payload, expected, "payload mismatch") - }) - - t.Run("non-owner accessing public note", func(t *testing.T) { - // Execute - url := getURL(publicNote.UUID) - req := testutils.MakeReq(server.URL, "GET", url, "") - res := testutils.HTTPAuthDo(t, db, req, anotherUser) - - // Test - assert.StatusCodeEquals(t, res, http.StatusOK, "") - - var payload presenters.Note - if err := json.NewDecoder(res.Body).Decode(&payload); err != nil { - t.Fatal(errors.Wrap(err, "decoding payload")) - } - - var n2Record database.Note - testutils.MustExec(t, db.Where("uuid = ?", publicNote.UUID).First(&n2Record), "finding n2Record") - - expected := getExpectedNotePayload(n2Record, b1, user) - assert.DeepEqual(t, payload, expected, "payload mismatch") - }) - - t.Run("non-owner accessing private note", func(t *testing.T) { - // Execute - url := getURL(privateNote.UUID) + url := getURL(note.UUID) req := testutils.MakeReq(server.URL, "GET", url, "") res := testutils.HTTPAuthDo(t, db, req, anotherUser) @@ -306,42 +256,21 @@ func TestGetNote(t *testing.T) { assert.DeepEqual(t, string(body), "not found\n", "payload mismatch") }) - t.Run("guest accessing public note", func(t *testing.T) { + t.Run("guest accessing note", func(t *testing.T) { // Execute - url := getURL(publicNote.UUID) + url := getURL(note.UUID) req := testutils.MakeReq(server.URL, "GET", url, "") res := testutils.HTTPDo(t, req) // Test - assert.StatusCodeEquals(t, res, http.StatusOK, "") - - var payload presenters.Note - if err := json.NewDecoder(res.Body).Decode(&payload); err != nil { - t.Fatal(errors.Wrap(err, "decoding payload")) - } - - var n2Record database.Note - testutils.MustExec(t, db.Where("uuid = ?", publicNote.UUID).First(&n2Record), "finding n2Record") - - expected := getExpectedNotePayload(n2Record, b1, user) - assert.DeepEqual(t, payload, expected, "payload mismatch") - }) - - t.Run("guest accessing private note", func(t *testing.T) { - // Execute - url := getURL(privateNote.UUID) - req := testutils.MakeReq(server.URL, "GET", url, "") - res := testutils.HTTPDo(t, req) - - // Test - assert.StatusCodeEquals(t, res, http.StatusNotFound, "") + assert.StatusCodeEquals(t, res, http.StatusUnauthorized, "") body, err := io.ReadAll(res.Body) if err != nil { t.Fatal(errors.Wrap(err, "reading body")) } - assert.DeepEqual(t, string(body), "not found\n", "payload mismatch") + assert.DeepEqual(t, string(body), "unauthorized\n", "payload mismatch") }) t.Run("nonexistent", func(t *testing.T) { @@ -533,7 +462,6 @@ func TestUpdateNote(t *testing.T) { type payloadData struct { Content *string `schema:"content" json:"content,omitempty"` BookUUID *string `schema:"book_uuid" json:"book_uuid,omitempty"` - Public *bool `schema:"public" json:"public,omitempty"` } testCases := []struct { @@ -541,12 +469,10 @@ func TestUpdateNote(t *testing.T) { noteUUID string noteBookUUID string noteBody string - notePublic bool noteDeleted bool expectedNoteBody string expectedNoteBookName string expectedNoteBookUUID string - expectedNotePublic bool }{ { payload: testutils.PayloadWrapper{ @@ -556,13 +482,11 @@ func TestUpdateNote(t *testing.T) { }, noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", noteBookUUID: b1UUID, - notePublic: false, noteBody: "original content", noteDeleted: false, expectedNoteBookUUID: b1UUID, expectedNoteBody: "some updated content", expectedNoteBookName: "css", - expectedNotePublic: false, }, { payload: testutils.PayloadWrapper{ @@ -572,13 +496,11 @@ func TestUpdateNote(t *testing.T) { }, noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", noteBookUUID: b1UUID, - notePublic: false, noteBody: "original content", noteDeleted: false, expectedNoteBookUUID: b1UUID, expectedNoteBody: "original content", expectedNoteBookName: "css", - expectedNotePublic: false, }, { payload: testutils.PayloadWrapper{ @@ -588,13 +510,11 @@ func TestUpdateNote(t *testing.T) { }, noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", noteBookUUID: b1UUID, - notePublic: false, noteBody: "original content", noteDeleted: false, expectedNoteBookUUID: b2UUID, expectedNoteBody: "original content", expectedNoteBookName: "js", - expectedNotePublic: false, }, { payload: testutils.PayloadWrapper{ @@ -605,13 +525,11 @@ func TestUpdateNote(t *testing.T) { }, noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", noteBookUUID: b1UUID, - notePublic: false, noteBody: "original content", noteDeleted: false, expectedNoteBookUUID: b2UUID, expectedNoteBody: "some updated content", expectedNoteBookName: "js", - expectedNotePublic: false, }, { payload: testutils.PayloadWrapper{ @@ -622,80 +540,11 @@ func TestUpdateNote(t *testing.T) { }, noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", noteBookUUID: b1UUID, - notePublic: false, noteBody: "", noteDeleted: true, expectedNoteBookUUID: b1UUID, expectedNoteBody: updatedBody, expectedNoteBookName: "js", - expectedNotePublic: false, - }, - { - payload: testutils.PayloadWrapper{ - Data: payloadData{ - Public: &testutils.TrueVal, - }, - }, - noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", - noteBookUUID: b1UUID, - notePublic: false, - noteBody: "original content", - noteDeleted: false, - expectedNoteBookUUID: b1UUID, - expectedNoteBody: "original content", - expectedNoteBookName: "css", - expectedNotePublic: true, - }, - { - payload: testutils.PayloadWrapper{ - Data: payloadData{ - Public: &testutils.FalseVal, - }, - }, - noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", - noteBookUUID: b1UUID, - notePublic: true, - noteBody: "original content", - noteDeleted: false, - expectedNoteBookUUID: b1UUID, - expectedNoteBody: "original content", - expectedNoteBookName: "css", - expectedNotePublic: false, - }, - { - payload: testutils.PayloadWrapper{ - Data: payloadData{ - Content: &updatedBody, - Public: &testutils.FalseVal, - }, - }, - noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", - noteBookUUID: b1UUID, - notePublic: true, - noteBody: "original content", - noteDeleted: false, - expectedNoteBookUUID: b1UUID, - expectedNoteBody: updatedBody, - expectedNoteBookName: "css", - expectedNotePublic: false, - }, - { - payload: testutils.PayloadWrapper{ - Data: payloadData{ - BookUUID: &b2UUID, - Content: &updatedBody, - Public: &testutils.TrueVal, - }, - }, - noteUUID: "ab50aa32-b232-40d8-b10f-10a7f9134053", - noteBookUUID: b1UUID, - notePublic: false, - noteBody: "original content", - noteDeleted: false, - expectedNoteBookUUID: b2UUID, - expectedNoteBody: updatedBody, - expectedNoteBookName: "js", - expectedNotePublic: true, }, } @@ -734,7 +583,6 @@ func TestUpdateNote(t *testing.T) { BookUUID: tc.noteBookUUID, Body: tc.noteBody, Deleted: tc.noteDeleted, - Public: tc.notePublic, } testutils.MustExec(t, db.Save(¬e), "preparing note") @@ -765,7 +613,6 @@ func TestUpdateNote(t *testing.T) { assert.Equal(t, noteRecord.UUID, tc.noteUUID, "note uuid mismatch for test case") assert.Equal(t, noteRecord.Body, tc.expectedNoteBody, "note content mismatch for test case") assert.Equal(t, noteRecord.BookUUID, tc.expectedNoteBookUUID, "note book_uuid mismatch for test case") - assert.Equal(t, noteRecord.Public, tc.expectedNotePublic, "note public mismatch for test case") assert.Equal(t, noteRecord.USN, 102, "note usn mismatch for test case") assert.Equal(t, userRecord.MaxUSN, 102, "user max_usn mismatch for test case") diff --git a/pkg/server/controllers/routes.go b/pkg/server/controllers/routes.go index db8b706d..ff7be403 100644 --- a/pkg/server/controllers/routes.go +++ b/pkg/server/controllers/routes.go @@ -82,7 +82,7 @@ func NewAPIRoutes(a *app.App, c *Controllers) []Route { {"POST", "/v3/signout", c.Users.V3Logout, true}, {"OPTIONS", "/v3/signout", c.Users.logoutOptions, true}, {"GET", "/v3/notes", mw.Auth(a.DB, c.Notes.V3Index, nil), true}, - {"GET", "/v3/notes/{noteUUID}", c.Notes.V3Show, true}, + {"GET", "/v3/notes/{noteUUID}", mw.Auth(a.DB, c.Notes.V3Show, nil), true}, {"POST", "/v3/notes", mw.Auth(a.DB, c.Notes.V3Create, nil), true}, {"DELETE", "/v3/notes/{noteUUID}", mw.Auth(a.DB, c.Notes.V3Delete, nil), true}, {"PATCH", "/v3/notes/{noteUUID}", mw.Auth(a.DB, c.Notes.V3Update, nil), true}, diff --git a/pkg/server/controllers/sync.go b/pkg/server/controllers/sync.go index 2ce8d02c..e93be7cd 100644 --- a/pkg/server/controllers/sync.go +++ b/pkg/server/controllers/sync.go @@ -75,7 +75,6 @@ type SyncFragNote struct { AddedOn int64 `json:"added_on"` EditedOn int64 `json:"edited_on"` Body string `json:"content"` - Public bool `json:"public"` Deleted bool `json:"deleted"` } @@ -89,7 +88,6 @@ func NewFragNote(note database.Note) SyncFragNote { AddedOn: note.AddedOn, EditedOn: note.EditedOn, Body: note.Body, - Public: note.Public, Deleted: note.Deleted, BookUUID: note.BookUUID, } diff --git a/pkg/server/database/models.go b/pkg/server/database/models.go index 98571e10..99e41c96 100644 --- a/pkg/server/database/models.go +++ b/pkg/server/database/models.go @@ -40,7 +40,6 @@ type Book struct { EditedOn int64 `json:"edited_on"` USN int `json:"-" gorm:"index"` Deleted bool `json:"-" gorm:"default:false"` - Encrypted bool `json:"-" gorm:"default:false"` } // Note is a model for a note @@ -54,10 +53,8 @@ type Note struct { Body string `json:"content"` AddedOn int64 `json:"added_on"` EditedOn int64 `json:"edited_on"` - Public bool `json:"public" gorm:"default:false"` USN int `json:"-" gorm:"index"` Deleted bool `json:"-" gorm:"default:false"` - Encrypted bool `json:"-" gorm:"default:false"` Client string `gorm:"index"` } diff --git a/pkg/server/middleware/auth.go b/pkg/server/middleware/auth.go index 984079e4..f74d1efa 100644 --- a/pkg/server/middleware/auth.go +++ b/pkg/server/middleware/auth.go @@ -101,7 +101,11 @@ func WithAccount(db *gorm.DB, next http.HandlerFunc) http.HandlerFunc { user := context.User(r.Context()) var account database.Account - if err := db.Where("user_id = ?", user.ID).First(&account).Error; err != nil { + err := db.Where("user_id = ?", user.ID).First(&account).Error + if errors.Is(err, gorm.ErrRecordNotFound) { + DoError(w, "account not found", err, http.StatusForbidden) + return + } else if err != nil { DoError(w, "finding account", err, http.StatusInternalServerError) return } diff --git a/pkg/server/middleware/auth_test.go b/pkg/server/middleware/auth_test.go index 1485befa..c0d94096 100644 --- a/pkg/server/middleware/auth_test.go +++ b/pkg/server/middleware/auth_test.go @@ -233,3 +233,37 @@ func TestTokenAuth(t *testing.T) { assert.Equal(t, res.StatusCode, http.StatusUnauthorized, "status code mismatch") }) } + +func TestWithAccount(t *testing.T) { + db := testutils.InitMemoryDB(t) + + handler := func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + } + + t.Run("user with account", func(t *testing.T) { + user := testutils.SetupUserData(db) + testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + + server := httptest.NewServer(Auth(db, handler, nil)) + defer server.Close() + + req := testutils.MakeReq(server.URL, "GET", "/", "") + res := testutils.HTTPAuthDo(t, db, req, user) + + assert.Equal(t, res.StatusCode, http.StatusOK, "status code mismatch") + }) + + t.Run("user without account", func(t *testing.T) { + user := testutils.SetupUserData(db) + // Note: not creating account for this user + + server := httptest.NewServer(Auth(db, handler, nil)) + defer server.Close() + + req := testutils.MakeReq(server.URL, "GET", "/", "") + res := testutils.HTTPAuthDo(t, db, req, user) + + assert.Equal(t, res.StatusCode, http.StatusForbidden, "status code mismatch") + }) +} diff --git a/pkg/server/operations/notes_test.go b/pkg/server/operations/notes_test.go index 6124b7e0..f003f7cb 100644 --- a/pkg/server/operations/notes_test.go +++ b/pkg/server/operations/notes_test.go @@ -40,29 +40,17 @@ func TestGetNote(t *testing.T) { } testutils.MustExec(t, db.Save(&b1), "preparing b1") - privateNote := database.Note{ + note := database.Note{ UUID: testutils.MustUUID(t), UserID: user.ID, BookUUID: b1.UUID, - Body: "privateNote content", + Body: "note content", Deleted: false, - Public: false, } - testutils.MustExec(t, db.Save(&privateNote), "preparing privateNote") + testutils.MustExec(t, db.Save(¬e), "preparing note") - publicNote := database.Note{ - UUID: testutils.MustUUID(t), - UserID: user.ID, - BookUUID: b1.UUID, - Body: "privateNote content", - Deleted: false, - Public: true, - } - testutils.MustExec(t, db.Save(&publicNote), "preparing privateNote") - - var privateNoteRecord, publicNoteRecord database.Note - testutils.MustExec(t, db.Where("uuid = ?", privateNote.UUID).Preload("Book").Preload("User").First(&privateNoteRecord), "finding privateNote") - testutils.MustExec(t, db.Where("uuid = ?", publicNote.UUID).Preload("Book").Preload("User").First(&publicNoteRecord), "finding publicNote") + var noteRecord database.Note + testutils.MustExec(t, db.Where("uuid = ?", note.UUID).Preload("Book").Preload("User").First(¬eRecord), "finding note") testCases := []struct { name string @@ -72,40 +60,26 @@ func TestGetNote(t *testing.T) { expectedNote database.Note }{ { - name: "owner accessing private note", + name: "owner accessing note", user: user, - note: privateNote, + note: note, expectedOK: true, - expectedNote: privateNoteRecord, + expectedNote: noteRecord, }, { - name: "non-owner accessing private note", + name: "non-owner accessing note", user: anotherUser, - note: privateNote, + note: note, expectedOK: false, expectedNote: database.Note{}, }, { - name: "non-owner accessing public note", - user: anotherUser, - note: publicNote, - expectedOK: true, - expectedNote: publicNoteRecord, - }, - { - name: "guest accessing private note", + name: "guest accessing note", user: database.User{}, - note: privateNote, + note: note, expectedOK: false, expectedNote: database.Note{}, }, - { - name: "guest accessing public note", - user: database.User{}, - note: publicNote, - expectedOK: true, - expectedNote: publicNoteRecord, - }, } for _, tc := range testCases { @@ -139,7 +113,6 @@ func TestGetNote_nonexistent(t *testing.T) { BookUUID: b1.UUID, Body: "n1 content", Deleted: false, - Public: false, } testutils.MustExec(t, db.Save(&n1), "preparing n1") diff --git a/pkg/server/permissions/permissions.go b/pkg/server/permissions/permissions.go index e3e10e63..d9d017d9 100644 --- a/pkg/server/permissions/permissions.go +++ b/pkg/server/permissions/permissions.go @@ -24,9 +24,6 @@ import ( // ViewNote checks if the given user can view the given note func ViewNote(user *database.User, note database.Note) bool { - if note.Public { - return true - } if user == nil { return false } diff --git a/pkg/server/permissions/permissions_test.go b/pkg/server/permissions/permissions_test.go index 4054b66f..ed439d28 100644 --- a/pkg/server/permissions/permissions_test.go +++ b/pkg/server/permissions/permissions_test.go @@ -39,53 +39,27 @@ func TestViewNote(t *testing.T) { } testutils.MustExec(t, db.Save(&b1), "preparing b1") - privateNote := database.Note{ + note := database.Note{ UUID: testutils.MustUUID(t), UserID: user.ID, BookUUID: b1.UUID, - Body: "privateNote content", + Body: "note content", Deleted: false, - Public: false, } - testutils.MustExec(t, db.Save(&privateNote), "preparing privateNote") + testutils.MustExec(t, db.Save(¬e), "preparing note") - publicNote := database.Note{ - UUID: testutils.MustUUID(t), - UserID: user.ID, - BookUUID: b1.UUID, - Body: "privateNote content", - Deleted: false, - Public: true, - } - testutils.MustExec(t, db.Save(&publicNote), "preparing privateNote") - - t.Run("owner accessing private note", func(t *testing.T) { - result := ViewNote(&user, privateNote) + t.Run("owner accessing note", func(t *testing.T) { + result := ViewNote(&user, note) assert.Equal(t, result, true, "result mismatch") }) - t.Run("owner accessing public note", func(t *testing.T) { - result := ViewNote(&user, publicNote) - assert.Equal(t, result, true, "result mismatch") - }) - - t.Run("non-owner accessing private note", func(t *testing.T) { - result := ViewNote(&anotherUser, privateNote) + t.Run("non-owner accessing note", func(t *testing.T) { + result := ViewNote(&anotherUser, note) assert.Equal(t, result, false, "result mismatch") }) - t.Run("non-owner accessing public note", func(t *testing.T) { - result := ViewNote(&anotherUser, publicNote) - assert.Equal(t, result, true, "result mismatch") - }) - - t.Run("guest accessing private note", func(t *testing.T) { - result := ViewNote(nil, privateNote) + t.Run("guest accessing note", func(t *testing.T) { + result := ViewNote(nil, note) assert.Equal(t, result, false, "result mismatch") }) - - t.Run("guest accessing public note", func(t *testing.T) { - result := ViewNote(nil, publicNote) - assert.Equal(t, result, true, "result mismatch") - }) } diff --git a/pkg/server/presenters/note.go b/pkg/server/presenters/note.go index 4119dd28..a20bb879 100644 --- a/pkg/server/presenters/note.go +++ b/pkg/server/presenters/note.go @@ -31,7 +31,6 @@ type Note struct { UpdatedAt time.Time `json:"updated_at"` Body string `json:"content"` AddedOn int64 `json:"added_on"` - Public bool `json:"public"` USN int `json:"usn"` Book NoteBook `json:"book"` User NoteUser `json:"user"` @@ -57,7 +56,6 @@ func PresentNote(note database.Note) Note { UpdatedAt: FormatTS(note.UpdatedAt), Body: note.Body, AddedOn: note.AddedOn, - Public: note.Public, USN: note.USN, Book: NoteBook{ UUID: note.Book.UUID, diff --git a/pkg/server/presenters/note_test.go b/pkg/server/presenters/note_test.go index 822c5cea..878acf67 100644 --- a/pkg/server/presenters/note_test.go +++ b/pkg/server/presenters/note_test.go @@ -41,7 +41,6 @@ func TestPresentNote(t *testing.T) { BookUUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098", Body: "Test note content", AddedOn: 1234567890, - Public: true, USN: 100, Book: database.Book{ UUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098", @@ -57,7 +56,6 @@ func TestPresentNote(t *testing.T) { assert.Equal(t, got.UUID, "a1b2c3d4-e5f6-4789-a012-3456789abcde", "UUID mismatch") assert.Equal(t, got.Body, "Test note content", "Body mismatch") assert.Equal(t, got.AddedOn, int64(1234567890), "AddedOn mismatch") - assert.Equal(t, got.Public, true, "Public mismatch") assert.Equal(t, got.USN, 100, "USN mismatch") assert.Equal(t, got.CreatedAt, FormatTS(createdAt), "CreatedAt mismatch") assert.Equal(t, got.UpdatedAt, FormatTS(updatedAt), "UpdatedAt mismatch") @@ -84,7 +82,6 @@ func TestPresentNotes(t *testing.T) { BookUUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098", Body: "First note", AddedOn: 1000000000, - Public: false, USN: 10, Book: database.Book{ UUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098", @@ -105,7 +102,6 @@ func TestPresentNotes(t *testing.T) { BookUUID: "abcdef01-2345-4678-9abc-def012345678", Body: "Second note", AddedOn: 2000000000, - Public: true, USN: 20, Book: database.Book{ UUID: "abcdef01-2345-4678-9abc-def012345678", diff --git a/pkg/server/tmpl/app_test.go b/pkg/server/tmpl/app_test.go index fba9bed4..8772bf92 100644 --- a/pkg/server/tmpl/app_test.go +++ b/pkg/server/tmpl/app_test.go @@ -19,12 +19,10 @@ package tmpl import ( - "fmt" "net/http" "testing" "github.com/dnote/dnote/pkg/assert" - "github.com/dnote/dnote/pkg/server/database" "github.com/dnote/dnote/pkg/server/testutils" "github.com/pkg/errors" ) @@ -50,42 +48,4 @@ func TestAppShellExecute(t *testing.T) { assert.Equal(t, string(b), "Dnote", "result mismatch") }) - - t.Run("note", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - user := testutils.SetupUserData(db) - b1 := database.Book{ - UUID: testutils.MustUUID(t), - UserID: user.ID, - Label: "js", - } - testutils.MustExec(t, db.Save(&b1), "preparing b1") - n1 := database.Note{ - UUID: testutils.MustUUID(t), - UserID: user.ID, - BookUUID: b1.UUID, - Public: true, - Body: "n1 content", - } - testutils.MustExec(t, db.Save(&n1), "preparing note") - - a, err := NewAppShell(db, []byte("{{ .MetaTags }}")) - if err != nil { - t.Fatal(errors.Wrap(err, "preparing app shell")) - } - - endpoint := fmt.Sprintf("http://mock.url/notes/%s", n1.UUID) - r, err := http.NewRequest("GET", endpoint, nil) - if err != nil { - t.Fatal(errors.Wrap(err, "preparing request")) - } - - b, err := a.Execute(r) - if err != nil { - t.Fatal(errors.Wrap(err, "executing")) - } - - assert.NotEqual(t, string(b), "", "result should not be empty") - }) } From 0a5728faf3ce84a6fd6da855129f3fc7a6031d70 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 21:05:47 -0700 Subject: [PATCH 19/33] Merge user and account (#701) --- pkg/e2e/sync_test.go | 9 +- pkg/server/app/books_test.go | 12 +- pkg/server/app/helpers_test.go | 2 +- pkg/server/app/notes_test.go | 24 +-- pkg/server/app/users.go | 73 +++------ pkg/server/app/users_test.go | 127 ++++++--------- pkg/server/cmd/user.go | 12 +- pkg/server/cmd/user_test.go | 26 ++-- pkg/server/context/user.go | 21 +-- pkg/server/controllers/books_test.go | 39 ++--- pkg/server/controllers/notes_test.go | 21 +-- pkg/server/controllers/users.go | 60 ++----- pkg/server/controllers/users_test.go | 146 +++++++----------- pkg/server/database/database.go | 1 - pkg/server/database/models.go | 13 +- pkg/server/middleware/auth.go | 23 --- pkg/server/middleware/auth_test.go | 25 +-- pkg/server/operations/notes_test.go | 6 +- pkg/server/permissions/permissions_test.go | 4 +- pkg/server/session/session.go | 4 +- pkg/server/session/session_test.go | 25 +-- pkg/server/testutils/main.go | 38 ++--- pkg/server/token/token_test.go | 2 +- pkg/server/views/data.go | 5 +- .../views/templates/layouts/navbar.gohtml | 2 +- pkg/server/views/view.go | 5 +- 26 files changed, 248 insertions(+), 477 deletions(-) diff --git a/pkg/e2e/sync_test.go b/pkg/e2e/sync_test.go index c2a1c4ee..73ea3b31 100644 --- a/pkg/e2e/sync_test.go +++ b/pkg/e2e/sync_test.go @@ -136,8 +136,7 @@ func TestMain(m *testing.M) { // helpers func setupUser(t *testing.T, db *cliDatabase.DB) database.User { - user := apitest.SetupUserData(serverDb) - apitest.SetupAccountData(serverDb, user, "alice@example.com", "pass1234") + user := apitest.SetupUserData(serverDb, "alice@example.com", "pass1234") return user } @@ -4255,8 +4254,7 @@ func TestSync_EmptyServer(t *testing.T) { // Step 1: Set up user on Server A and sync apiEndpointA := fmt.Sprintf("%s/api", serverA.URL) - userA := apitest.SetupUserData(serverDbA) - apitest.SetupAccountData(serverDbA, userA, "alice@example.com", "pass1234") + userA := apitest.SetupUserData(serverDbA, "alice@example.com", "pass1234") sessionA := apitest.SetupSession(serverDbA, userA) cliDatabase.MustExec(t, "inserting session_key", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, sessionA.Key) cliDatabase.MustExec(t, "inserting session_key_expiry", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, sessionA.ExpiresAt.Unix()) @@ -4280,8 +4278,7 @@ func TestSync_EmptyServer(t *testing.T) { apiEndpointB := fmt.Sprintf("%s/api", serverB.URL) // Set up user on Server B - userB := apitest.SetupUserData(serverDbB) - apitest.SetupAccountData(serverDbB, userB, "alice@example.com", "pass1234") + userB := apitest.SetupUserData(serverDbB, "alice@example.com", "pass1234") sessionB := apitest.SetupSession(serverDbB, userB) cliDatabase.MustExec(t, "updating session_key for B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) cliDatabase.MustExec(t, "updating session_key_expiry for B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) diff --git a/pkg/server/app/books_test.go b/pkg/server/app/books_test.go index 85df4770..66a27077 100644 --- a/pkg/server/app/books_test.go +++ b/pkg/server/app/books_test.go @@ -56,10 +56,10 @@ func TestCreateBook(t *testing.T) { func() { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") testutils.MustExec(t, db.Model(&user).Update("max_usn", tc.userUSN), fmt.Sprintf("preparing user max_usn for test case %d", idx)) - anotherUser := testutils.SetupUserData(db) + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") testutils.MustExec(t, db.Model(&anotherUser).Update("max_usn", 55), fmt.Sprintf("preparing user max_usn for test case %d", idx)) a := NewTest() @@ -122,10 +122,10 @@ func TestDeleteBook(t *testing.T) { func() { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") testutils.MustExec(t, db.Model(&user).Update("max_usn", tc.userUSN), fmt.Sprintf("preparing user max_usn for test case %d", idx)) - anotherUser := testutils.SetupUserData(db) + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") testutils.MustExec(t, db.Model(&anotherUser).Update("max_usn", 55), fmt.Sprintf("preparing user max_usn for test case %d", idx)) book := database.Book{UserID: user.ID, Label: "js", Deleted: false} @@ -201,10 +201,10 @@ func TestUpdateBook(t *testing.T) { func() { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") testutils.MustExec(t, db.Model(&user).Update("max_usn", tc.userUSN), fmt.Sprintf("preparing user max_usn for test case %d", idx)) - anotherUser := testutils.SetupUserData(db) + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") testutils.MustExec(t, db.Model(&anotherUser).Update("max_usn", 55), fmt.Sprintf("preparing user max_usn for test case %d", idx)) b := database.Book{UserID: user.ID, Deleted: false, Label: tc.expectedLabel} diff --git a/pkg/server/app/helpers_test.go b/pkg/server/app/helpers_test.go index 2c7a2828..ad309514 100644 --- a/pkg/server/app/helpers_test.go +++ b/pkg/server/app/helpers_test.go @@ -48,7 +48,7 @@ func TestIncremenetUserUSN(t *testing.T) { func() { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") testutils.MustExec(t, db.Model(&user).Update("max_usn", tc.maxUSN), fmt.Sprintf("preparing user max_usn for test case %d", idx)) // execute diff --git a/pkg/server/app/notes_test.go b/pkg/server/app/notes_test.go index 42a0bd8a..38195079 100644 --- a/pkg/server/app/notes_test.go +++ b/pkg/server/app/notes_test.go @@ -77,11 +77,11 @@ func TestCreateNote(t *testing.T) { func() { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") testutils.MustExec(t, db.Model(&user).Update("max_usn", tc.userUSN), fmt.Sprintf("preparing user max_usn for test case %d", idx)) fmt.Println(user) - anotherUser := testutils.SetupUserData(db) + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") testutils.MustExec(t, db.Model(&anotherUser).Update("max_usn", 55), fmt.Sprintf("preparing user max_usn for test case %d", idx)) b1 := database.Book{UserID: user.ID, Label: "js", Deleted: false} @@ -130,7 +130,7 @@ func TestCreateNote(t *testing.T) { func TestCreateNote_EmptyBody(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") b1 := database.Book{UserID: user.ID, Label: "testBook"} testutils.MustExec(t, db.Save(&b1), "preparing book") @@ -169,10 +169,10 @@ func TestUpdateNote(t *testing.T) { t.Run(fmt.Sprintf("test case %d", idx), func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") testutils.MustExec(t, db.Model(&user).Update("max_usn", tc.userUSN), "preparing user max_usn for test case") - anotherUser := testutils.SetupUserData(db) + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") testutils.MustExec(t, db.Model(&anotherUser).Update("max_usn", 55), "preparing user max_usn for test case") b1 := database.Book{UserID: user.ID, Label: "js", Deleted: false} @@ -234,7 +234,7 @@ func TestUpdateNote(t *testing.T) { func TestUpdateNote_SameContent(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") b1 := database.Book{UserID: user.ID, Label: "testBook"} testutils.MustExec(t, db.Save(&b1), "preparing book") @@ -291,10 +291,10 @@ func TestDeleteNote(t *testing.T) { func() { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") testutils.MustExec(t, db.Model(&user).Update("max_usn", tc.userUSN), fmt.Sprintf("preparing user max_usn for test case %d", idx)) - anotherUser := testutils.SetupUserData(db) + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") testutils.MustExec(t, db.Model(&anotherUser).Update("max_usn", 55), fmt.Sprintf("preparing user max_usn for test case %d", idx)) b1 := database.Book{UserID: user.ID, Label: "testBook"} @@ -351,7 +351,7 @@ func TestDeleteNote(t *testing.T) { func TestGetNotes_FTSSearch(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") b1 := database.Book{UserID: user.ID, Label: "testBook"} testutils.MustExec(t, db.Save(&b1), "preparing book") @@ -415,7 +415,7 @@ func TestGetNotes_FTSSearch(t *testing.T) { func TestGetNotes_FTSSearch_Snippet(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") b1 := database.Book{UserID: user.ID, Label: "testBook"} testutils.MustExec(t, db.Save(&b1), "preparing book") @@ -449,7 +449,7 @@ func TestGetNotes_FTSSearch_Snippet(t *testing.T) { func TestGetNotes_FTSSearch_ShortWord(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") b1 := database.Book{UserID: user.ID, Label: "testBook"} testutils.MustExec(t, db.Save(&b1), "preparing book") @@ -481,7 +481,7 @@ func TestGetNotes_FTSSearch_ShortWord(t *testing.T) { func TestGetNotes_All(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") b1 := database.Book{UserID: user.ID, Label: "testBook"} testutils.MustExec(t, db.Save(&b1), "preparing book") diff --git a/pkg/server/app/users.go b/pkg/server/app/users.go index b3993d55..6e9535e7 100644 --- a/pkg/server/app/users.go +++ b/pkg/server/app/users.go @@ -65,7 +65,7 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d tx := a.DB.Begin() var count int64 - if err := tx.Model(database.Account{}).Where("email = ?", email).Count(&count).Error; err != nil { + if err := tx.Model(&database.User{}).Where("email = ?", email).Count(&count).Error; err != nil { return database.User{}, pkgErrors.Wrap(err, "counting user") } if count > 0 { @@ -85,21 +85,14 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d } user := database.User{ - UUID: uuid, + UUID: uuid, + Email: database.ToNullString(email), + Password: database.ToNullString(string(hashedPassword)), } if err = tx.Save(&user).Error; err != nil { tx.Rollback() return database.User{}, pkgErrors.Wrap(err, "saving user") } - account := database.Account{ - Email: database.ToNullString(email), - Password: database.ToNullString(string(hashedPassword)), - UserID: user.ID, - } - if err = tx.Save(&account).Error; err != nil { - tx.Rollback() - return database.User{}, pkgErrors.Wrap(err, "saving account") - } if err := a.TouchLastLoginAt(user, tx); err != nil { tx.Rollback() @@ -111,42 +104,36 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d return user, nil } -// GetAccountByEmail finds an account by email -func (a *App) GetAccountByEmail(email string) (*database.Account, error) { - var account database.Account - err := a.DB.Where("email = ?", email).First(&account).Error +// GetUserByEmail finds a user by email +func (a *App) GetUserByEmail(email string) (*database.User, error) { + var user database.User + err := a.DB.Where("email = ?", email).First(&user).Error if errors.Is(err, gorm.ErrRecordNotFound) { return nil, ErrNotFound } else if err != nil { return nil, err } - return &account, nil + return &user, nil } // Authenticate authenticates a user func (a *App) Authenticate(email, password string) (*database.User, error) { - account, err := a.GetAccountByEmail(email) + user, err := a.GetUserByEmail(email) if err != nil { return nil, err } - err = bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte(password)) + err = bcrypt.CompareHashAndPassword([]byte(user.Password.String), []byte(password)) if err != nil { return nil, ErrLoginInvalid } - var user database.User - err = a.DB.Where("id = ?", account.UserID).First(&user).Error - if err != nil { - return nil, pkgErrors.Wrap(err, "finding user") - } - - return &user, nil + return user, nil } -// UpdateAccountPassword updates an account's password with validation -func UpdateAccountPassword(db *gorm.DB, account *database.Account, newPassword string) error { +// UpdateUserPassword updates a user's password with validation +func UpdateUserPassword(db *gorm.DB, user *database.User, newPassword string) error { // Validate password if err := validatePassword(newPassword); err != nil { return err @@ -159,25 +146,25 @@ func UpdateAccountPassword(db *gorm.DB, account *database.Account, newPassword s } // Update the password - if err := db.Model(&account).Update("password", string(hashedPassword)).Error; err != nil { + if err := db.Model(&user).Update("password", string(hashedPassword)).Error; err != nil { return pkgErrors.Wrap(err, "updating password") } return nil } -// RemoveUser removes a user and their account from the system +// RemoveUser removes a user from the system // Returns an error if the user has any notes or books func (a *App) RemoveUser(email string) error { - // Find the account and user - account, err := a.GetAccountByEmail(email) + // Find the user + user, err := a.GetUserByEmail(email) if err != nil { return err } // Check if user has any notes var noteCount int64 - if err := a.DB.Model(&database.Note{}).Where("user_id = ? AND deleted = ?", account.UserID, false).Count(¬eCount).Error; err != nil { + if err := a.DB.Model(&database.Note{}).Where("user_id = ? AND deleted = ?", user.ID, false).Count(¬eCount).Error; err != nil { return pkgErrors.Wrap(err, "counting notes") } if noteCount > 0 { @@ -186,34 +173,18 @@ func (a *App) RemoveUser(email string) error { // Check if user has any books var bookCount int64 - if err := a.DB.Model(&database.Book{}).Where("user_id = ? AND deleted = ?", account.UserID, false).Count(&bookCount).Error; err != nil { + if err := a.DB.Model(&database.Book{}).Where("user_id = ? AND deleted = ?", user.ID, false).Count(&bookCount).Error; err != nil { return pkgErrors.Wrap(err, "counting books") } if bookCount > 0 { return ErrUserHasExistingResources } - // Delete account and user in a transaction - tx := a.DB.Begin() - - if err := tx.Delete(&account).Error; err != nil { - tx.Rollback() - return pkgErrors.Wrap(err, "deleting account") - } - - var user database.User - if err := tx.Where("id = ?", account.UserID).First(&user).Error; err != nil { - tx.Rollback() - return pkgErrors.Wrap(err, "finding user") - } - - if err := tx.Delete(&user).Error; err != nil { - tx.Rollback() + // Delete user + if err := a.DB.Delete(&user).Error; err != nil { return pkgErrors.Wrap(err, "deleting user") } - tx.Commit() - return nil } diff --git a/pkg/server/app/users_test.go b/pkg/server/app/users_test.go index a4c3a60d..90184fec 100644 --- a/pkg/server/app/users_test.go +++ b/pkg/server/app/users_test.go @@ -82,21 +82,20 @@ func TestCreateUser_ProValue(t *testing.T) { } -func TestGetAccountByEmail(t *testing.T) { +func TestGetUserByEmail(t *testing.T) { t.Run("success", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "password123") + user := testutils.SetupUserData(db, "alice@example.com", "password123") a := NewTest() a.DB = db - account, err := a.GetAccountByEmail("alice@example.com") + foundUser, err := a.GetUserByEmail("alice@example.com") assert.Equal(t, err, nil, "should not error") - assert.Equal(t, account.Email.String, "alice@example.com", "email mismatch") - assert.Equal(t, account.UserID, user.ID, "user ID mismatch") + assert.Equal(t, foundUser.Email.String, "alice@example.com", "email mismatch") + assert.Equal(t, foundUser.ID, user.ID, "user ID mismatch") }) t.Run("not found", func(t *testing.T) { @@ -105,10 +104,10 @@ func TestGetAccountByEmail(t *testing.T) { a := NewTest() a.DB = db - account, err := a.GetAccountByEmail("nonexistent@example.com") + user, err := a.GetUserByEmail("nonexistent@example.com") assert.Equal(t, err, ErrNotFound, "should return ErrNotFound") - assert.Equal(t, account, (*database.Account)(nil), "account should be nil") + assert.Equal(t, user, (*database.User)(nil), "user should be nil") }) } @@ -124,25 +123,21 @@ func TestCreateUser(t *testing.T) { var userCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user") - assert.Equal(t, userCount, int64(1), "book count mismatch") + assert.Equal(t, userCount, int64(1), "user count mismatch") - var accountCount int64 - var accountRecord database.Account - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting account") - testutils.MustExec(t, db.First(&accountRecord), "finding account") + var userRecord database.User + testutils.MustExec(t, db.First(&userRecord), "finding user") - assert.Equal(t, accountCount, int64(1), "account count mismatch") - assert.Equal(t, accountRecord.Email.String, "alice@example.com", "account email mismatch") + assert.Equal(t, userRecord.Email.String, "alice@example.com", "user email mismatch") - passwordErr := bcrypt.CompareHashAndPassword([]byte(accountRecord.Password.String), []byte("pass1234")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(userRecord.Password.String), []byte("pass1234")) assert.Equal(t, passwordErr, nil, "Password mismatch") }) t.Run("duplicate email", func(t *testing.T) { db := testutils.InitMemoryDB(t) - aliceUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, aliceUser, "alice@example.com", "somepassword") + testutils.SetupUserData(db, "alice@example.com", "somepassword") a := NewTest() a.DB = db @@ -150,116 +145,109 @@ func TestCreateUser(t *testing.T) { assert.Equal(t, err, ErrDuplicateEmail, "error mismatch") - var userCount, accountCount int64 + var userCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user") - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting account") assert.Equal(t, userCount, int64(1), "user count mismatch") - assert.Equal(t, accountCount, int64(1), "account count mismatch") }) } -func TestUpdateAccountPassword(t *testing.T) { +func TestUpdateUserPassword(t *testing.T) { t.Run("success", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + user := testutils.SetupUserData(db, "alice@example.com", "oldpassword123") - err := UpdateAccountPassword(db, &account, "newpassword123") + err := UpdateUserPassword(db, &user, "newpassword123") assert.Equal(t, err, nil, "should not error") // Verify password was updated in database - var updatedAccount database.Account - testutils.MustExec(t, db.Where("id = ?", account.ID).First(&updatedAccount), "finding updated account") + var updatedUser database.User + testutils.MustExec(t, db.Where("id = ?", user.ID).First(&updatedUser), "finding updated user") // Verify new password works - passwordErr := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("newpassword123")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(updatedUser.Password.String), []byte("newpassword123")) assert.Equal(t, passwordErr, nil, "New password should match") // Verify old password no longer works - oldPasswordErr := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("oldpassword123")) + oldPasswordErr := bcrypt.CompareHashAndPassword([]byte(updatedUser.Password.String), []byte("oldpassword123")) assert.NotEqual(t, oldPasswordErr, nil, "Old password should not match") }) t.Run("password too short", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + user := testutils.SetupUserData(db, "alice@example.com", "oldpassword123") - err := UpdateAccountPassword(db, &account, "short") + err := UpdateUserPassword(db, &user, "short") assert.Equal(t, err, ErrPasswordTooShort, "should return ErrPasswordTooShort") // Verify password was NOT updated in database - var unchangedAccount database.Account - testutils.MustExec(t, db.Where("id = ?", account.ID).First(&unchangedAccount), "finding unchanged account") + var unchangedUser database.User + testutils.MustExec(t, db.Where("id = ?", user.ID).First(&unchangedUser), "finding unchanged user") // Verify old password still works - passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedAccount.Password.String), []byte("oldpassword123")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedUser.Password.String), []byte("oldpassword123")) assert.Equal(t, passwordErr, nil, "Old password should still match") }) t.Run("empty password", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + user := testutils.SetupUserData(db, "alice@example.com", "oldpassword123") - err := UpdateAccountPassword(db, &account, "") + err := UpdateUserPassword(db, &user, "") assert.Equal(t, err, ErrPasswordTooShort, "should return ErrPasswordTooShort") // Verify password was NOT updated in database - var unchangedAccount database.Account - testutils.MustExec(t, db.Where("id = ?", account.ID).First(&unchangedAccount), "finding unchanged account") + var unchangedUser database.User + testutils.MustExec(t, db.Where("id = ?", user.ID).First(&unchangedUser), "finding unchanged user") // Verify old password still works - passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedAccount.Password.String), []byte("oldpassword123")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedUser.Password.String), []byte("oldpassword123")) assert.Equal(t, passwordErr, nil, "Old password should still match") }) t.Run("transaction rollback", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + user := testutils.SetupUserData(db, "alice@example.com", "oldpassword123") - // Start a transaction and rollback to verify UpdateAccountPassword respects transactions + // Start a transaction and rollback to verify UpdateUserPassword respects transactions tx := db.Begin() - err := UpdateAccountPassword(tx, &account, "newpassword123") + err := UpdateUserPassword(tx, &user, "newpassword123") assert.Equal(t, err, nil, "should not error") tx.Rollback() // Verify password was NOT updated after rollback - var unchangedAccount database.Account - testutils.MustExec(t, db.Where("id = ?", account.ID).First(&unchangedAccount), "finding unchanged account") + var unchangedUser database.User + testutils.MustExec(t, db.Where("id = ?", user.ID).First(&unchangedUser), "finding unchanged user") // Verify old password still works - passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedAccount.Password.String), []byte("oldpassword123")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(unchangedUser.Password.String), []byte("oldpassword123")) assert.Equal(t, passwordErr, nil, "Old password should still match after rollback") }) t.Run("transaction commit", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - account := testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword123") + user := testutils.SetupUserData(db, "alice@example.com", "oldpassword123") - // Start a transaction and commit to verify UpdateAccountPassword respects transactions + // Start a transaction and commit to verify UpdateUserPassword respects transactions tx := db.Begin() - err := UpdateAccountPassword(tx, &account, "newpassword123") + err := UpdateUserPassword(tx, &user, "newpassword123") assert.Equal(t, err, nil, "should not error") tx.Commit() // Verify password was updated after commit - var updatedAccount database.Account - testutils.MustExec(t, db.Where("id = ?", account.ID).First(&updatedAccount), "finding updated account") + var updatedUser database.User + testutils.MustExec(t, db.Where("id = ?", user.ID).First(&updatedUser), "finding updated user") // Verify new password works - passwordErr := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("newpassword123")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(updatedUser.Password.String), []byte("newpassword123")) assert.Equal(t, passwordErr, nil, "New password should match after commit") }) } @@ -268,8 +256,7 @@ func TestRemoveUser(t *testing.T) { t.Run("success", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "password123") + testutils.SetupUserData(db, "alice@example.com", "password123") a := NewTest() a.DB = db @@ -282,11 +269,6 @@ func TestRemoveUser(t *testing.T) { var userCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") assert.Equal(t, userCount, int64(0), "user should be deleted") - - // Verify account was deleted - var accountCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") - assert.Equal(t, accountCount, int64(0), "account should be deleted") }) t.Run("user not found", func(t *testing.T) { @@ -303,8 +285,7 @@ func TestRemoveUser(t *testing.T) { t.Run("user has notes", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "password123") + user := testutils.SetupUserData(db, "alice@example.com", "password123") book := database.Book{UserID: user.ID, Label: "testbook", Deleted: false} testutils.MustExec(t, db.Save(&book), "creating book") @@ -324,17 +305,12 @@ func TestRemoveUser(t *testing.T) { testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") assert.Equal(t, userCount, int64(1), "user should not be deleted") - // Verify account was NOT deleted - var accountCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") - assert.Equal(t, accountCount, int64(1), "account should not be deleted") }) t.Run("user has books", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "password123") + user := testutils.SetupUserData(db, "alice@example.com", "password123") book := database.Book{UserID: user.ID, Label: "testbook", Deleted: false} testutils.MustExec(t, db.Save(&book), "creating book") @@ -351,17 +327,12 @@ func TestRemoveUser(t *testing.T) { testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") assert.Equal(t, userCount, int64(1), "user should not be deleted") - // Verify account was NOT deleted - var accountCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") - assert.Equal(t, accountCount, int64(1), "account should not be deleted") }) t.Run("user has deleted notes and books", func(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "password123") + user := testutils.SetupUserData(db, "alice@example.com", "password123") book := database.Book{UserID: user.ID, Label: "testbook", Deleted: false} testutils.MustExec(t, db.Save(&book), "creating book") @@ -385,9 +356,5 @@ func TestRemoveUser(t *testing.T) { testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting users") assert.Equal(t, userCount, int64(0), "user should be deleted") - // Verify account was deleted - var accountCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting accounts") - assert.Equal(t, accountCount, int64(0), "account should be deleted") }) } diff --git a/pkg/server/cmd/user.go b/pkg/server/cmd/user.go index 6123cdae..ec5b4ea2 100644 --- a/pkg/server/cmd/user.go +++ b/pkg/server/cmd/user.go @@ -81,12 +81,12 @@ func userRemoveCmd(args []string, stdin io.Reader) { defer cleanup() // Check if user exists first - _, err := a.GetAccountByEmail(*email) + _, err := a.GetUserByEmail(*email) if err != nil { if errors.Is(err, app.ErrNotFound) { fmt.Printf("Error: user with email %s not found\n", *email) } else { - log.ErrorWrap(err, "finding account") + log.ErrorWrap(err, "finding user") } os.Exit(1) } @@ -133,19 +133,19 @@ func userResetPasswordCmd(args []string) { a, cleanup := setupAppWithDB(fs, *dbPath) defer cleanup() - // Find the account - account, err := a.GetAccountByEmail(*email) + // Find the user + user, err := a.GetUserByEmail(*email) if err != nil { if errors.Is(err, app.ErrNotFound) { fmt.Printf("Error: user with email %s not found\n", *email) } else { - log.ErrorWrap(err, "finding account") + log.ErrorWrap(err, "finding user") } os.Exit(1) } // Update the password - if err := app.UpdateAccountPassword(a.DB, account, *password); err != nil { + if err := app.UpdateUserPassword(a.DB, user, *password); err != nil { log.ErrorWrap(err, "updating password") os.Exit(1) } diff --git a/pkg/server/cmd/user_test.go b/pkg/server/cmd/user_test.go index d3536d52..ea81832a 100644 --- a/pkg/server/cmd/user_test.go +++ b/pkg/server/cmd/user_test.go @@ -45,9 +45,9 @@ func TestUserCreateCmd(t *testing.T) { testutils.MustExec(t, db.Model(&database.User{}).Count(&count), "counting users") assert.Equal(t, count, int64(1), "should have 1 user") - var account database.Account - testutils.MustExec(t, db.Where("email = ?", "test@example.com").First(&account), "finding account") - assert.Equal(t, account.Email.String, "test@example.com", "email mismatch") + var user database.User + testutils.MustExec(t, db.Where("email = ?", "test@example.com").First(&user), "finding user") + assert.Equal(t, user.Email.String, "test@example.com", "email mismatch") } func TestUserRemoveCmd(t *testing.T) { @@ -55,8 +55,7 @@ func TestUserRemoveCmd(t *testing.T) { // Create a user first db := testutils.InitDB(tmpDB) - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "test@example.com", "password123") + testutils.SetupUserData(db, "test@example.com", "password123") sqlDB, _ := db.DB() sqlDB.Close() @@ -81,9 +80,8 @@ func TestUserResetPasswordCmd(t *testing.T) { // Create a user first db := testutils.InitDB(tmpDB) - user := testutils.SetupUserData(db) - account := testutils.SetupAccountData(db, user, "test@example.com", "oldpassword123") - oldPasswordHash := account.Password.String + user := testutils.SetupUserData(db, "test@example.com", "oldpassword123") + oldPasswordHash := user.Password.String sqlDB, _ := db.DB() sqlDB.Close() @@ -97,18 +95,18 @@ func TestUserResetPasswordCmd(t *testing.T) { sqlDB2.Close() }() - var updatedAccount database.Account - testutils.MustExec(t, db2.Where("email = ?", "test@example.com").First(&updatedAccount), "finding account") + var updatedUser database.User + testutils.MustExec(t, db2.Where("email = ?", "test@example.com").First(&updatedUser), "finding user") // Verify password hash changed - assert.Equal(t, updatedAccount.Password.String != oldPasswordHash, true, "password hash should be different") - assert.Equal(t, len(updatedAccount.Password.String) > 0, true, "password should be set") + assert.Equal(t, updatedUser.Password.String != oldPasswordHash, true, "password hash should be different") + assert.Equal(t, len(updatedUser.Password.String) > 0, true, "password should be set") // Verify new password works - err := bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("newpassword123")) + err := bcrypt.CompareHashAndPassword([]byte(updatedUser.Password.String), []byte("newpassword123")) assert.Equal(t, err, nil, "new password should match") // Verify old password doesn't work - err = bcrypt.CompareHashAndPassword([]byte(updatedAccount.Password.String), []byte("oldpassword123")) + err = bcrypt.CompareHashAndPassword([]byte(updatedUser.Password.String), []byte("oldpassword123")) assert.Equal(t, err != nil, true, "old password should not match") } diff --git a/pkg/server/context/user.go b/pkg/server/context/user.go index 77d66916..64171df7 100644 --- a/pkg/server/context/user.go +++ b/pkg/server/context/user.go @@ -25,9 +25,8 @@ import ( ) const ( - userKey privateKey = "user" - accountKey privateKey = "account" - tokenKey privateKey = "token" + userKey privateKey = "user" + tokenKey privateKey = "token" ) type privateKey string @@ -37,11 +36,6 @@ func WithUser(ctx context.Context, user *database.User) context.Context { return context.WithValue(ctx, userKey, user) } -// WithAccount creates a new context with the given account -func WithAccount(ctx context.Context, account *database.Account) context.Context { - return context.WithValue(ctx, accountKey, account) -} - // WithToken creates a new context with the given user func WithToken(ctx context.Context, tok *database.Token) context.Context { return context.WithValue(ctx, tokenKey, tok) @@ -59,17 +53,6 @@ func User(ctx context.Context) *database.User { return nil } -// Account retrieves an account from the given context. -func Account(ctx context.Context) *database.Account { - if temp := ctx.Value(accountKey); temp != nil { - if account, ok := temp.(*database.Account); ok { - return account - } - } - - return nil -} - // Token retrieves a token from the given context. func Token(ctx context.Context) *database.Token { if temp := ctx.Value(tokenKey); temp != nil { diff --git a/pkg/server/controllers/books_test.go b/pkg/server/controllers/books_test.go index d59dcd17..e2302f22 100644 --- a/pkg/server/controllers/books_test.go +++ b/pkg/server/controllers/books_test.go @@ -50,10 +50,8 @@ func TestGetBooks(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") - anotherUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, anotherUser, "bob@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") + anotherUser := testutils.SetupUserData(db, "bob@test.com", "pass1234") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -143,10 +141,8 @@ func TestGetBooksByName(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") - anotherUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, anotherUser, "bob@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") + anotherUser := testutils.SetupUserData(db, "bob@test.com", "pass1234") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -212,10 +208,8 @@ func TestGetBook(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") - anotherUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, anotherUser, "bob@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") + anotherUser := testutils.SetupUserData(db, "bob@test.com", "pass1234") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -276,10 +270,8 @@ func TestGetBookNonOwner(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") - nonOwner := testutils.SetupUserData(db) - testutils.SetupAccountData(db, nonOwner, "bob@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") + nonOwner := testutils.SetupUserData(db, "bob@test.com", "pass1234") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -314,8 +306,7 @@ func TestCreateBook(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") testutils.MustExec(t, db.Model(&user).Update("max_usn", 101), "preparing user max_usn") req := testutils.MakeReq(server.URL, "POST", "/api/v3/books", `{"name": "js"}`) @@ -375,8 +366,7 @@ func TestCreateBook(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") testutils.MustExec(t, db.Model(&user).Update("max_usn", 101), "preparing user max_usn") b1 := database.Book{ @@ -465,8 +455,7 @@ func TestUpdateBook(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") testutils.MustExec(t, db.Model(&user).Update("max_usn", 101), "preparing user max_usn") b1 := database.Book{ @@ -550,11 +539,9 @@ func TestDeleteBook(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") testutils.MustExec(t, db.Model(&user).Update("max_usn", 58), "preparing user max_usn") - anotherUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, anotherUser, "bob@test.com", "pass1234") + anotherUser := testutils.SetupUserData(db, "bob@test.com", "pass1234") testutils.MustExec(t, db.Model(&anotherUser).Update("max_usn", 109), "preparing another user max_usn") b1 := database.Book{ diff --git a/pkg/server/controllers/notes_test.go b/pkg/server/controllers/notes_test.go index ce3f20c7..b69f7c1e 100644 --- a/pkg/server/controllers/notes_test.go +++ b/pkg/server/controllers/notes_test.go @@ -63,10 +63,8 @@ func TestGetNotes(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") - anotherUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, anotherUser, "bob@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") + anotherUser := testutils.SetupUserData(db, "bob@test.com", "pass1234") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -187,10 +185,8 @@ func TestGetNote(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "user@test.com", "pass1234") - anotherUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, anotherUser, "another@test.com", "pass1234") + user := testutils.SetupUserData(db, "user@test.com", "pass1234") + anotherUser := testutils.SetupUserData(db, "another@test.com", "pass1234") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -318,8 +314,7 @@ func TestCreateNote(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") testutils.MustExec(t, db.Model(&user).Update("max_usn", 101), "preparing user max_usn") b1 := database.Book{ @@ -400,8 +395,7 @@ func TestDeleteNote(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") testutils.MustExec(t, db.Model(&user).Update("max_usn", 981), "preparing user max_usn") b1 := database.Book{ @@ -559,8 +553,7 @@ func TestUpdateNote(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") testutils.MustExec(t, db.Model(&user).Update("max_usn", 101), "preparing user max_usn") diff --git a/pkg/server/controllers/users.go b/pkg/server/controllers/users.go index b1945d8f..bf1e6384 100644 --- a/pkg/server/controllers/users.go +++ b/pkg/server/controllers/users.go @@ -307,23 +307,23 @@ func (u *Users) CreateResetToken(w http.ResponseWriter, r *http.Request) { return } - var account database.Account - err := u.app.DB.Where("email = ?", form.Email).First(&account).Error + var user database.User + err := u.app.DB.Where("email = ?", form.Email).First(&user).Error if errors.Is(err, gorm.ErrRecordNotFound) { return } if err != nil { - handleHTMLError(w, r, err, "finding account", u.PasswordResetView, vd) + handleHTMLError(w, r, err, "finding user", u.PasswordResetView, vd) return } - resetToken, err := token.Create(u.app.DB, account.UserID, database.TokenTypeResetPassword) + resetToken, err := token.Create(u.app.DB, user.ID, database.TokenTypeResetPassword) if err != nil { handleHTMLError(w, r, err, "generating token", u.PasswordResetView, vd) return } - if err := u.app.SendPasswordResetEmail(account.Email.String, resetToken.Value); err != nil { + if err := u.app.SendPasswordResetEmail(user.Email.String, resetToken.Value); err != nil { handleHTMLError(w, r, err, "sending password reset email", u.PasswordResetView, vd) return } @@ -396,8 +396,8 @@ func (u *Users) PasswordReset(w http.ResponseWriter, r *http.Request) { return } - var account database.Account - if err := u.app.DB.Where("user_id = ?", token.UserID).First(&account).Error; err != nil { + var user database.User + if err := u.app.DB.Where("id = ?", token.UserID).First(&user).Error; err != nil { handleHTMLError(w, r, err, "finding user", u.PasswordResetConfirmView, vd) return } @@ -405,7 +405,7 @@ func (u *Users) PasswordReset(w http.ResponseWriter, r *http.Request) { tx := u.app.DB.Begin() // Update the password - if err := app.UpdateAccountPassword(tx, &account, params.Password); err != nil { + if err := app.UpdateUserPassword(tx, &user, params.Password); err != nil { tx.Rollback() handleHTMLError(w, r, err, "updating password", u.PasswordResetConfirmView, vd) return @@ -417,7 +417,7 @@ func (u *Users) PasswordReset(w http.ResponseWriter, r *http.Request) { return } - if err := u.app.DeleteUserSessions(tx, account.UserID); err != nil { + if err := u.app.DeleteUserSessions(tx, user.ID); err != nil { tx.Rollback() handleHTMLError(w, r, err, "deleting user sessions", u.PasswordResetConfirmView, vd) return @@ -425,19 +425,13 @@ func (u *Users) PasswordReset(w http.ResponseWriter, r *http.Request) { tx.Commit() - var user database.User - if err := u.app.DB.Where("id = ?", account.UserID).First(&user).Error; err != nil { - handleHTMLError(w, r, err, "finding user", u.PasswordResetConfirmView, vd) - return - } - alert := views.Alert{ Level: views.AlertLvlSuccess, Message: "Password reset successful", } views.RedirectAlert(w, r, "/login", http.StatusFound, alert) - if err := u.app.SendPasswordResetAlertEmail(account.Email.String); err != nil { + if err := u.app.SendPasswordResetAlertEmail(user.Email.String); err != nil { log.ErrorWrap(err, "sending password reset email") } } @@ -493,14 +487,8 @@ func (u *Users) PasswordUpdate(w http.ResponseWriter, r *http.Request) { return } - var account database.Account - if err := u.app.DB.Where("user_id = ?", user.ID).First(&account).Error; err != nil { - handleHTMLError(w, r, err, "getting account", u.SettingView, vd) - return - } - password := []byte(form.OldPassword) - if err := bcrypt.CompareHashAndPassword([]byte(account.Password.String), password); err != nil { + if err := bcrypt.CompareHashAndPassword([]byte(user.Password.String), password); err != nil { log.WithFields(log.Fields{ "user_id": user.ID, }).Warn("invalid password update attempt") @@ -508,7 +496,7 @@ func (u *Users) PasswordUpdate(w http.ResponseWriter, r *http.Request) { return } - if err := app.UpdateAccountPassword(u.app.DB, &account, form.NewPassword); err != nil { + if err := app.UpdateUserPassword(u.app.DB, user, form.NewPassword); err != nil { handleHTMLError(w, r, err, "updating password", u.SettingView, vd) return } @@ -534,12 +522,6 @@ func (u *Users) ProfileUpdate(w http.ResponseWriter, r *http.Request) { return } - var account database.Account - if err := u.app.DB.Where("user_id = ?", user.ID).First(&account).Error; err != nil { - handleHTMLError(w, r, err, "getting account", u.SettingView, vd) - return - } - var form updateProfileForm if err := parseRequestData(r, &form); err != nil { handleHTMLError(w, r, err, "parsing payload", u.SettingView, vd) @@ -547,7 +529,7 @@ func (u *Users) ProfileUpdate(w http.ResponseWriter, r *http.Request) { } password := []byte(form.Password) - if err := bcrypt.CompareHashAndPassword([]byte(account.Password.String), password); err != nil { + if err := bcrypt.CompareHashAndPassword([]byte(user.Password.String), password); err != nil { log.WithFields(log.Fields{ "user_id": user.ID, }).Warn("invalid email update attempt") @@ -561,23 +543,13 @@ func (u *Users) ProfileUpdate(w http.ResponseWriter, r *http.Request) { return } - tx := u.app.DB.Begin() - if err := tx.Save(&user).Error; err != nil { - tx.Rollback() + user.Email.String = form.Email + + if err := u.app.DB.Save(&user).Error; err != nil { handleHTMLError(w, r, err, "saving user", u.SettingView, vd) return } - account.Email.String = form.Email - - if err := tx.Save(&account).Error; err != nil { - tx.Rollback() - handleHTMLError(w, r, err, "saving account", u.SettingView, vd) - return - } - - tx.Commit() - alert := views.Alert{ Level: views.AlertLvlSuccess, Message: "Email change successful", diff --git a/pkg/server/controllers/users_test.go b/pkg/server/controllers/users_test.go index 643cb016..03f6c53e 100644 --- a/pkg/server/controllers/users_test.go +++ b/pkg/server/controllers/users_test.go @@ -98,15 +98,14 @@ func TestJoin(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusFound, "") - var account database.Account - testutils.MustExec(t, db.Where("email = ?", tc.email).First(&account), "finding account") - assert.Equal(t, account.Email.String, tc.email, "Email mismatch") - assert.NotEqual(t, account.UserID, 0, "UserID mismatch") - passwordErr := bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte(tc.password)) + var user database.User + testutils.MustExec(t, db.Where("email = ?", tc.email).First(&user), "finding account") + assert.Equal(t, user.Email.String, tc.email, "Email mismatch") + assert.NotEqual(t, user.ID, 0, "UserID mismatch") + passwordErr := bcrypt.CompareHashAndPassword([]byte(user.Password.String), []byte(tc.password)) assert.Equal(t, passwordErr, nil, "Password mismatch") - var user database.User - testutils.MustExec(t, db.Where("id = ?", account.UserID).First(&user), "finding user") + testutils.MustExec(t, db.Where("id = ?", user.ID).First(&user), "finding user") assert.Equal(t, user.MaxUSN, 0, "MaxUSN mismatch") // welcome email @@ -140,11 +139,9 @@ func TestJoinError(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status mismatch") - var accountCount, userCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting account") + var userCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user") - assert.Equal(t, accountCount, int64(0), "accountCount mismatch") assert.Equal(t, userCount, int64(0), "userCount mismatch") }) @@ -168,11 +165,9 @@ func TestJoinError(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status mismatch") - var accountCount, userCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting account") + var userCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user") - assert.Equal(t, accountCount, int64(0), "accountCount mismatch") assert.Equal(t, userCount, int64(0), "userCount mismatch") }) @@ -198,11 +193,9 @@ func TestJoinError(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status mismatch") - var accountCount, userCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting account") + var userCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user") - assert.Equal(t, accountCount, int64(0), "accountCount mismatch") assert.Equal(t, userCount, int64(0), "userCount mismatch") }) } @@ -217,8 +210,7 @@ func TestJoinDuplicateEmail(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "somepassword") + u := testutils.SetupUserData(db, "alice@example.com", "somepassword") dat := url.Values{} dat.Set("email", "alice@example.com") @@ -232,15 +224,13 @@ func TestJoinDuplicateEmail(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusBadRequest, "status code mismatch") - var accountCount, userCount, verificationTokenCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting account") + var userCount, verificationTokenCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user") testutils.MustExec(t, db.Model(&database.Token{}).Count(&verificationTokenCount), "counting verification token") var user database.User testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding user") - assert.Equal(t, accountCount, int64(1), "account count mismatch") assert.Equal(t, userCount, int64(1), "user count mismatch") assert.Equal(t, verificationTokenCount, int64(0), "verification_token should not have been created") assert.Equal(t, user.LastLoginAt, (*time.Time)(nil), "LastLoginAt mismatch") @@ -268,11 +258,9 @@ func TestJoinDisabled(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusNotFound, "status code mismatch") - var accountCount, userCount int64 - testutils.MustExec(t, db.Model(&database.Account{}).Count(&accountCount), "counting account") + var userCount int64 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user") - assert.Equal(t, accountCount, int64(0), "account count mismatch") assert.Equal(t, userCount, int64(0), "user count mismatch") } @@ -286,8 +274,7 @@ func TestLogin(t *testing.T) { a.DB = db server := MustNewServer(t, &a) - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") + _ = testutils.SetupUserData(db, "alice@example.com", "pass1234") defer server.Close() // Execute @@ -346,8 +333,7 @@ func TestLogin(t *testing.T) { a.DB = db server := MustNewServer(t, &a) - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") + _ = testutils.SetupUserData(db, "alice@example.com", "pass1234") defer server.Close() var req *http.Request @@ -386,8 +372,7 @@ func TestLogin(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") + _ = testutils.SetupUserData(db, "alice@example.com", "pass1234") var req *http.Request if target == testutils.EndpointWeb { @@ -456,9 +441,8 @@ func TestLogout(t *testing.T) { a.DB = db server := MustNewServer(t, &a) - aliceUser := testutils.SetupUserData(db) - testutils.SetupAccountData(db, aliceUser, "alice@example.com", "pass1234") - anotherUser := testutils.SetupUserData(db) + aliceUser := testutils.SetupUserData(db, "alice@example.com", "pass1234") + anotherUser := testutils.SetupUserData(db, "bob@example.com", "password123") session1ExpiresAt := time.Now().Add(time.Hour * 24) session1 := database.Session{ @@ -570,8 +554,7 @@ func TestResetPassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "oldpassword") + u := testutils.SetupUserData(db, "alice@example.com", "oldpassword") tok := database.Token{ UserID: u.ID, Value: "MivFxYiSMMA4An9dP24DNQ==", @@ -593,7 +576,7 @@ func TestResetPassword(t *testing.T) { } testutils.MustExec(t, db.Save(&s2), "preparing user session 2") - anotherUser := testutils.SetupUserData(db) + anotherUser := testutils.SetupUserData(db, "bob@example.com", "password123") testutils.MustExec(t, db.Save(&database.Session{ Key: "some-session-key-3", UserID: anotherUser.ID, @@ -613,12 +596,12 @@ func TestResetPassword(t *testing.T) { assert.StatusCodeEquals(t, res, http.StatusFound, "Status code mismatch") var resetToken database.Token - var account database.Account + var user database.User testutils.MustExec(t, db.Where("value = ?", "MivFxYiSMMA4An9dP24DNQ==").First(&resetToken), "finding reset token") - testutils.MustExec(t, db.Where("id = ?", acc.ID).First(&account), "finding account") + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding account") assert.NotEqual(t, resetToken.UsedAt, nil, "reset_token UsedAt mismatch") - passwordErr := bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte("newpassword")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(user.Password.String), []byte("newpassword")) assert.Equal(t, passwordErr, nil, "Password mismatch") var s1Count, s2Count int64 @@ -646,8 +629,7 @@ func TestResetPassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "somepassword") + u := testutils.SetupUserData(db, "alice@example.com", "somepassword") tok := database.Token{ UserID: u.ID, Value: "MivFxYiSMMA4An9dP24DNQ==", @@ -668,12 +650,12 @@ func TestResetPassword(t *testing.T) { assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status code mismatch") var resetToken database.Token - var account database.Account + var user database.User testutils.MustExec(t, db.Where("value = ?", "MivFxYiSMMA4An9dP24DNQ==").First(&resetToken), "finding reset token") - testutils.MustExec(t, db.Where("id = ?", acc.ID).First(&account), "finding account") + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding account") - assert.Equal(t, acc.Password, account.Password, "password should not have been updated") - assert.Equal(t, acc.Password, account.Password, "password should not have been updated") + assert.Equal(t, u.Password, user.Password, "password should not have been updated") + assert.Equal(t, u.Password, user.Password, "password should not have been updated") assert.Equal(t, resetToken.UsedAt, (*time.Time)(nil), "used_at should be nil") }) @@ -687,8 +669,7 @@ func TestResetPassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "somepassword") + u := testutils.SetupUserData(db, "alice@example.com", "somepassword") tok := database.Token{ UserID: u.ID, Value: "MivFxYiSMMA4An9dP24DNQ==", @@ -710,10 +691,10 @@ func TestResetPassword(t *testing.T) { assert.StatusCodeEquals(t, res, http.StatusGone, "Status code mismatch") var resetToken database.Token - var account database.Account + var user database.User testutils.MustExec(t, db.Where("value = ?", "MivFxYiSMMA4An9dP24DNQ==").First(&resetToken), "failed to find reset_token") - testutils.MustExec(t, db.Where("id = ?", acc.ID).First(&account), "failed to find account") - assert.Equal(t, acc.Password, account.Password, "password should not have been updated") + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "failed to find account") + assert.Equal(t, u.Password, user.Password, "password should not have been updated") assert.Equal(t, resetToken.UsedAt, (*time.Time)(nil), "used_at should be nil") }) @@ -727,8 +708,7 @@ func TestResetPassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "somepassword") + u := testutils.SetupUserData(db, "alice@example.com", "somepassword") usedAt := time.Now().Add(time.Hour * -11).UTC() tok := database.Token{ @@ -753,10 +733,10 @@ func TestResetPassword(t *testing.T) { assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status code mismatch") var resetToken database.Token - var account database.Account + var user database.User testutils.MustExec(t, db.Where("value = ?", "MivFxYiSMMA4An9dP24DNQ==").First(&resetToken), "failed to find reset_token") - testutils.MustExec(t, db.Where("id = ?", acc.ID).First(&account), "failed to find account") - assert.Equal(t, acc.Password, account.Password, "password should not have been updated") + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "failed to find account") + assert.Equal(t, u.Password, user.Password, "password should not have been updated") resetTokenUsedAtUTC := resetToken.UsedAt.UTC() if resetTokenUsedAtUTC.Year() != usedAt.Year() || @@ -782,8 +762,7 @@ func TestCreateResetToken(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "somepassword") + u := testutils.SetupUserData(db, "alice@example.com", "somepassword") // Execute dat := url.Values{} @@ -816,8 +795,7 @@ func TestCreateResetToken(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "somepassword") + _ = testutils.SetupUserData(db, "alice@example.com", "somepassword") // Execute dat := url.Values{} @@ -846,8 +824,7 @@ func TestUpdatePassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@example.com", "oldpassword") + user := testutils.SetupUserData(db, "alice@example.com", "oldpassword") // Execute dat := url.Values{} @@ -861,10 +838,9 @@ func TestUpdatePassword(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusFound, "Status code mismsatch") - var account database.Account - testutils.MustExec(t, db.Where("user_id = ?", user.ID).First(&account), "finding account") + testutils.MustExec(t, db.Where("id = ?", user.ID).First(&user), "finding account") - passwordErr := bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte("newpassword")) + passwordErr := bcrypt.CompareHashAndPassword([]byte(user.Password.String), []byte("newpassword")) assert.Equal(t, passwordErr, nil, "Password mismatch") }) @@ -877,8 +853,7 @@ func TestUpdatePassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "oldpassword") + u := testutils.SetupUserData(db, "alice@example.com", "oldpassword") // Execute dat := url.Values{} @@ -892,9 +867,9 @@ func TestUpdatePassword(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusUnauthorized, "Status code mismsatch") - var account database.Account - testutils.MustExec(t, db.Where("user_id = ?", u.ID).First(&account), "finding account") - assert.Equal(t, acc.Password.String, account.Password.String, "password should not have been updated") + var user database.User + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding account") + assert.Equal(t, u.Password.String, user.Password.String, "password should not have been updated") }) t.Run("password too short", func(t *testing.T) { @@ -907,8 +882,7 @@ func TestUpdatePassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "oldpassword") + u := testutils.SetupUserData(db, "alice@example.com", "oldpassword") // Execute dat := url.Values{} @@ -922,9 +896,9 @@ func TestUpdatePassword(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status code mismsatch") - var account database.Account - testutils.MustExec(t, db.Where("user_id = ?", u.ID).First(&account), "finding account") - assert.Equal(t, acc.Password.String, account.Password.String, "password should not have been updated") + var user database.User + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding account") + assert.Equal(t, u.Password.String, user.Password.String, "password should not have been updated") }) t.Run("password confirmation mismatch", func(t *testing.T) { @@ -937,8 +911,7 @@ func TestUpdatePassword(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - acc := testutils.SetupAccountData(db, u, "alice@example.com", "oldpassword") + u := testutils.SetupUserData(db, "alice@example.com", "oldpassword") // Execute dat := url.Values{} @@ -952,9 +925,9 @@ func TestUpdatePassword(t *testing.T) { // Test assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status code mismsatch") - var account database.Account - testutils.MustExec(t, db.Where("user_id = ?", u.ID).First(&account), "finding account") - assert.Equal(t, acc.Password.String, account.Password.String, "password should not have been updated") + var user database.User + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding account") + assert.Equal(t, u.Password.String, user.Password.String, "password should not have been updated") }) } @@ -969,8 +942,7 @@ func TestUpdateEmail(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") + u := testutils.SetupUserData(db, "alice@example.com", "pass1234") // Execute dat := url.Values{} @@ -984,11 +956,10 @@ func TestUpdateEmail(t *testing.T) { assert.StatusCodeEquals(t, res, http.StatusFound, "Status code mismatch") var user database.User - var account database.Account testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding user") - testutils.MustExec(t, db.Where("user_id = ?", u.ID).First(&account), "finding account") + testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding account") - assert.Equal(t, account.Email.String, "alice-new@example.com", "email mismatch") + assert.Equal(t, user.Email.String, "alice-new@example.com", "email mismatch") }) t.Run("password mismatch", func(t *testing.T) { @@ -1001,8 +972,7 @@ func TestUpdateEmail(t *testing.T) { server := MustNewServer(t, &a) defer server.Close() - u := testutils.SetupUserData(db) - testutils.SetupAccountData(db, u, "alice@example.com", "pass1234") + u := testutils.SetupUserData(db, "alice@example.com", "pass1234") // Execute dat := url.Values{} @@ -1016,11 +986,9 @@ func TestUpdateEmail(t *testing.T) { assert.StatusCodeEquals(t, res, http.StatusUnauthorized, "Status code mismsatch") var user database.User - var account database.Account testutils.MustExec(t, db.Where("id = ?", u.ID).First(&user), "finding user") - testutils.MustExec(t, db.Where("user_id = ?", u.ID).First(&account), "finding account") - assert.Equal(t, account.Email.String, "alice@example.com", "email mismatch") + assert.Equal(t, user.Email.String, "alice@example.com", "email mismatch") }) } diff --git a/pkg/server/database/database.go b/pkg/server/database/database.go index eaab7c50..f73d45af 100644 --- a/pkg/server/database/database.go +++ b/pkg/server/database/database.go @@ -36,7 +36,6 @@ var ( func InitSchema(db *gorm.DB) { if err := db.AutoMigrate( &User{}, - &Account{}, &Book{}, &Note{}, &Token{}, diff --git a/pkg/server/database/models.go b/pkg/server/database/models.go index 99e41c96..576dee7f 100644 --- a/pkg/server/database/models.go +++ b/pkg/server/database/models.go @@ -61,20 +61,13 @@ type Note struct { // User is a model for a user type User struct { Model - UUID string `json:"uuid" gorm:"type:text;index"` - Account Account `gorm:"foreignKey:UserID"` + UUID string `json:"uuid" gorm:"type:text;index"` + Email NullString `gorm:"index"` + Password NullString `json:"-"` LastLoginAt *time.Time `json:"-"` MaxUSN int `json:"-" gorm:"default:0"` } -// Account is a model for an account -type Account struct { - Model - UserID int `gorm:"index"` - Email NullString - Password NullString -} - // Token is a model for a token type Token struct { Model diff --git a/pkg/server/middleware/auth.go b/pkg/server/middleware/auth.go index f74d1efa..daf92dc3 100644 --- a/pkg/server/middleware/auth.go +++ b/pkg/server/middleware/auth.go @@ -67,8 +67,6 @@ type AuthParams struct { // Auth is an authentication middleware func Auth(db *gorm.DB, next http.HandlerFunc, p *AuthParams) http.HandlerFunc { - next = WithAccount(db, next) - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { user, ok, err := AuthWithSession(db, r) if !ok { @@ -93,27 +91,6 @@ func Auth(db *gorm.DB, next http.HandlerFunc, p *AuthParams) http.HandlerFunc { ctx := context.WithUser(r.Context(), &user) next.ServeHTTP(w, r.WithContext(ctx)) }) - -} - -func WithAccount(db *gorm.DB, next http.HandlerFunc) http.HandlerFunc { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - user := context.User(r.Context()) - - var account database.Account - err := db.Where("user_id = ?", user.ID).First(&account).Error - if errors.Is(err, gorm.ErrRecordNotFound) { - DoError(w, "account not found", err, http.StatusForbidden) - return - } else if err != nil { - DoError(w, "finding account", err, http.StatusInternalServerError) - return - } - - ctx := context.WithAccount(r.Context(), &account) - - next.ServeHTTP(w, r.WithContext(ctx)) - }) } // TokenAuth is an authentication middleware with token diff --git a/pkg/server/middleware/auth_test.go b/pkg/server/middleware/auth_test.go index c0d94096..95c935a2 100644 --- a/pkg/server/middleware/auth_test.go +++ b/pkg/server/middleware/auth_test.go @@ -47,7 +47,7 @@ func TestGuestOnly(t *testing.T) { }) t.Run("logged in", func(t *testing.T) { - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") req := testutils.MakeReq(server.URL, "GET", "/", "") res := testutils.HTTPAuthDo(t, db, req, user) @@ -67,8 +67,7 @@ func TestGuestOnly(t *testing.T) { func TestAuth(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") session := database.Session{ Key: "A9xgggqzTHETy++GDi1NpDNe0iyqosPm9bitdeNGkJU=", @@ -175,7 +174,7 @@ func TestAuth(t *testing.T) { func TestTokenAuth(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") tok := database.Token{ UserID: user.ID, Type: database.TokenTypeResetPassword, @@ -241,9 +240,8 @@ func TestWithAccount(t *testing.T) { w.WriteHeader(http.StatusOK) } - t.Run("user with account", func(t *testing.T) { - user := testutils.SetupUserData(db) - testutils.SetupAccountData(db, user, "alice@test.com", "pass1234") + t.Run("authenticated user", func(t *testing.T) { + user := testutils.SetupUserData(db, "alice@test.com", "pass1234") server := httptest.NewServer(Auth(db, handler, nil)) defer server.Close() @@ -253,17 +251,4 @@ func TestWithAccount(t *testing.T) { assert.Equal(t, res.StatusCode, http.StatusOK, "status code mismatch") }) - - t.Run("user without account", func(t *testing.T) { - user := testutils.SetupUserData(db) - // Note: not creating account for this user - - server := httptest.NewServer(Auth(db, handler, nil)) - defer server.Close() - - req := testutils.MakeReq(server.URL, "GET", "/", "") - res := testutils.HTTPAuthDo(t, db, req, user) - - assert.Equal(t, res.StatusCode, http.StatusForbidden, "status code mismatch") - }) } diff --git a/pkg/server/operations/notes_test.go b/pkg/server/operations/notes_test.go index f003f7cb..a2ccb023 100644 --- a/pkg/server/operations/notes_test.go +++ b/pkg/server/operations/notes_test.go @@ -30,8 +30,8 @@ import ( func TestGetNote(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - anotherUser := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") b1 := database.Book{ UUID: testutils.MustUUID(t), @@ -98,7 +98,7 @@ func TestGetNote(t *testing.T) { func TestGetNote_nonexistent(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") b1 := database.Book{ UUID: testutils.MustUUID(t), diff --git a/pkg/server/permissions/permissions_test.go b/pkg/server/permissions/permissions_test.go index ed439d28..13f13f97 100644 --- a/pkg/server/permissions/permissions_test.go +++ b/pkg/server/permissions/permissions_test.go @@ -29,8 +29,8 @@ import ( func TestViewNote(t *testing.T) { db := testutils.InitMemoryDB(t) - user := testutils.SetupUserData(db) - anotherUser := testutils.SetupUserData(db) + user := testutils.SetupUserData(db, "user@test.com", "password123") + anotherUser := testutils.SetupUserData(db, "another@test.com", "password123") b1 := database.Book{ UUID: testutils.MustUUID(t), diff --git a/pkg/server/session/session.go b/pkg/server/session/session.go index a9494c58..d7c3d0d8 100644 --- a/pkg/server/session/session.go +++ b/pkg/server/session/session.go @@ -29,9 +29,9 @@ type Session struct { } // New returns a new session for the given user -func New(user database.User, account database.Account) Session { +func New(user database.User) Session { return Session{ UUID: user.UUID, - Email: account.Email.String, + Email: user.Email.String, } } diff --git a/pkg/server/session/session_test.go b/pkg/server/session/session_test.go index dec674b7..dddfa18b 100644 --- a/pkg/server/session/session_test.go +++ b/pkg/server/session/session_test.go @@ -27,33 +27,34 @@ import ( ) func TestNew(t *testing.T) { - u1 := database.User{UUID: "0f5f0054-d23f-4be1-b5fb-57673109e9cb"} - a1 := database.Account{Email: database.ToNullString("alice@example.com")} + u1 := database.User{ + UUID: "0f5f0054-d23f-4be1-b5fb-57673109e9cb", + Email: database.ToNullString("alice@example.com"), + } - u2 := database.User{UUID: "718a1041-bbe6-496e-bbe4-ea7e572c295e"} - a2 := database.Account{Email: database.ToNullString("bob@example.com")} + u2 := database.User{ + UUID: "718a1041-bbe6-496e-bbe4-ea7e572c295e", + Email: database.ToNullString("bob@example.com"), + } testCases := []struct { - user database.User - account database.Account + user database.User }{ { - user: u1, - account: a1, + user: u1, }, { - user: u2, - account: a2, + user: u2, }, } for idx, tc := range testCases { t.Run(fmt.Sprintf("user %d", idx), func(t *testing.T) { // Execute - got := New(tc.user, tc.account) + got := New(tc.user) expected := Session{ UUID: tc.user.UUID, - Email: tc.account.Email.String, + Email: tc.user.Email.String, } assert.DeepEqual(t, got, expected, "result mismatch") diff --git a/pkg/server/testutils/main.go b/pkg/server/testutils/main.go index 08bc07de..45c547d0 100644 --- a/pkg/server/testutils/main.go +++ b/pkg/server/testutils/main.go @@ -82,9 +82,6 @@ func ClearData(db *gorm.DB) { if err := db.Where("1 = 1").Delete(&database.Session{}).Error; err != nil { panic(errors.Wrap(err, "Failed to clear sessions")) } - if err := db.Where("1 = 1").Delete(&database.Account{}).Error; err != nil { - panic(errors.Wrap(err, "Failed to clear accounts")) - } if err := db.Where("1 = 1").Delete(&database.User{}).Error; err != nil { panic(errors.Wrap(err, "Failed to clear users")) } @@ -99,15 +96,22 @@ func MustUUID(t *testing.T) string { return uuid } -// SetupUserData creates and returns a new user for testing purposes -func SetupUserData(db *gorm.DB) database.User { +// SetupUserData creates and returns a new user with email and password for testing purposes +func SetupUserData(db *gorm.DB, email, password string) database.User { uuid, err := helpers.GenUUID() if err != nil { panic(errors.Wrap(err, "Failed to generate UUID")) } + hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) + if err != nil { + panic(errors.Wrap(err, "Failed to hash password")) + } + user := database.User{ - UUID: uuid, + UUID: uuid, + Email: database.ToNullString(email), + Password: database.ToNullString(string(hashedPassword)), } if err := db.Save(&user).Error; err != nil { @@ -117,28 +121,6 @@ func SetupUserData(db *gorm.DB) database.User { return user } -// SetupAccountData creates and returns a new account for the user -func SetupAccountData(db *gorm.DB, user database.User, email, password string) database.Account { - account := database.Account{ - UserID: user.ID, - } - if email != "" { - account.Email = database.ToNullString(email) - } - - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) - if err != nil { - panic(errors.Wrap(err, "Failed to hash password")) - } - account.Password = database.ToNullString(string(hashedPassword)) - - if err := db.Save(&account).Error; err != nil { - panic(errors.Wrap(err, "Failed to prepare account")) - } - - return account -} - // SetupSession creates and returns a new user session func SetupSession(db *gorm.DB, user database.User) database.Session { session := database.Session{ diff --git a/pkg/server/token/token_test.go b/pkg/server/token/token_test.go index 426ff3d1..c7469d4f 100644 --- a/pkg/server/token/token_test.go +++ b/pkg/server/token/token_test.go @@ -42,7 +42,7 @@ func TestCreate(t *testing.T) { db := testutils.InitMemoryDB(t) // Set up - u := testutils.SetupUserData(db) + u := testutils.SetupUserData(db, "user@test.com", "password123") // Execute tok, err := Create(db, u.ID, tc.kind) diff --git a/pkg/server/views/data.go b/pkg/server/views/data.go index 451cade8..98444364 100644 --- a/pkg/server/views/data.go +++ b/pkg/server/views/data.go @@ -50,9 +50,8 @@ type Alert struct { type Data struct { Alert *Alert // CSRF template.HTML - User *database.User - Account *database.Account - Yield map[string]interface{} + User *database.User + Yield map[string]interface{} } func getErrMessage(err error) string { diff --git a/pkg/server/views/templates/layouts/navbar.gohtml b/pkg/server/views/templates/layouts/navbar.gohtml index ea7c026f..b39a1e4e 100644 --- a/pkg/server/views/templates/layouts/navbar.gohtml +++ b/pkg/server/views/templates/layouts/navbar.gohtml @@ -41,7 +41,7 @@
diff --git a/pkg/server/views/view.go b/pkg/server/views/view.go index 3484dca8..438735a1 100644 --- a/pkg/server/views/view.go +++ b/pkg/server/views/view.go @@ -108,14 +108,13 @@ func (v *View) Render(w http.ResponseWriter, r *http.Request, data *Data, status } vd.User = context.User(r.Context()) - vd.Account = context.Account(r.Context()) // Put user data in Yield if vd.Yield == nil { vd.Yield = map[string]interface{}{} } - if vd.Account != nil { - vd.Yield["Email"] = vd.Account.Email.String + if vd.User != nil { + vd.Yield["Email"] = vd.User.Email.String } vd.Yield["CurrentPath"] = r.URL.Path vd.Yield["Standalone"] = buildinfo.Standalone From e3380a4dfafe88e7e3197619b8d1093e466fdf45 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 19 Oct 2025 21:42:53 -0700 Subject: [PATCH 20/33] Remove unused templates (#702) --- pkg/server/tmpl/app.go | 103 ------------- pkg/server/tmpl/app_test.go | 51 ------- pkg/server/tmpl/data.go | 141 ------------------ pkg/server/tmpl/data_test.go | 68 --------- pkg/server/tmpl/tmpl.go | 29 ---- pkg/server/views/templates/books/index.gohtml | 20 --- pkg/server/views/templates/books/show.gohtml | 4 - pkg/server/views/templates/icons/book.gohtml | 17 --- pkg/server/views/templates/icons/caret.gohtml | 26 ---- pkg/server/views/templates/notes/index.gohtml | 91 ----------- pkg/server/views/templates/notes/show.gohtml | 33 ---- .../templates/partials/page_toolbar.gohtml | 5 - .../views/templates/partials/time.gohtml | 13 -- 13 files changed, 601 deletions(-) delete mode 100644 pkg/server/tmpl/app.go delete mode 100644 pkg/server/tmpl/app_test.go delete mode 100644 pkg/server/tmpl/data.go delete mode 100644 pkg/server/tmpl/data_test.go delete mode 100644 pkg/server/tmpl/tmpl.go delete mode 100644 pkg/server/views/templates/books/index.gohtml delete mode 100644 pkg/server/views/templates/books/show.gohtml delete mode 100644 pkg/server/views/templates/icons/book.gohtml delete mode 100644 pkg/server/views/templates/icons/caret.gohtml delete mode 100644 pkg/server/views/templates/notes/index.gohtml delete mode 100644 pkg/server/views/templates/notes/show.gohtml delete mode 100644 pkg/server/views/templates/partials/page_toolbar.gohtml delete mode 100644 pkg/server/views/templates/partials/time.gohtml diff --git a/pkg/server/tmpl/app.go b/pkg/server/tmpl/app.go deleted file mode 100644 index 7f084a85..00000000 --- a/pkg/server/tmpl/app.go +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ - -package tmpl - -import ( - "bytes" - "html/template" - "net/http" - "regexp" - - "gorm.io/gorm" - "github.com/pkg/errors" -) - -// routes -var notesPathRegex = regexp.MustCompile("^/notes/([^/]+)$") - -// template names -var templateIndex = "index" -var templateNoteMetaTags = "note_metatags" - -// AppShell represents the application in HTML -type AppShell struct { - DB *gorm.DB - T *template.Template -} - -// ErrNotFound is an error indicating that a resource was not found -var ErrNotFound = errors.New("not found") - -// NewAppShell parses the templates for the application -func NewAppShell(db *gorm.DB, content []byte) (AppShell, error) { - t, err := template.New(templateIndex).Parse(string(content)) - if err != nil { - return AppShell{}, errors.Wrap(err, "parsing the index template") - } - - _, err = t.New(templateNoteMetaTags).Parse(noteMetaTags) - if err != nil { - return AppShell{}, errors.Wrap(err, "parsing the note meta tags template") - } - - return AppShell{DB: db, T: t}, nil -} - -// Execute executes the index template -func (a AppShell) Execute(r *http.Request) ([]byte, error) { - data, err := a.getData(r) - if err != nil { - return nil, errors.Wrap(err, "getting data") - } - - var buf bytes.Buffer - if err := a.T.ExecuteTemplate(&buf, templateIndex, data); err != nil { - return nil, errors.Wrap(err, "executing template") - } - - return buf.Bytes(), nil -} - -func (a AppShell) getData(r *http.Request) (tmplData, error) { - path := r.URL.Path - - if ok, params := matchPath(path, notesPathRegex); ok { - p, err := a.newNotePage(r, params[0]) - if err != nil { - return tmplData{}, errors.Wrap(err, "instantiating note page") - } - - return p.getData() - } - - p := defaultPage{} - return p.getData(), nil -} - -// matchPath checks if the given path matches the given regular expressions -// and returns a boolean as well as any parameters from regex capture groups. -func matchPath(p string, reg *regexp.Regexp) (bool, []string) { - match := notesPathRegex.FindStringSubmatch(p) - - if len(match) > 0 { - return true, match[1:] - } - - return false, nil -} diff --git a/pkg/server/tmpl/app_test.go b/pkg/server/tmpl/app_test.go deleted file mode 100644 index 8772bf92..00000000 --- a/pkg/server/tmpl/app_test.go +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ - -package tmpl - -import ( - "net/http" - "testing" - - "github.com/dnote/dnote/pkg/assert" - "github.com/dnote/dnote/pkg/server/testutils" - "github.com/pkg/errors" -) - -func TestAppShellExecute(t *testing.T) { - t.Run("home", func(t *testing.T) { - db := testutils.InitMemoryDB(t) - - a, err := NewAppShell(db, []byte("{{ .Title }}{{ .MetaTags }}")) - if err != nil { - t.Fatal(errors.Wrap(err, "preparing app shell")) - } - - r, err := http.NewRequest("GET", "http://mock.url/", nil) - if err != nil { - t.Fatal(errors.Wrap(err, "preparing request")) - } - - b, err := a.Execute(r) - if err != nil { - t.Fatal(errors.Wrap(err, "executing")) - } - - assert.Equal(t, string(b), "Dnote", "result mismatch") - }) -} diff --git a/pkg/server/tmpl/data.go b/pkg/server/tmpl/data.go deleted file mode 100644 index 186c1467..00000000 --- a/pkg/server/tmpl/data.go +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ - -package tmpl - -import ( - "bytes" - "fmt" - "html/template" - "net/http" - "regexp" - "strings" - "time" - - "github.com/dnote/dnote/pkg/server/database" - "github.com/dnote/dnote/pkg/server/middleware" - "github.com/dnote/dnote/pkg/server/operations" - "github.com/pkg/errors" -) - -var newlineRegexp = regexp.MustCompile(`\r?\n`) - -// tmplData is the data to be passed to the app shell template -type tmplData struct { - Title string - MetaTags template.HTML -} - -type noteMetaTagsData struct { - Title string - Description string -} - -type notePage struct { - Note database.Note - T *template.Template -} - -func (a AppShell) newNotePage(r *http.Request, noteUUID string) (notePage, error) { - user, _, err := middleware.AuthWithSession(a.DB, r) - if err != nil { - return notePage{}, errors.Wrap(err, "authenticating with session") - } - - note, ok, err := operations.GetNote(a.DB, noteUUID, &user) - - if !ok { - return notePage{}, ErrNotFound - } - if err != nil { - return notePage{}, errors.Wrap(err, "getting note") - } - - return notePage{note, a.T}, nil -} - -func (p notePage) getTitle() string { - note := p.Note - date := time.Unix(0, note.AddedOn).Format("Jan 2 2006") - - return fmt.Sprintf("Note: %s (%s)", note.Book.Label, date) -} - -func excerpt(s string, maxLen int) string { - if len(s) > maxLen { - - var lastIdx int - if maxLen > 3 { - lastIdx = maxLen - 3 - } else { - lastIdx = maxLen - } - - return s[:lastIdx] + "..." - } - - return s -} - -func formatMetaDescContent(s string) string { - desc := excerpt(s, 200) - desc = strings.Trim(desc, " ") - - return newlineRegexp.ReplaceAllString(desc, " ") -} - -func (p notePage) getMetaTags() (template.HTML, error) { - title := p.getTitle() - desc := formatMetaDescContent(p.Note.Body) - - data := noteMetaTagsData{ - Title: title, - Description: desc, - } - - var buf bytes.Buffer - if err := p.T.ExecuteTemplate(&buf, templateNoteMetaTags, data); err != nil { - return "", errors.Wrap(err, "executing template") - } - - return template.HTML(buf.String()), nil -} - -func (p notePage) getData() (tmplData, error) { - mt, err := p.getMetaTags() - if err != nil { - return tmplData{}, errors.Wrap(err, "getting meta tags") - } - - dat := tmplData{ - Title: p.getTitle(), - MetaTags: mt, - } - - return dat, nil -} - -type defaultPage struct { -} - -func (p defaultPage) getData() tmplData { - return tmplData{ - Title: "Dnote", - MetaTags: "", - } -} diff --git a/pkg/server/tmpl/data_test.go b/pkg/server/tmpl/data_test.go deleted file mode 100644 index c072d12e..00000000 --- a/pkg/server/tmpl/data_test.go +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ - -package tmpl - -import ( - "html/template" - "testing" - "time" - - "github.com/dnote/dnote/pkg/assert" - "github.com/dnote/dnote/pkg/server/database" - "github.com/dnote/dnote/pkg/server/testutils" - "github.com/pkg/errors" -) - -func TestDefaultPageGetData(t *testing.T) { - p := defaultPage{} - - result := p.getData() - - assert.Equal(t, result.MetaTags, template.HTML(""), "MetaTags mismatch") - assert.Equal(t, result.Title, "Dnote", "Title mismatch") -} - -func TestNotePageGetData(t *testing.T) { - // Set time.Local to UTC for deterministic test - time.Local = time.UTC - - db := testutils.InitMemoryDB(t) - a, err := NewAppShell(db, nil) - if err != nil { - t.Fatal(errors.Wrap(err, "preparing app shell")) - } - - p := notePage{ - Note: database.Note{ - Book: database.Book{ - Label: "vocabulary", - }, - AddedOn: time.Date(2019, time.January, 2, 0, 0, 0, 0, time.UTC).UnixNano(), - }, - T: a.T, - } - - result, err := p.getData() - if err != nil { - t.Fatal(errors.Wrap(err, "executing")) - } - - assert.NotEqual(t, result.MetaTags, template.HTML(""), "MetaTags should not be empty") - assert.Equal(t, result.Title, "Note: vocabulary (Jan 2 2019)", "Title mismatch") -} diff --git a/pkg/server/tmpl/tmpl.go b/pkg/server/tmpl/tmpl.go deleted file mode 100644 index fbc13398..00000000 --- a/pkg/server/tmpl/tmpl.go +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ - -package tmpl - -var noteMetaTags = ` - - - - - - - -` diff --git a/pkg/server/views/templates/books/index.gohtml b/pkg/server/views/templates/books/index.gohtml deleted file mode 100644 index 46ebbecc..00000000 --- a/pkg/server/views/templates/books/index.gohtml +++ /dev/null @@ -1,20 +0,0 @@ -{{define "yield"}} -
-{{end}} diff --git a/pkg/server/views/templates/books/show.gohtml b/pkg/server/views/templates/books/show.gohtml deleted file mode 100644 index 4d84d095..00000000 --- a/pkg/server/views/templates/books/show.gohtml +++ /dev/null @@ -1,4 +0,0 @@ -{{define "yield"}} - content - {{ .Note.Body }} -{{end}} diff --git a/pkg/server/views/templates/icons/book.gohtml b/pkg/server/views/templates/icons/book.gohtml deleted file mode 100644 index a04a3e68..00000000 --- a/pkg/server/views/templates/icons/book.gohtml +++ /dev/null @@ -1,17 +0,0 @@ -{{define "book"}} - - Book - Icon depicting a book - - -{{end}} diff --git a/pkg/server/views/templates/icons/caret.gohtml b/pkg/server/views/templates/icons/caret.gohtml deleted file mode 100644 index 0a9f60a0..00000000 --- a/pkg/server/views/templates/icons/caret.gohtml +++ /dev/null @@ -1,26 +0,0 @@ -{{define "caret"}} - - - - -{{end}} diff --git a/pkg/server/views/templates/notes/index.gohtml b/pkg/server/views/templates/notes/index.gohtml deleted file mode 100644 index 168430f5..00000000 --- a/pkg/server/views/templates/notes/index.gohtml +++ /dev/null @@ -1,91 +0,0 @@ -{{define "yield"}} -
-

Notes

- - {{template "pageToolbar" dict "data" . "class" "toolbar"}} - -
- {{if eq (len .NoteGroups) 0 }} -
No notes found.
- {{end}} - - {{range .NoteGroups}} - {{template "noteGroup" .}} - {{end}} -
-
-{{end}} - -{{define "noteGroup"}} -
-
-

- -

-
- -
    - {{range .Data}} - {{template "noteItem" .}} - {{end}} -
-
-{{end}} - -{{define "noteItem"}} -
  • - -
    -
    -

    - {{ .Book.Label }} -

    - - {{template "time" dict "value" .UpdatedAt "text" (timeAgo .UpdatedAt)}} -
    - -
    - {{ excerpt .Body 160 }} -
    -
    -
    -
  • -{{end}} - -{{define "pageToolbarContent"}} - -{{end}} - -{{define "pager"}} - -{{$ariaLabel := ""}} -{{if eq .direction "left"}} - {{$ariaLabel = "Previous page"}} -{{else}} - {{$ariaLabel = "Next page"}} -{{end}} - -{{if .disabled}} - - {{template "caret" dict "direction" .direction "stroke" "gray"}} - -{{else}} - - {{template "caret" dict "direction" .direction "stroke" "black"}} - -{{end}} -{{end}} diff --git a/pkg/server/views/templates/notes/show.gohtml b/pkg/server/views/templates/notes/show.gohtml deleted file mode 100644 index 7051bee4..00000000 --- a/pkg/server/views/templates/notes/show.gohtml +++ /dev/null @@ -1,33 +0,0 @@ -{{define "yield"}} -
    -
    -
    -
    -
    - {{template "book" dict "fill" "#000000"}} - -

    - - {{ .Note.Book.Label }} - -

    -
    -
    - - -
    -
    - {{ .Content }} -
    -
    - -
    -
    - Last edit: - {{ timeFormat .Note.UpdatedAt "January 02, 2006" }} -
    -
    -
    -
    -
    -{{end}} diff --git a/pkg/server/views/templates/partials/page_toolbar.gohtml b/pkg/server/views/templates/partials/page_toolbar.gohtml deleted file mode 100644 index 4d1abdfd..00000000 --- a/pkg/server/views/templates/partials/page_toolbar.gohtml +++ /dev/null @@ -1,5 +0,0 @@ -{{define "pageToolbar"}} -
    - {{template "pageToolbarContent" .data}} -
    -{{end}} diff --git a/pkg/server/views/templates/partials/time.gohtml b/pkg/server/views/templates/partials/time.gohtml deleted file mode 100644 index b05b3a86..00000000 --- a/pkg/server/views/templates/partials/time.gohtml +++ /dev/null @@ -1,13 +0,0 @@ -{{define "time"}} - -{{$mobileText := defaultValue .mobileText .text}} - - - - -{{end}} From f6a4c6344ccbdb964954a6460fa9012225a1ce28 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 25 Oct 2025 20:51:57 -0700 Subject: [PATCH 21/33] Remove public from CLI (#703) * Remove public from CLI * Write migration and test * Use in-memory db for a test server * Simplify CLI test db teardown * Restructure packages to reduce duplication --- Makefile | 11 +- pkg/cli/COMMANDS.md | 2 +- pkg/cli/client/client.go | 5 +- pkg/cli/cmd/add/add.go | 2 +- pkg/cli/cmd/sync/sync.go | 14 +- pkg/cli/cmd/sync/sync_test.go | 130 +- pkg/cli/context/files.go | 51 + pkg/cli/context/files_test.go | 65 + pkg/cli/context/testutils.go | 77 +- pkg/cli/database/models.go | 12 +- pkg/cli/database/models_test.go | 83 +- pkg/cli/database/queries.go | 2 - pkg/cli/database/queries_test.go | 39 +- pkg/cli/database/schema.sql | 40 + pkg/cli/database/schema/main.go | 166 ++ pkg/cli/database/schema/main_test.go | 84 + pkg/cli/database/testutils.go | 132 +- pkg/cli/infra/init.go | 33 +- pkg/cli/infra/init_test.go | 6 +- pkg/cli/main_test.go | 94 +- .../migrate/fixtures/local-12-pre-schema.sql | 8 - .../migrate/fixtures/local-14-pre-schema.sql | 42 + pkg/cli/migrate/legacy_test.go | 14 +- pkg/cli/migrate/migrate.go | 1 + pkg/cli/migrate/migrate_test.go | 200 ++- pkg/cli/migrate/migrations.go | 12 + pkg/cli/testutils/main.go | 11 +- pkg/cli/ui/editor_test.go | 18 +- pkg/cli/utils/files.go | 18 + .../sync/main_test.go => utils/files_test.go} | 30 +- pkg/clock/clock.go | 8 +- pkg/e2e/sync_test.go | 1546 ++++++++--------- pkg/server/.env.test | 1 - pkg/server/app/notes_test.go | 6 +- pkg/server/testutils/main.go | 20 - scripts/cli/test.sh | 7 +- scripts/e2e/test.sh | 6 +- scripts/server/test-local.sh | 4 - 38 files changed, 1647 insertions(+), 1353 deletions(-) create mode 100644 pkg/cli/context/files.go create mode 100644 pkg/cli/context/files_test.go create mode 100644 pkg/cli/database/schema.sql create mode 100644 pkg/cli/database/schema/main.go create mode 100644 pkg/cli/database/schema/main_test.go create mode 100644 pkg/cli/migrate/fixtures/local-14-pre-schema.sql rename pkg/cli/{cmd/sync/main_test.go => utils/files_test.go} (55%) delete mode 100644 pkg/server/.env.test diff --git a/Makefile b/Makefile index 5037c408..c38819c0 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ endif test: test-cli test-api test-e2e .PHONY: test -test-cli: +test-cli: generate-cli-schema @echo "==> running CLI test" @(${currentDir}/scripts/cli/test.sh) .PHONY: test-cli @@ -76,7 +76,14 @@ endif @(cd ${currentDir}/host/docker && ./build.sh $(version) $(platform)) .PHONY: build-server-docker -build-cli: +generate-cli-schema: + @echo "==> generating CLI database schema" + @mkdir -p pkg/cli/database + @touch pkg/cli/database/schema.sql + @go run -tags fts5 ./pkg/cli/database/schema +.PHONY: generate-cli-schema + +build-cli: generate-cli-schema ifeq ($(debug), true) @echo "==> building cli in dev mode" @${currentDir}/scripts/cli/dev.sh diff --git a/pkg/cli/COMMANDS.md b/pkg/cli/COMMANDS.md index 73d34007..c3402152 100644 --- a/pkg/cli/COMMANDS.md +++ b/pkg/cli/COMMANDS.md @@ -96,7 +96,7 @@ dnote find "merge sort" -b algorithm _alias: s_ -Sync notes with Dnote server. All your data is encrypted before being sent to the server. +Sync notes with Dnote server. ## dnote login diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index 86df4374..1e122a3d 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -246,7 +246,6 @@ type SyncFragNote struct { AddedOn int64 `json:"added_on"` EditedOn int64 `json:"edited_on"` Body string `json:"content"` - Public bool `json:"public"` Deleted bool `json:"deleted"` } @@ -458,7 +457,6 @@ func CreateNote(ctx context.DnoteCtx, bookUUID, content string) (CreateNoteResp, type updateNotePayload struct { BookUUID *string `json:"book_uuid"` Body *string `json:"content"` - Public *bool `json:"public"` } // UpdateNoteResp is the response from create book api @@ -468,11 +466,10 @@ type UpdateNoteResp struct { } // UpdateNote updates a note in the server -func UpdateNote(ctx context.DnoteCtx, uuid, bookUUID, content string, public bool) (UpdateNoteResp, error) { +func UpdateNote(ctx context.DnoteCtx, uuid, bookUUID, content string) (UpdateNoteResp, error) { payload := updateNotePayload{ BookUUID: &bookUUID, Body: &content, - Public: &public, } b, err := json.Marshal(payload) if err != nil { diff --git a/pkg/cli/cmd/add/add.go b/pkg/cli/cmd/add/add.go index aa8c8453..2d6591a2 100644 --- a/pkg/cli/cmd/add/add.go +++ b/pkg/cli/cmd/add/add.go @@ -173,7 +173,7 @@ func writeNote(ctx context.DnoteCtx, bookLabel string, content string, ts int64) return 0, errors.Wrap(err, "generating uuid") } - n := database.NewNote(noteUUID, bookUUID, content, ts, 0, 0, false, false, true) + n := database.NewNote(noteUUID, bookUUID, content, ts, 0, 0, false, true) err = n.Insert(tx) if err != nil { diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index ec66a2cb..fd870751 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -280,8 +280,8 @@ func mergeNote(tx *database.DB, serverNote client.SyncFragNote, localNote databa // if the local copy is deleted, and it was edited on the server, override with server values and mark it not dirty. if localNote.Deleted { - if _, err := tx.Exec("UPDATE notes SET usn = ?, book_uuid = ?, body = ?, edited_on = ?, deleted = ?, public = ?, dirty = ? WHERE uuid = ?", - serverNote.USN, serverNote.BookUUID, serverNote.Body, serverNote.EditedOn, serverNote.Deleted, serverNote.Public, false, serverNote.UUID); err != nil { + if _, err := tx.Exec("UPDATE notes SET usn = ?, book_uuid = ?, body = ?, edited_on = ?, deleted = ?, dirty = ? WHERE uuid = ?", + serverNote.USN, serverNote.BookUUID, serverNote.Body, serverNote.EditedOn, serverNote.Deleted, false, serverNote.UUID); err != nil { return errors.Wrapf(err, "updating local note %s", serverNote.UUID) } @@ -311,7 +311,7 @@ func stepSyncNote(tx *database.DB, n client.SyncFragNote) error { // if note exists in the server and does not exist in the client, insert the note. if err == sql.ErrNoRows { - note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, false) + note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, false) if err := note.Insert(tx); err != nil { return errors.Wrapf(err, "inserting note with uuid %s", n.UUID) @@ -335,7 +335,7 @@ func fullSyncNote(tx *database.DB, n client.SyncFragNote) error { // if note exists in the server and does not exist in the client, insert the note. if err == sql.ErrNoRows { - note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, false) + note := database.NewNote(n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, false) if err := note.Insert(tx); err != nil { return errors.Wrapf(err, "inserting note with uuid %s", n.UUID) @@ -758,7 +758,7 @@ func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) { func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) { isBehind := false - rows, err := tx.Query("SELECT uuid, book_uuid, body, public, deleted, usn, added_on FROM notes WHERE dirty") + rows, err := tx.Query("SELECT uuid, book_uuid, body, deleted, usn, added_on FROM notes WHERE dirty") if err != nil { return isBehind, errors.Wrap(err, "getting syncable notes") } @@ -767,7 +767,7 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) { for rows.Next() { var note database.Note - if err = rows.Scan(¬e.UUID, ¬e.BookUUID, ¬e.Body, ¬e.Public, ¬e.Deleted, ¬e.USN, ¬e.AddedOn); err != nil { + if err = rows.Scan(¬e.UUID, ¬e.BookUUID, ¬e.Body, ¬e.Deleted, ¬e.USN, ¬e.AddedOn); err != nil { return isBehind, errors.Wrap(err, "scanning a syncable note") } @@ -822,7 +822,7 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) { respUSN = resp.Result.USN } else { - resp, err := client.UpdateNote(ctx, note.UUID, note.BookUUID, note.Body, note.Public) + resp, err := client.UpdateNote(ctx, note.UUID, note.BookUUID, note.Body) if err != nil { return isBehind, errors.Wrap(err, "updating a note") } diff --git a/pkg/cli/cmd/sync/sync_test.go b/pkg/cli/cmd/sync/sync_test.go index 34f0c9df..828179f5 100644 --- a/pkg/cli/cmd/sync/sync_test.go +++ b/pkg/cli/cmd/sync/sync_test.go @@ -36,6 +36,7 @@ import ( "github.com/pkg/errors" ) + func TestProcessFragments(t *testing.T) { fragments := []client.SyncFragment{ { @@ -106,8 +107,7 @@ func TestProcessFragments(t *testing.T) { func TestGetLastSyncAt(t *testing.T) { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "setting up last_sync_at", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastSyncAt, 1541108743) // exec @@ -129,8 +129,7 @@ func TestGetLastSyncAt(t *testing.T) { func TestGetLastMaxUSN(t *testing.T) { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "setting up last_max_usn", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastMaxUSN, 20001) // exec @@ -176,8 +175,7 @@ func TestResolveLabel(t *testing.T) { for idx, tc := range testCases { func() { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b1-uuid", "js") database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b2-uuid", "css_2") @@ -206,8 +204,7 @@ func TestResolveLabel(t *testing.T) { func TestSyncDeleteNote(t *testing.T) { t.Run("exists on server only", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) // execute tx, err := db.Begin() @@ -235,8 +232,7 @@ func TestSyncDeleteNote(t *testing.T) { b1UUID := testutils.MustGenerateUUID(t) // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting b1 for test case %d", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") database.MustExec(t, "inserting n1 for test case %d", db, "INSERT INTO notes (uuid, book_uuid, usn, body, added_on, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?)", "n1-uuid", b1UUID, 10, "n1 body", 1541108743, false, true) @@ -305,8 +301,7 @@ func TestSyncDeleteNote(t *testing.T) { b1UUID := testutils.MustGenerateUUID(t) // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting b1 for test case %d", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") database.MustExec(t, "inserting n1 for test case %d", db, "INSERT INTO notes (uuid, book_uuid, usn, body, added_on, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?)", "n1-uuid", b1UUID, 10, "n1 body", 1541108743, false, false) @@ -361,8 +356,7 @@ func TestSyncDeleteNote(t *testing.T) { func TestSyncDeleteBook(t *testing.T) { t.Run("exists on server only", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting b1 for test case %d", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b1-uuid", "b1-label") var b1 database.Book @@ -406,8 +400,7 @@ func TestSyncDeleteBook(t *testing.T) { b1UUID := testutils.MustGenerateUUID(t) // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting b1 for test case %d", db, "INSERT INTO books (uuid, label, usn, dirty) VALUES (?, ?, ?, ?)", b1UUID, "b1-label", 12, true) database.MustExec(t, "inserting n1 for test case %d", db, "INSERT INTO notes (uuid, book_uuid, usn, body, added_on, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?)", "n1-uuid", b1UUID, 10, "n1 body", 1541108743, false, true) @@ -472,8 +465,7 @@ func TestSyncDeleteBook(t *testing.T) { b2UUID := testutils.MustGenerateUUID(t) // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting b1 for test case %d", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") database.MustExec(t, "inserting n1 for test case %d", db, "INSERT INTO notes (uuid, book_uuid, usn, body, added_on, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?)", "n1-uuid", b1UUID, 10, "n1 body", 1541108743, false, false) @@ -538,8 +530,7 @@ func TestSyncDeleteBook(t *testing.T) { b1UUID := testutils.MustGenerateUUID(t) // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting b1 for test case %d", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") database.MustExec(t, "inserting n1 for test case %d", db, "INSERT INTO notes (uuid, book_uuid, usn, body, added_on, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?)", "n1-uuid", b1UUID, 10, "n1 body", 1541108743, false, true) @@ -590,8 +581,7 @@ func TestSyncDeleteBook(t *testing.T) { func TestFullSyncNote(t *testing.T) { t.Run("exists on server only", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") @@ -822,8 +812,7 @@ n1 body edited for idx, tc := range testCases { func() { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, fmt.Sprintf("inserting b1 for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") database.MustExec(t, fmt.Sprintf("inserting b2 for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b2UUID, "b2-label") @@ -884,8 +873,7 @@ n1 body edited func TestFullSyncBook(t *testing.T) { t.Run("exists on server only", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", b1UUID, 555, "b1-label", true, false) @@ -1023,8 +1011,7 @@ func TestFullSyncBook(t *testing.T) { for idx, tc := range testCases { func() { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", b1UUID, tc.clientUSN, tc.clientLabel, tc.clientDirty, tc.clientDeleted) @@ -1076,8 +1063,7 @@ func TestFullSyncBook(t *testing.T) { func TestStepSyncNote(t *testing.T) { t.Run("exists on server only", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") @@ -1234,8 +1220,7 @@ n1 body edited for idx, tc := range testCases { func() { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, fmt.Sprintf("inserting b1 for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1-label") database.MustExec(t, fmt.Sprintf("inserting b2 for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b2UUID, "b2-label") @@ -1296,8 +1281,7 @@ n1 body edited func TestStepSyncBook(t *testing.T) { t.Run("exists on server only", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", b1UUID, 555, "b1-label", true, false) @@ -1419,8 +1403,7 @@ func TestStepSyncBook(t *testing.T) { for idx, tc := range testCases { func() { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", b1UUID, tc.clientUSN, tc.clientLabel, tc.clientDirty, tc.clientDeleted) @@ -1483,8 +1466,7 @@ func TestStepSyncBook(t *testing.T) { func TestMergeBook(t *testing.T) { t.Run("insert, no duplicates", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) // test tx, err := db.Begin() @@ -1527,8 +1509,7 @@ func TestMergeBook(t *testing.T) { t.Run("insert, 1 duplicate", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", "b1-uuid", 1, "foo", false, false) // test @@ -1579,8 +1560,7 @@ func TestMergeBook(t *testing.T) { t.Run("insert, 3 duplicates", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", "b1-uuid", 1, "foo", false, false) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", "b2-uuid", 2, "foo_2", true, false) @@ -1648,8 +1628,7 @@ func TestMergeBook(t *testing.T) { t.Run("update, no duplicates", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) // test tx, err := db.Begin() @@ -1695,8 +1674,7 @@ func TestMergeBook(t *testing.T) { t.Run("update, 1 duplicate", func(t *testing.T) { // set up - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", "b1-uuid", 1, "foo", false, false) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", "b2-uuid", 2, "bar", false, false) @@ -1749,8 +1727,7 @@ func TestMergeBook(t *testing.T) { t.Run("update, 3 duplicate", func(t *testing.T) { // set uj - db := database.InitTestDB(t, dbPath, nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", "b1-uuid", 1, "foo", false, false) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, usn, label, dirty, deleted) VALUES (?, ?, ?, ?, ?)", "b2-uuid", 2, "bar", false, false) @@ -1820,11 +1797,8 @@ func TestMergeBook(t *testing.T) { func TestSaveServerState(t *testing.T) { // set up - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - testutils.Login(t, &ctx) - - db := ctx.DB + db := database.InitTestMemoryDB(t) + testutils.LoginDB(t, db) database.MustExec(t, "inserting last synced at", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastSyncAt, int64(1231108742)) database.MustExec(t, "inserting last max usn", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastMaxUSN, 8) @@ -1864,8 +1838,7 @@ func TestSaveServerState(t *testing.T) { // are updated accordingly based on the server response. func TestSendBooks(t *testing.T) { // set up - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) testutils.Login(t, &ctx) db := ctx.DB @@ -1900,7 +1873,7 @@ func TestSendBooks(t *testing.T) { var updatesUUIDs []string var deletedUUIDs []string - // fire up a test server. It decrypts the payload for test purposes. + // fire up a test server ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.String() == "/v3/books" && r.Method == "POST" { var payload client.CreateBookPayload @@ -1967,7 +1940,7 @@ func TestSendBooks(t *testing.T) { // test - // First, decrypt data so that they can be asserted + // First, sort data so that they can be asserted sort.SliceStable(createdLabels, func(i, j int) bool { return strings.Compare(createdLabels[i], createdLabels[j]) < 0 }) @@ -2097,9 +2070,8 @@ func TestSendBooks_isBehind(t *testing.T) { for idx, tc := range testCases { func() { // set up - ctx := context.InitTestCtx(t, paths, nil) + ctx := context.InitTestCtx(t) ctx.APIEndpoint = ts.URL - defer context.TeardownTestCtx(t, ctx) testutils.Login(t, &ctx) db := ctx.DB @@ -2145,9 +2117,8 @@ func TestSendBooks_isBehind(t *testing.T) { for idx, tc := range testCases { func() { // set up - ctx := context.InitTestCtx(t, paths, nil) + ctx := context.InitTestCtx(t) ctx.APIEndpoint = ts.URL - defer context.TeardownTestCtx(t, ctx) testutils.Login(t, &ctx) db := ctx.DB @@ -2193,9 +2164,8 @@ func TestSendBooks_isBehind(t *testing.T) { for idx, tc := range testCases { func() { // set up - ctx := context.InitTestCtx(t, paths, nil) + ctx := context.InitTestCtx(t) ctx.APIEndpoint = ts.URL - defer context.TeardownTestCtx(t, ctx) testutils.Login(t, &ctx) db := ctx.DB @@ -2228,8 +2198,7 @@ func TestSendBooks_isBehind(t *testing.T) { // uuid from the incoming data. func TestSendNotes(t *testing.T) { // set up - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) testutils.Login(t, &ctx) db := ctx.DB @@ -2264,7 +2233,7 @@ func TestSendNotes(t *testing.T) { var updatedUUIDs []string var deletedUUIDs []string - // fire up a test server. It decrypts the payload for test purposes. + // fire up a test server ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.String() == "/v3/notes" && r.Method == "POST" { var payload client.CreateNotePayload @@ -2381,8 +2350,7 @@ func TestSendNotes(t *testing.T) { func TestSendNotes_addedOn(t *testing.T) { // set up - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) testutils.Login(t, &ctx) db := ctx.DB @@ -2393,7 +2361,7 @@ func TestSendNotes_addedOn(t *testing.T) { b1UUID := "b1-uuid" database.MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, usn, body, added_on, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?)", "n1-uuid", b1UUID, 0, "n1-body", 1541108743, false, true) - // fire up a test server. It decrypts the payload for test purposes. + // fire up a test server ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.String() == "/v3/notes" && r.Method == "POST" { resp := client.CreateNoteResp{ @@ -2513,8 +2481,7 @@ func TestSendNotes_isBehind(t *testing.T) { for idx, tc := range testCases { func() { // set up - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) testutils.Login(t, &ctx) ctx.APIEndpoint = ts.URL @@ -2562,8 +2529,7 @@ func TestSendNotes_isBehind(t *testing.T) { for idx, tc := range testCases { func() { // set up - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) testutils.Login(t, &ctx) ctx.APIEndpoint = ts.URL @@ -2611,8 +2577,7 @@ func TestSendNotes_isBehind(t *testing.T) { for idx, tc := range testCases { func() { // set up - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) testutils.Login(t, &ctx) ctx.APIEndpoint = ts.URL @@ -2777,8 +2742,7 @@ n1 body edited for idx, tc := range testCases { func() { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, fmt.Sprintf("inserting b1 for test case %d", idx), db, "INSERT INTO books (uuid, label, usn, dirty) VALUES (?, ?, ?, ?)", b1UUID, "b1-label", 5, false) database.MustExec(t, fmt.Sprintf("inserting b2 for test case %d", idx), db, "INSERT INTO books (uuid, label, usn, dirty) VALUES (?, ?, ?, ?)", b2UUID, "b2-label", 6, false) @@ -2859,8 +2823,7 @@ n1 body edited func TestCheckBookPristine(t *testing.T) { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, dirty) VALUES (?, ?, ?, ?)", "b1-uuid", "b1-label", 5, false) database.MustExec(t, "inserting b2", db, "INSERT INTO books (uuid, label, usn, dirty) VALUES (?, ?, ?, ?)", "b2-uuid", "b2-label", 6, false) @@ -3033,8 +2996,7 @@ func TestCheckBookInList(t *testing.T) { func TestCleanLocalNotes(t *testing.T) { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) list := syncList{ Notes: map[string]client.SyncFragNote{ @@ -3105,8 +3067,7 @@ func TestCleanLocalNotes(t *testing.T) { func TestCleanLocalBooks(t *testing.T) { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) list := syncList{ Notes: map[string]client.SyncFragNote{ @@ -3173,8 +3134,7 @@ func TestCleanLocalBooks(t *testing.T) { func TestPrepareEmptyServerSync(t *testing.T) { // set up - db := database.InitTestDB(t, "../../tmp/.dnote", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) // Setup: local has synced data (usn > 0, dirty = false) and some deleted items database.MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", "b1-uuid", "b1-label", 5, false, false) diff --git a/pkg/cli/context/files.go b/pkg/cli/context/files.go new file mode 100644 index 00000000..098b2cd5 --- /dev/null +++ b/pkg/cli/context/files.go @@ -0,0 +1,51 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package context + +import ( + "path/filepath" + + "github.com/dnote/dnote/pkg/cli/consts" + "github.com/dnote/dnote/pkg/cli/utils" + "github.com/pkg/errors" +) + +// InitDnoteDirs creates the dnote directories if they don't already exist. +func InitDnoteDirs(paths Paths) error { + if paths.Config != "" { + configDir := filepath.Join(paths.Config, consts.DnoteDirName) + if err := utils.EnsureDir(configDir); err != nil { + return errors.Wrap(err, "initializing config dir") + } + } + if paths.Data != "" { + dataDir := filepath.Join(paths.Data, consts.DnoteDirName) + if err := utils.EnsureDir(dataDir); err != nil { + return errors.Wrap(err, "initializing data dir") + } + } + if paths.Cache != "" { + cacheDir := filepath.Join(paths.Cache, consts.DnoteDirName) + if err := utils.EnsureDir(cacheDir); err != nil { + return errors.Wrap(err, "initializing cache dir") + } + } + + return nil +} diff --git a/pkg/cli/context/files_test.go b/pkg/cli/context/files_test.go new file mode 100644 index 00000000..2422a795 --- /dev/null +++ b/pkg/cli/context/files_test.go @@ -0,0 +1,65 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package context + +import ( + "os" + "path/filepath" + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/consts" +) + +func assertDirsExist(t *testing.T, paths Paths) { + configDir := filepath.Join(paths.Config, consts.DnoteDirName) + info, err := os.Stat(configDir) + assert.Equal(t, err, nil, "config dir should exist") + assert.Equal(t, info.IsDir(), true, "config should be a directory") + + dataDir := filepath.Join(paths.Data, consts.DnoteDirName) + info, err = os.Stat(dataDir) + assert.Equal(t, err, nil, "data dir should exist") + assert.Equal(t, info.IsDir(), true, "data should be a directory") + + cacheDir := filepath.Join(paths.Cache, consts.DnoteDirName) + info, err = os.Stat(cacheDir) + assert.Equal(t, err, nil, "cache dir should exist") + assert.Equal(t, info.IsDir(), true, "cache should be a directory") +} + +func TestInitDnoteDirs(t *testing.T) { + tmpDir := t.TempDir() + + paths := Paths{ + Config: filepath.Join(tmpDir, "config"), + Data: filepath.Join(tmpDir, "data"), + Cache: filepath.Join(tmpDir, "cache"), + } + + // Initialize directories + err := InitDnoteDirs(paths) + assert.Equal(t, err, nil, "InitDnoteDirs should succeed") + assertDirsExist(t, paths) + + // Call again - should be idempotent + err = InitDnoteDirs(paths) + assert.Equal(t, err, nil, "InitDnoteDirs should succeed when dirs already exist") + assertDirsExist(t, paths) +} diff --git a/pkg/cli/context/testutils.go b/pkg/cli/context/testutils.go index 8453dd3a..62fed833 100644 --- a/pkg/cli/context/testutils.go +++ b/pkg/cli/context/testutils.go @@ -19,8 +19,7 @@ package context import ( - "fmt" - "os" + "path/filepath" "testing" "github.com/dnote/dnote/pkg/cli/consts" @@ -29,11 +28,27 @@ import ( "github.com/pkg/errors" ) -// InitTestCtx initializes a test context -func InitTestCtx(t *testing.T, paths Paths, dbOpts *database.TestDBOptions) DnoteCtx { - dbPath := fmt.Sprintf("%s/%s/%s", paths.Data, consts.DnoteDirName, consts.DnoteDBFileName) +// getDefaultTestPaths creates default test paths with all paths pointing to a temp directory +func getDefaultTestPaths(t *testing.T) Paths { + tmpDir := t.TempDir() + return Paths{ + Home: tmpDir, + Cache: tmpDir, + Config: tmpDir, + Data: tmpDir, + } +} - db := database.InitTestDB(t, dbPath, dbOpts) + +// InitTestCtx initializes a test context with an in-memory database +// and a temporary directory for all paths +func InitTestCtx(t *testing.T) DnoteCtx { + paths := getDefaultTestPaths(t) + db := database.InitTestMemoryDB(t) + + if err := InitDnoteDirs(paths); err != nil { + t.Fatal(errors.Wrap(err, "creating test directories")) + } return DnoteCtx{ DB: db, @@ -42,17 +57,47 @@ func InitTestCtx(t *testing.T, paths Paths, dbOpts *database.TestDBOptions) Dnot } } -// TeardownTestCtx cleans up the test context -func TeardownTestCtx(t *testing.T, ctx DnoteCtx) { - database.TeardownTestDB(t, ctx.DB) +// InitTestCtxWithDB initializes a test context with the provided database +// and a temporary directory for all paths. +// Used when you need full control over database initialization (e.g. migration tests). +func InitTestCtxWithDB(t *testing.T, db *database.DB) DnoteCtx { + paths := getDefaultTestPaths(t) - if err := os.RemoveAll(ctx.Paths.Data); err != nil { - t.Fatal(errors.Wrap(err, "removing test data directory")) + if err := InitDnoteDirs(paths); err != nil { + t.Fatal(errors.Wrap(err, "creating test directories")) } - if err := os.RemoveAll(ctx.Paths.Config); err != nil { - t.Fatal(errors.Wrap(err, "removing test config directory")) - } - if err := os.RemoveAll(ctx.Paths.Cache); err != nil { - t.Fatal(errors.Wrap(err, "removing test cache directory")) + + return DnoteCtx{ + DB: db, + Paths: paths, + Clock: clock.NewMock(), // Use a mock clock to test times + } +} + +// InitTestCtxWithFileDB initializes a test context with a file-based database +// at the expected path. +func InitTestCtxWithFileDB(t *testing.T) DnoteCtx { + paths := getDefaultTestPaths(t) + + if err := InitDnoteDirs(paths); err != nil { + t.Fatal(errors.Wrap(err, "creating test directories")) + } + + dbPath := filepath.Join(paths.Data, consts.DnoteDirName, consts.DnoteDBFileName) + db, err := database.Open(dbPath) + if err != nil { + t.Fatal(errors.Wrap(err, "opening database")) + } + + if _, err := db.Exec(database.GetDefaultSchemaSQL()); err != nil { + t.Fatal(errors.Wrap(err, "running schema sql")) + } + + t.Cleanup(func() { db.Close() }) + + return DnoteCtx{ + DB: db, + Paths: paths, + Clock: clock.NewMock(), // Use a mock clock to test times } } diff --git a/pkg/cli/database/models.go b/pkg/cli/database/models.go index 05dd2f06..b26a6b5a 100644 --- a/pkg/cli/database/models.go +++ b/pkg/cli/database/models.go @@ -41,13 +41,12 @@ type Note struct { AddedOn int64 `json:"added_on"` EditedOn int64 `json:"edited_on"` USN int `json:"usn"` - Public bool `json:"public"` Deleted bool `json:"deleted"` Dirty bool `json:"dirty"` } // NewNote constructs a note with the given data -func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, public, deleted, dirty bool) Note { +func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, deleted, dirty bool) Note { return Note{ UUID: uuid, BookUUID: bookUUID, @@ -55,7 +54,6 @@ func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, publ AddedOn: addedOn, EditedOn: editedOn, USN: usn, - Public: public, Deleted: deleted, Dirty: dirty, } @@ -63,8 +61,8 @@ func NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, publ // Insert inserts a new note func (n Note) Insert(db *DB) error { - _, err := db.Exec("INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", - n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, n.Dirty) + _, err := db.Exec("INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + n.UUID, n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, n.Dirty) if err != nil { return errors.Wrapf(err, "inserting note with uuid %s", n.UUID) @@ -75,8 +73,8 @@ func (n Note) Insert(db *DB) error { // Update updates the note with the given data func (n Note) Update(db *DB) error { - _, err := db.Exec("UPDATE notes SET book_uuid = ?, body = ?, added_on = ?, edited_on = ?, usn = ?, public = ?, deleted = ?, dirty = ? WHERE uuid = ?", - n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Public, n.Deleted, n.Dirty, n.UUID) + _, err := db.Exec("UPDATE notes SET book_uuid = ?, body = ?, added_on = ?, edited_on = ?, usn = ?, deleted = ?, dirty = ? WHERE uuid = ?", + n.BookUUID, n.Body, n.AddedOn, n.EditedOn, n.USN, n.Deleted, n.Dirty, n.UUID) if err != nil { return errors.Wrapf(err, "updating the note with uuid %s", n.UUID) diff --git a/pkg/cli/database/models_test.go b/pkg/cli/database/models_test.go index 197937fc..53565d7b 100644 --- a/pkg/cli/database/models_test.go +++ b/pkg/cli/database/models_test.go @@ -34,7 +34,6 @@ func TestNewNote(t *testing.T) { addedOn int64 editedOn int64 usn int - public bool deleted bool dirty bool }{ @@ -45,7 +44,6 @@ func TestNewNote(t *testing.T) { addedOn: 1542058875, editedOn: 0, usn: 0, - public: false, deleted: false, dirty: false, }, @@ -56,14 +54,13 @@ func TestNewNote(t *testing.T) { addedOn: 1542058875, editedOn: 1542058876, usn: 1008, - public: true, deleted: true, dirty: true, }, } for idx, tc := range testCases { - got := NewNote(tc.uuid, tc.bookUUID, tc.body, tc.addedOn, tc.editedOn, tc.usn, tc.public, tc.deleted, tc.dirty) + got := NewNote(tc.uuid, tc.bookUUID, tc.body, tc.addedOn, tc.editedOn, tc.usn, tc.deleted, tc.dirty) assert.Equal(t, got.UUID, tc.uuid, fmt.Sprintf("UUID mismatch for test case %d", idx)) assert.Equal(t, got.BookUUID, tc.bookUUID, fmt.Sprintf("BookUUID mismatch for test case %d", idx)) @@ -71,7 +68,6 @@ func TestNewNote(t *testing.T) { assert.Equal(t, got.AddedOn, tc.addedOn, fmt.Sprintf("AddedOn mismatch for test case %d", idx)) assert.Equal(t, got.EditedOn, tc.editedOn, fmt.Sprintf("EditedOn mismatch for test case %d", idx)) assert.Equal(t, got.USN, tc.usn, fmt.Sprintf("USN mismatch for test case %d", idx)) - assert.Equal(t, got.Public, tc.public, fmt.Sprintf("Public mismatch for test case %d", idx)) assert.Equal(t, got.Deleted, tc.deleted, fmt.Sprintf("Deleted mismatch for test case %d", idx)) assert.Equal(t, got.Dirty, tc.dirty, fmt.Sprintf("Dirty mismatch for test case %d", idx)) } @@ -85,7 +81,6 @@ func TestNoteInsert(t *testing.T) { addedOn int64 editedOn int64 usn int - public bool deleted bool dirty bool }{ @@ -96,7 +91,6 @@ func TestNoteInsert(t *testing.T) { addedOn: 1542058875, editedOn: 0, usn: 0, - public: false, deleted: false, dirty: false, }, @@ -107,7 +101,6 @@ func TestNoteInsert(t *testing.T) { addedOn: 1542058875, editedOn: 1542058876, usn: 1008, - public: true, deleted: true, dirty: true, }, @@ -116,8 +109,7 @@ func TestNoteInsert(t *testing.T) { for idx, tc := range testCases { func() { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) n := Note{ UUID: tc.uuid, @@ -126,7 +118,6 @@ func TestNoteInsert(t *testing.T) { AddedOn: tc.addedOn, EditedOn: tc.editedOn, USN: tc.usn, - Public: tc.public, Deleted: tc.deleted, Dirty: tc.dirty, } @@ -148,10 +139,10 @@ func TestNoteInsert(t *testing.T) { var uuid, bookUUID, body string var addedOn, editedOn int64 var usn int - var public, deleted, dirty bool + var deleted, dirty bool MustScan(t, "getting n1", - db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid), - &uuid, &bookUUID, &body, &addedOn, &editedOn, &usn, &public, &deleted, &dirty) + db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid), + &uuid, &bookUUID, &body, &addedOn, &editedOn, &usn, &deleted, &dirty) assert.Equal(t, uuid, tc.uuid, fmt.Sprintf("uuid mismatch for test case %d", idx)) assert.Equal(t, bookUUID, tc.bookUUID, fmt.Sprintf("bookUUID mismatch for test case %d", idx)) @@ -159,7 +150,6 @@ func TestNoteInsert(t *testing.T) { assert.Equal(t, addedOn, tc.addedOn, fmt.Sprintf("addedOn mismatch for test case %d", idx)) assert.Equal(t, editedOn, tc.editedOn, fmt.Sprintf("editedOn mismatch for test case %d", idx)) assert.Equal(t, usn, tc.usn, fmt.Sprintf("usn mismatch for test case %d", idx)) - assert.Equal(t, public, tc.public, fmt.Sprintf("public mismatch for test case %d", idx)) assert.Equal(t, deleted, tc.deleted, fmt.Sprintf("deleted mismatch for test case %d", idx)) assert.Equal(t, dirty, tc.dirty, fmt.Sprintf("dirty mismatch for test case %d", idx)) }() @@ -174,14 +164,12 @@ func TestNoteUpdate(t *testing.T) { addedOn int64 editedOn int64 usn int - public bool deleted bool dirty bool newBookUUID string newBody string newEditedOn int64 newUSN int - newPublic bool newDeleted bool newDirty bool }{ @@ -192,14 +180,12 @@ func TestNoteUpdate(t *testing.T) { addedOn: 1542058875, editedOn: 0, usn: 0, - public: false, deleted: false, dirty: false, newBookUUID: "b1-uuid", newBody: "n1-body edited", newEditedOn: 1542058879, newUSN: 0, - newPublic: false, newDeleted: false, newDirty: false, }, @@ -210,14 +196,12 @@ func TestNoteUpdate(t *testing.T) { addedOn: 1542058875, editedOn: 0, usn: 0, - public: false, deleted: false, dirty: true, newBookUUID: "b2-uuid", newBody: "n1-body", newEditedOn: 1542058879, newUSN: 0, - newPublic: true, newDeleted: false, newDirty: false, }, @@ -228,14 +212,12 @@ func TestNoteUpdate(t *testing.T) { addedOn: 1542058875, editedOn: 0, usn: 10, - public: false, deleted: false, dirty: false, newBookUUID: "", newBody: "", newEditedOn: 1542058879, newUSN: 151, - newPublic: false, newDeleted: true, newDirty: false, }, @@ -246,14 +228,12 @@ func TestNoteUpdate(t *testing.T) { addedOn: 1542058875, editedOn: 0, usn: 0, - public: false, deleted: false, dirty: false, newBookUUID: "", newBody: "", newEditedOn: 1542058879, newUSN: 15, - newPublic: false, newDeleted: true, newDirty: false, }, @@ -262,8 +242,7 @@ func TestNoteUpdate(t *testing.T) { for idx, tc := range testCases { func() { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) n1 := Note{ UUID: tc.uuid, @@ -272,7 +251,6 @@ func TestNoteUpdate(t *testing.T) { AddedOn: tc.addedOn, EditedOn: tc.editedOn, USN: tc.usn, - Public: tc.public, Deleted: tc.deleted, Dirty: tc.dirty, } @@ -283,13 +261,12 @@ func TestNoteUpdate(t *testing.T) { AddedOn: 1542058875, EditedOn: 0, USN: 39, - Public: false, Deleted: false, Dirty: false, } - MustExec(t, fmt.Sprintf("inserting n1 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Public, n1.Deleted, n1.Dirty) - MustExec(t, fmt.Sprintf("inserting n2 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Public, n2.Deleted, n2.Dirty) + MustExec(t, fmt.Sprintf("inserting n1 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Deleted, n1.Dirty) + MustExec(t, fmt.Sprintf("inserting n2 for test case %d", idx), db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Deleted, n2.Dirty) // execute tx, err := db.Begin() @@ -301,7 +278,6 @@ func TestNoteUpdate(t *testing.T) { n1.Body = tc.newBody n1.EditedOn = tc.newEditedOn n1.USN = tc.newUSN - n1.Public = tc.newPublic n1.Deleted = tc.newDeleted n1.Dirty = tc.newDirty @@ -315,11 +291,11 @@ func TestNoteUpdate(t *testing.T) { // test var n1Record, n2Record Note MustScan(t, "getting n1", - db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid), - &n1Record.UUID, &n1Record.BookUUID, &n1Record.Body, &n1Record.AddedOn, &n1Record.EditedOn, &n1Record.USN, &n1Record.Public, &n1Record.Deleted, &n1Record.Dirty) + db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", tc.uuid), + &n1Record.UUID, &n1Record.BookUUID, &n1Record.Body, &n1Record.AddedOn, &n1Record.EditedOn, &n1Record.USN, &n1Record.Deleted, &n1Record.Dirty) MustScan(t, "getting n2", - db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID), - &n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Public, &n2Record.Deleted, &n2Record.Dirty) + db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID), + &n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Deleted, &n2Record.Dirty) assert.Equal(t, n1Record.UUID, n1.UUID, fmt.Sprintf("n1 uuid mismatch for test case %d", idx)) assert.Equal(t, n1Record.BookUUID, tc.newBookUUID, fmt.Sprintf("n1 bookUUID mismatch for test case %d", idx)) @@ -327,7 +303,6 @@ func TestNoteUpdate(t *testing.T) { assert.Equal(t, n1Record.AddedOn, n1.AddedOn, fmt.Sprintf("n1 addedOn mismatch for test case %d", idx)) assert.Equal(t, n1Record.EditedOn, tc.newEditedOn, fmt.Sprintf("n1 editedOn mismatch for test case %d", idx)) assert.Equal(t, n1Record.USN, tc.newUSN, fmt.Sprintf("n1 usn mismatch for test case %d", idx)) - assert.Equal(t, n1Record.Public, tc.newPublic, fmt.Sprintf("n1 public mismatch for test case %d", idx)) assert.Equal(t, n1Record.Deleted, tc.newDeleted, fmt.Sprintf("n1 deleted mismatch for test case %d", idx)) assert.Equal(t, n1Record.Dirty, tc.newDirty, fmt.Sprintf("n1 dirty mismatch for test case %d", idx)) @@ -337,7 +312,6 @@ func TestNoteUpdate(t *testing.T) { assert.Equal(t, n2Record.AddedOn, n2.AddedOn, fmt.Sprintf("n2 addedOn mismatch for test case %d", idx)) assert.Equal(t, n2Record.EditedOn, n2.EditedOn, fmt.Sprintf("n2 editedOn mismatch for test case %d", idx)) assert.Equal(t, n2Record.USN, n2.USN, fmt.Sprintf("n2 usn mismatch for test case %d", idx)) - assert.Equal(t, n2Record.Public, n2.Public, fmt.Sprintf("n2 public mismatch for test case %d", idx)) assert.Equal(t, n2Record.Deleted, n2.Deleted, fmt.Sprintf("n2 deleted mismatch for test case %d", idx)) assert.Equal(t, n2Record.Dirty, n2.Dirty, fmt.Sprintf("n2 dirty mismatch for test case %d", idx)) }() @@ -359,8 +333,7 @@ func TestNoteUpdateUUID(t *testing.T) { for idx, tc := range testCases { t.Run(fmt.Sprintf("testCase%d", idx), func(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) n1 := Note{ UUID: "n1-uuid", @@ -414,8 +387,7 @@ func TestNoteUpdateUUID(t *testing.T) { func TestNoteExpunge(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) n1 := Note{ UUID: "n1-uuid", @@ -424,7 +396,6 @@ func TestNoteExpunge(t *testing.T) { AddedOn: 1542058874, EditedOn: 0, USN: 22, - Public: false, Deleted: false, Dirty: false, } @@ -435,13 +406,12 @@ func TestNoteExpunge(t *testing.T) { AddedOn: 1542058875, EditedOn: 0, USN: 39, - Public: false, Deleted: false, Dirty: false, } - MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Public, n1.Deleted, n1.Dirty) - MustExec(t, "inserting n2", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Public, n2.Deleted, n2.Dirty) + MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1.UUID, n1.BookUUID, n1.USN, n1.AddedOn, n1.EditedOn, n1.Body, n1.Deleted, n1.Dirty) + MustExec(t, "inserting n2", db, "INSERT INTO notes (uuid, book_uuid, usn, added_on, edited_on, body, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n2.UUID, n2.BookUUID, n2.USN, n2.AddedOn, n2.EditedOn, n2.Body, n2.Deleted, n2.Dirty) // execute tx, err := db.Begin() @@ -464,8 +434,8 @@ func TestNoteExpunge(t *testing.T) { var n2Record Note MustScan(t, "getting n2", - db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID), - &n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Public, &n2Record.Deleted, &n2Record.Dirty) + db.QueryRow("SELECT uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty FROM notes WHERE uuid = ?", n2.UUID), + &n2Record.UUID, &n2Record.BookUUID, &n2Record.Body, &n2Record.AddedOn, &n2Record.EditedOn, &n2Record.USN, &n2Record.Deleted, &n2Record.Dirty) assert.Equal(t, n2Record.UUID, n2.UUID, "n2 uuid mismatch") assert.Equal(t, n2Record.BookUUID, n2.BookUUID, "n2 bookUUID mismatch") @@ -473,7 +443,6 @@ func TestNoteExpunge(t *testing.T) { assert.Equal(t, n2Record.AddedOn, n2.AddedOn, "n2 addedOn mismatch") assert.Equal(t, n2Record.EditedOn, n2.EditedOn, "n2 editedOn mismatch") assert.Equal(t, n2Record.USN, n2.USN, "n2 usn mismatch") - assert.Equal(t, n2Record.Public, n2.Public, "n2 public mismatch") assert.Equal(t, n2Record.Deleted, n2.Deleted, "n2 deleted mismatch") assert.Equal(t, n2Record.Dirty, n2.Dirty, "n2 dirty mismatch") } @@ -540,8 +509,7 @@ func TestBookInsert(t *testing.T) { for idx, tc := range testCases { func() { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) b := Book{ UUID: tc.uuid, @@ -621,8 +589,7 @@ func TestBookUpdate(t *testing.T) { for idx, tc := range testCases { func() { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) b1 := Book{ UUID: "b1-uuid", @@ -700,8 +667,7 @@ func TestBookUpdateUUID(t *testing.T) { t.Run(fmt.Sprintf("testCase%d", idx), func(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) b1 := Book{ UUID: "b1-uuid", @@ -751,8 +717,7 @@ func TestBookUpdateUUID(t *testing.T) { func TestBookExpunge(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) b1 := Book{ UUID: "b1-uuid", @@ -806,8 +771,7 @@ func TestBookExpunge(t *testing.T) { // TestNoteFTS tests that note full text search indices stay in sync with the notes after insert, update and delete func TestNoteFTS(t *testing.T) { // set up - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) // execute - insert n := Note{ @@ -817,7 +781,6 @@ func TestNoteFTS(t *testing.T) { AddedOn: 1542058875, EditedOn: 0, USN: 0, - Public: false, Deleted: false, Dirty: false, } diff --git a/pkg/cli/database/queries.go b/pkg/cli/database/queries.go index fe0884bc..e8ec5ce5 100644 --- a/pkg/cli/database/queries.go +++ b/pkg/cli/database/queries.go @@ -170,7 +170,6 @@ func GetActiveNote(db *DB, rowid int) (Note, error) { added_on, edited_on, usn, - public, deleted, dirty FROM notes WHERE rowid = ? AND deleted = false;`, rowid).Scan( @@ -181,7 +180,6 @@ func GetActiveNote(db *DB, rowid int) (Note, error) { &ret.AddedOn, &ret.EditedOn, &ret.USN, - &ret.Public, &ret.Deleted, &ret.Dirty, ) diff --git a/pkg/cli/database/queries_test.go b/pkg/cli/database/queries_test.go index cbfc71f2..cccc697f 100644 --- a/pkg/cli/database/queries_test.go +++ b/pkg/cli/database/queries_test.go @@ -47,8 +47,7 @@ func TestInsertSystem(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) // execute tx, err := db.Begin() @@ -95,8 +94,7 @@ func TestUpsertSystem(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz") @@ -134,8 +132,7 @@ func TestUpsertSystem(t *testing.T) { func TestGetSystem(t *testing.T) { t.Run(fmt.Sprintf("get string value"), func(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) // execute MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "bar") @@ -157,8 +154,7 @@ func TestGetSystem(t *testing.T) { t.Run(fmt.Sprintf("get int64 value"), func(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) // execute MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", 1234) @@ -198,8 +194,7 @@ func TestUpdateSystem(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("update %s %s", tc.key, tc.val), func(t *testing.T) { // Setup - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "fuz") MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz") @@ -238,11 +233,10 @@ func TestUpdateSystem(t *testing.T) { func TestGetActiveNote(t *testing.T) { t.Run("not deleted", func(t *testing.T) { // set up - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) n1UUID := "n1-uuid" - MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, false, true) + MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, false, true) var n1RowID int MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", n1UUID), &n1RowID) @@ -261,18 +255,16 @@ func TestGetActiveNote(t *testing.T) { assert.Equal(t, got.AddedOn, int64(1542058875), "AddedOn mismatch") assert.Equal(t, got.EditedOn, int64(1542058876), "EditedOn mismatch") assert.Equal(t, got.USN, 1, "USN mismatch") - assert.Equal(t, got.Public, true, "Public mismatch") assert.Equal(t, got.Deleted, false, "Deleted mismatch") assert.Equal(t, got.Dirty, true, "Dirty mismatch") }) t.Run("deleted", func(t *testing.T) { // set up - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) n1UUID := "n1-uuid" - MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, true, true) + MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, true) var n1RowID int MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", n1UUID), &n1RowID) @@ -292,11 +284,10 @@ func TestGetActiveNote(t *testing.T) { func TestUpdateNoteContent(t *testing.T) { // set up - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) uuid := "n1-uuid" - MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", uuid, "b1-uuid", "n1 content", 1542058875, 0, 1, false, false, false) + MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", uuid, "b1-uuid", "n1 content", 1542058875, 0, 1, false, false) var rowid int MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", uuid), &rowid) @@ -324,8 +315,7 @@ func TestUpdateNoteContent(t *testing.T) { func TestUpdateNoteBook(t *testing.T) { // set up - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) b1UUID := "b1-uuid" b2UUID := "b2-uuid" @@ -333,7 +323,7 @@ func TestUpdateNoteBook(t *testing.T) { MustExec(t, "inserting b2", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b2UUID, "b2-label", 9, false, false) uuid := "n1-uuid" - MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", uuid, b1UUID, "n1 content", 1542058875, 0, 1, false, false, false) + MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", uuid, b1UUID, "n1 content", 1542058875, 0, 1, false, false) var rowid int MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", uuid), &rowid) @@ -361,8 +351,7 @@ func TestUpdateNoteBook(t *testing.T) { func TestUpdateBookName(t *testing.T) { // set up - db := InitTestDB(t, "../tmp/dnote-test.db", nil) - defer TeardownTestDB(t, db) + db := InitTestMemoryDB(t) b1UUID := "b1-uuid" MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b1UUID, "b1-label", 8, false, false) diff --git a/pkg/cli/database/schema.sql b/pkg/cli/database/schema.sql new file mode 100644 index 00000000..9a9de094 --- /dev/null +++ b/pkg/cli/database/schema.sql @@ -0,0 +1,40 @@ +-- This is the final state of the CLI database after all migrations. +-- Auto-generated by generate-schema.go. Do not edit manually. +CREATE TABLE books + ( + uuid text PRIMARY KEY, + label text NOT NULL + , dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false); +CREATE TABLE system + ( + key string NOT NULL, + value text NOT NULL + ); +CREATE UNIQUE INDEX idx_books_label ON books(label); +CREATE UNIQUE INDEX idx_books_uuid ON books(uuid); +CREATE TABLE "notes" + ( + uuid text NOT NULL, + book_uuid text NOT NULL, + body text NOT NULL, + added_on integer NOT NULL, + edited_on integer DEFAULT 0, + dirty bool DEFAULT false, + usn int DEFAULT 0 NOT NULL, + deleted bool DEFAULT false + ); +CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'"); +CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN + INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); + END; +CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN + INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); + END; +CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN + INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); + INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); + END; + +-- Migration version data. +INSERT INTO system (key, value) VALUES ('schema', 14); +INSERT INTO system (key, value) VALUES ('remote_schema', 1); diff --git a/pkg/cli/database/schema/main.go b/pkg/cli/database/schema/main.go new file mode 100644 index 00000000..2596c84a --- /dev/null +++ b/pkg/cli/database/schema/main.go @@ -0,0 +1,166 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +// Command schema generates the CLI database schema.sql file. +package main + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/dnote/dnote/pkg/cli/config" + "github.com/dnote/dnote/pkg/cli/consts" + "github.com/dnote/dnote/pkg/cli/context" + "github.com/dnote/dnote/pkg/cli/database" + "github.com/dnote/dnote/pkg/cli/infra" + "github.com/dnote/dnote/pkg/cli/migrate" +) + +func main() { + tmpDir, err := os.MkdirTemp("", "dnote-schema-gen-*") + if err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } + defer os.RemoveAll(tmpDir) + + schemaPath := filepath.Join("pkg", "cli", "database", "schema.sql") + + if err := run(tmpDir, schemaPath); err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } +} + +func run(tmpDir, outputPath string) error { + schema, err := generateSchema(tmpDir) + if err != nil { + return err + } + + if err := os.WriteFile(outputPath, []byte(schema), 0644); err != nil { + return fmt.Errorf("writing schema file: %w", err) + } + + fmt.Printf("Schema generated successfully at %s\n", outputPath) + return nil +} + +// generateSchema creates a fresh database, runs all migrations, and extracts the schema +func generateSchema(tmpDir string) (string, error) { + // Create dnote directory structure in temp dir + dnoteDir := filepath.Join(tmpDir, "dnote") + if err := os.MkdirAll(dnoteDir, 0755); err != nil { + return "", fmt.Errorf("creating dnote dir: %w", err) + } + + // Use a file-based database + dbPath := filepath.Join(tmpDir, "schema.db") + + // Create context + ctx := context.DnoteCtx{ + Paths: context.Paths{ + Home: tmpDir, + Config: tmpDir, + Data: tmpDir, + Cache: tmpDir, + }, + Version: "schema-gen", + } + + // Open database + db, err := database.Open(dbPath) + if err != nil { + return "", fmt.Errorf("opening database: %w", err) + } + defer db.Close() + ctx.DB = db + + // Initialize database with base tables + if err := infra.InitDB(ctx); err != nil { + return "", fmt.Errorf("initializing database: %w", err) + } + + // Initialize system data + if err := infra.InitSystem(ctx); err != nil { + return "", fmt.Errorf("initializing system: %w", err) + } + + // Create minimal config file + if err := config.Write(ctx, config.Config{}); err != nil { + return "", fmt.Errorf("writing initial config: %w", err) + } + + // Run all local migrations + if err := migrate.Run(ctx, migrate.LocalSequence, migrate.LocalMode); err != nil { + return "", fmt.Errorf("running migrations: %w", err) + } + + // Extract schema before closing database + schema, err := extractSchema(db) + if err != nil { + return "", fmt.Errorf("extracting schema: %w", err) + } + + // Add INSERT statements for migration versions. + systemData := "\n-- Migration version data.\n" + systemData += fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s', %d);\n", consts.SystemSchema, len(migrate.LocalSequence)) + systemData += fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s', %d);\n", consts.SystemRemoteSchema, len(migrate.RemoteSequence)) + + return schema + systemData, nil +} + +// extractSchema extracts the complete schema by querying sqlite_master +func extractSchema(db *database.DB) (string, error) { + // Query sqlite_master for all schema objects, excluding FTS shadow tables + // FTS shadow tables are internal tables automatically created by FTS virtual tables + rows, err := db.Conn.Query(`SELECT sql FROM sqlite_master + WHERE sql IS NOT NULL + AND name NOT LIKE 'sqlite_%' + AND (type != 'table' + OR (type = 'table' AND name NOT IN ( + SELECT m1.name FROM sqlite_master m1 + JOIN sqlite_master m2 ON m1.name LIKE m2.name || '_%' + WHERE m2.type = 'table' AND m2.sql LIKE '%VIRTUAL TABLE%' + )))`) + if err != nil { + return "", fmt.Errorf("querying sqlite_master: %w", err) + } + defer rows.Close() + + var schemas []string + for rows.Next() { + var sql string + if err := rows.Scan(&sql); err != nil { + return "", fmt.Errorf("scanning row: %w", err) + } + schemas = append(schemas, sql) + } + + if err := rows.Err(); err != nil { + return "", fmt.Errorf("iterating rows: %w", err) + } + + // Add autogenerated header comment + header := `-- This is the final state of the CLI database after all migrations. +-- Auto-generated by generate-schema.go. Do not edit manually. +` + return header + strings.Join(schemas, ";\n") + ";\n", nil +} diff --git a/pkg/cli/database/schema/main_test.go b/pkg/cli/database/schema/main_test.go new file mode 100644 index 00000000..24bd9fc0 --- /dev/null +++ b/pkg/cli/database/schema/main_test.go @@ -0,0 +1,84 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package main + +import ( + "fmt" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/consts" +) + +func TestRun(t *testing.T) { + tmpDir := t.TempDir() + outputPath := filepath.Join(tmpDir, "schema.sql") + + // Run the function + if err := run(tmpDir, outputPath); err != nil { + t.Fatalf("run() failed: %v", err) + } + + // Verify schema.sql was created + content, err := os.ReadFile(outputPath) + if err != nil { + t.Fatalf("reading schema.sql: %v", err) + } + + schema := string(content) + + // Verify it has the header + assert.Equal(t, strings.HasPrefix(schema, "-- This is the final state"), true, "schema.sql should have header comment") + + // Verify schema contains expected tables + expectedTables := []string{ + "CREATE TABLE books", + "CREATE TABLE system", + "CREATE TABLE \"notes\"", + "CREATE VIRTUAL TABLE note_fts", + } + + for _, expected := range expectedTables { + assert.Equal(t, strings.Contains(schema, expected), true, fmt.Sprintf("schema should contain %s", expected)) + } + + // Verify schema contains triggers + expectedTriggers := []string{ + "CREATE TRIGGER notes_after_insert", + "CREATE TRIGGER notes_after_delete", + "CREATE TRIGGER notes_after_update", + } + + for _, expected := range expectedTriggers { + assert.Equal(t, strings.Contains(schema, expected), true, fmt.Sprintf("schema should contain %s", expected)) + } + + // Verify schema does not contain sqlite internal tables + assert.Equal(t, strings.Contains(schema, "sqlite_sequence"), false, "schema should not contain sqlite_sequence") + + // Verify system key-value pairs for schema versions are present + expectedSchemaKey := fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s',", consts.SystemSchema) + assert.Equal(t, strings.Contains(schema, expectedSchemaKey), true, "schema should contain schema version INSERT statement") + + expectedRemoteSchemaKey := fmt.Sprintf("INSERT INTO system (key, value) VALUES ('%s',", consts.SystemRemoteSchema) + assert.Equal(t, strings.Contains(schema, expectedRemoteSchemaKey), true, "schema should contain remote_schema version INSERT statement") +} diff --git a/pkg/cli/database/testutils.go b/pkg/cli/database/testutils.go index 28fd7067..16685686 100644 --- a/pkg/cli/database/testutils.go +++ b/pkg/cli/database/testutils.go @@ -20,8 +20,8 @@ package database import ( "database/sql" + _ "embed" "fmt" - "os" "path/filepath" "testing" @@ -30,56 +30,13 @@ import ( "github.com/pkg/errors" ) -var defaultSchemaSQL = `CREATE TABLE books - ( - uuid text PRIMARY KEY, - label text NOT NULL - , dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false); -CREATE TABLE system - ( - key string NOT NULL, - value text NOT NULL - ); -CREATE UNIQUE INDEX idx_books_label ON books(label); -CREATE UNIQUE INDEX idx_books_uuid ON books(uuid); -CREATE TABLE IF NOT EXISTS "notes" - ( - uuid text NOT NULL, - book_uuid text NOT NULL, - body text NOT NULL, - added_on integer NOT NULL, - edited_on integer DEFAULT 0, - public bool DEFAULT false, - dirty bool DEFAULT false, - usn int DEFAULT 0 NOT NULL, - deleted bool DEFAULT false - ); -CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'") -/* note_fts(body) */; -CREATE TABLE IF NOT EXISTS 'note_fts_data'(id INTEGER PRIMARY KEY, block BLOB); -CREATE TABLE IF NOT EXISTS 'note_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID; -CREATE TABLE IF NOT EXISTS 'note_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB); -CREATE TABLE IF NOT EXISTS 'note_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID; -CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN - INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); - END; -CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN - INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); - END; -CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN - INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); - INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); - END; -CREATE TABLE actions - ( - uuid text PRIMARY KEY, - schema integer NOT NULL, - type text NOT NULL, - data text NOT NULL, - timestamp integer NOT NULL - ); -CREATE UNIQUE INDEX idx_notes_uuid ON notes(uuid); -CREATE INDEX idx_notes_book_uuid ON notes(book_uuid);` +//go:embed schema.sql +var defaultSchemaSQL string + +// GetDefaultSchemaSQL returns the default schema SQL for tests +func GetDefaultSchemaSQL() string { + return defaultSchemaSQL +} // MustScan scans the given row and fails a test in case of any errors func MustScan(t *testing.T, message string, row *sql.Row, args ...interface{}) { @@ -99,29 +56,47 @@ func MustExec(t *testing.T, message string, db *DB, query string, args ...interf return result } -// TestDBOptions contains options for test database -type TestDBOptions struct { - SchemaSQLPath string - SkipMigration bool +// InitTestMemoryDB initializes an in-memory test database with the default schema. +func InitTestMemoryDB(t *testing.T) *DB { + return InitTestMemoryDBRaw(t, "") } -// InitTestDB initializes a test database and opens connection to it -func InitTestDB(t *testing.T, dbPath string, options *TestDBOptions) *DB { +// InitTestFileDB initializes a file-based test database with the default schema. +func InitTestFileDB(t *testing.T) (*DB, string) { + dbPath := filepath.Join(t.TempDir(), "dnote.db") + db := InitTestFileDBRaw(t, dbPath) + return db, dbPath +} + +// InitTestFileDBRaw initializes a file-based test database at the specified path with the default schema. +func InitTestFileDBRaw(t *testing.T, dbPath string) *DB { db, err := Open(dbPath) if err != nil { - t.Fatal(errors.Wrap(err, "opening database connection")) + t.Fatal(errors.Wrap(err, "opening database")) } - dir, _ := filepath.Split(dbPath) - err = os.MkdirAll(dir, 0777) + if _, err := db.Exec(defaultSchemaSQL); err != nil { + t.Fatal(errors.Wrap(err, "running schema sql")) + } + + t.Cleanup(func() { db.Close() }) + return db +} + +// InitTestMemoryDBRaw initializes an in-memory test database without marking migrations complete. +// If schemaPath is empty, uses the default schema. Used for migration testing. +func InitTestMemoryDBRaw(t *testing.T, schemaPath string) *DB { + uuid := mustGenerateTestUUID(t) + dbName := fmt.Sprintf("file:%s?mode=memory&cache=shared", uuid) + + db, err := Open(dbName) if err != nil { - t.Fatal(errors.Wrap(err, "creating the directory for test database file")) + t.Fatal(errors.Wrap(err, "opening in-memory database")) } var schemaSQL string - if options != nil && options.SchemaSQLPath != "" { - b := utils.ReadFileAbs(options.SchemaSQLPath) - schemaSQL = string(b) + if schemaPath != "" { + schemaSQL = string(utils.ReadFileAbs(schemaPath)) } else { schemaSQL = defaultSchemaSQL } @@ -130,24 +105,10 @@ func InitTestDB(t *testing.T, dbPath string, options *TestDBOptions) *DB { t.Fatal(errors.Wrap(err, "running schema sql")) } - if options == nil || !options.SkipMigration { - MarkMigrationComplete(t, db) - } - + t.Cleanup(func() { db.Close() }) return db } -// TeardownTestDB closes the test database and removes the its file -func TeardownTestDB(t *testing.T, db *DB) { - if err := db.Close(); err != nil { - t.Fatal(errors.Wrap(err, "closing database")) - } - - if err := os.RemoveAll(db.Filepath); err != nil { - t.Fatal(errors.Wrap(err, "removing database file")) - } -} - // OpenTestDB opens the database connection to a test database // without initializing any schema func OpenTestDB(t *testing.T, dnoteDir string) *DB { @@ -160,12 +121,11 @@ func OpenTestDB(t *testing.T, dnoteDir string) *DB { return db } -// MarkMigrationComplete marks all migrations as complete in the database -func MarkMigrationComplete(t *testing.T, db *DB) { - if _, err := db.Exec("INSERT INTO system (key, value) VALUES (? , ?);", consts.SystemSchema, 12); err != nil { - t.Fatal(errors.Wrap(err, "inserting schema")) - } - if _, err := db.Exec("INSERT INTO system (key, value) VALUES (? , ?);", consts.SystemRemoteSchema, 1); err != nil { - t.Fatal(errors.Wrap(err, "inserting remote schema")) +// mustGenerateTestUUID generates a UUID for test databases and fails the test on error +func mustGenerateTestUUID(t *testing.T) string { + uuid, err := utils.GenerateUUID() + if err != nil { + t.Fatal(errors.Wrap(err, "generating UUID for test database")) } + return uuid } diff --git a/pkg/cli/infra/init.go b/pkg/cli/infra/init.go index 4bbaae6e..1e572cf7 100644 --- a/pkg/cli/infra/init.go +++ b/pkg/cli/infra/init.go @@ -24,7 +24,6 @@ import ( "database/sql" "fmt" "os" - "path/filepath" "strconv" "time" @@ -329,36 +328,6 @@ func getEditorCommand() string { return ret } -func initDir(path string) error { - ok, err := utils.FileExists(path) - if err != nil { - return errors.Wrapf(err, "checking if dir exists at %s", path) - } - if ok { - return nil - } - - if err := os.MkdirAll(path, 0755); err != nil { - return errors.Wrapf(err, "creating a directory at %s", path) - } - - return nil -} - -// initDnoteDir initializes missing directories that Dnote uses -func initDnoteDir(ctx context.DnoteCtx) error { - if err := initDir(filepath.Join(ctx.Paths.Config, consts.DnoteDirName)); err != nil { - return errors.Wrap(err, "initializing config dir") - } - if err := initDir(filepath.Join(ctx.Paths.Data, consts.DnoteDirName)); err != nil { - return errors.Wrap(err, "initializing data dir") - } - if err := initDir(filepath.Join(ctx.Paths.Cache, consts.DnoteDirName)); err != nil { - return errors.Wrap(err, "initializing cache dir") - } - - return nil -} // initConfigFile populates a new config file if it does not exist yet func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error { @@ -394,7 +363,7 @@ func initConfigFile(ctx context.DnoteCtx, apiEndpoint string) error { // initFiles creates, if necessary, the dnote directory and files inside func initFiles(ctx context.DnoteCtx, apiEndpoint string) error { - if err := initDnoteDir(ctx); err != nil { + if err := context.InitDnoteDirs(ctx.Paths); err != nil { return errors.Wrap(err, "creating the dnote dir") } if err := initConfigFile(ctx, apiEndpoint); err != nil { diff --git a/pkg/cli/infra/init_test.go b/pkg/cli/infra/init_test.go index 546baab0..6ac0d5cf 100644 --- a/pkg/cli/infra/init_test.go +++ b/pkg/cli/infra/init_test.go @@ -32,8 +32,7 @@ import ( func TestInitSystemKV(t *testing.T) { // Setup - db := database.InitTestDB(t, "../tmp/dnote-test.db", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) var originalCount int database.MustScan(t, "counting system configs", db.QueryRow("SELECT count(*) FROM system"), &originalCount) @@ -64,8 +63,7 @@ func TestInitSystemKV(t *testing.T) { func TestInitSystemKV_existing(t *testing.T) { // Setup - db := database.InitTestDB(t, "../tmp/dnote-test.db", nil) - defer database.TeardownTestDB(t, db) + db := database.InitTestMemoryDB(t) database.MustExec(t, "inserting a system config", db, "INSERT INTO system (key, value) VALUES (?, ?)", "testKey", "testVal") diff --git a/pkg/cli/main_test.go b/pkg/cli/main_test.go index 63a95d87..0d9ad71a 100644 --- a/pkg/cli/main_test.go +++ b/pkg/cli/main_test.go @@ -35,14 +35,17 @@ import ( var binaryName = "test-dnote" -var testDir = "./tmp/.dnote" - -var opts = testutils.RunDnoteCmdOptions{ - Env: []string{ - fmt.Sprintf("XDG_CONFIG_HOME=%s", testDir), - fmt.Sprintf("XDG_DATA_HOME=%s", testDir), - fmt.Sprintf("XDG_CACHE_HOME=%s", testDir), - }, +// setupTestEnv creates a unique test directory for parallel test execution +func setupTestEnv(t *testing.T) (string, testutils.RunDnoteCmdOptions) { + testDir := t.TempDir() + opts := testutils.RunDnoteCmdOptions{ + Env: []string{ + fmt.Sprintf("XDG_CONFIG_HOME=%s", testDir), + fmt.Sprintf("XDG_DATA_HOME=%s", testDir), + fmt.Sprintf("XDG_CACHE_HOME=%s", testDir), + }, + } + return testDir, opts } func TestMain(m *testing.M) { @@ -55,10 +58,11 @@ func TestMain(m *testing.M) { } func TestInit(t *testing.T) { + testDir, opts := setupTestEnv(t) + // Execute // run an arbitrary command "view" due to https://github.com/spf13/cobra/issues/1056 testutils.RunDnoteCmd(t, opts, binaryName, "view") - defer testutils.RemoveDir(t, testDir) db := database.OpenTestDB(t, testDir) @@ -107,12 +111,12 @@ func TestInit(t *testing.T) { func TestAddNote(t *testing.T) { t.Run("new book", func(t *testing.T) { + testDir, opts := setupTestEnv(t) + // Set up and execute testutils.RunDnoteCmd(t, opts, binaryName, "add", "js", "-c", "foo") testutils.MustWaitDnoteCmd(t, opts, testutils.UserContent, binaryName, "add", "js") - defer testutils.RemoveDir(t, testDir) - db := database.OpenTestDB(t, testDir) // Test @@ -138,13 +142,14 @@ func TestAddNote(t *testing.T) { }) t.Run("existing book", func(t *testing.T) { + _, opts := setupTestEnv(t) + // Setup - db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil) + db, dbPath := database.InitTestFileDB(t) testutils.Setup3(t, db) // Execute - testutils.RunDnoteCmd(t, opts, binaryName, "add", "js", "-c", "foo") - defer testutils.RemoveDir(t, testDir) + testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "add", "js", "-c", "foo") // Test @@ -179,13 +184,14 @@ func TestAddNote(t *testing.T) { func TestEditNote(t *testing.T) { t.Run("content flag", func(t *testing.T) { + _, opts := setupTestEnv(t) + // Setup - db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil) + db, dbPath := database.InitTestFileDB(t) testutils.Setup4(t, db) // Execute - testutils.RunDnoteCmd(t, opts, binaryName, "edit", "2", "-c", "foo bar") - defer testutils.RemoveDir(t, testDir) + testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "2", "-c", "foo bar") // Test var noteCount, bookCount int @@ -212,13 +218,14 @@ func TestEditNote(t *testing.T) { }) t.Run("book flag", func(t *testing.T) { + _, opts := setupTestEnv(t) + // Setup - db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil) + db, dbPath := database.InitTestFileDB(t) testutils.Setup5(t, db) // Execute - testutils.RunDnoteCmd(t, opts, binaryName, "edit", "2", "-b", "linux") - defer testutils.RemoveDir(t, testDir) + testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "2", "-b", "linux") // Test var noteCount, bookCount int @@ -246,13 +253,14 @@ func TestEditNote(t *testing.T) { }) t.Run("book flag and content flag", func(t *testing.T) { + _, opts := setupTestEnv(t) + // Setup - db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil) + db, dbPath := database.InitTestFileDB(t) testutils.Setup5(t, db) // Execute - testutils.RunDnoteCmd(t, opts, binaryName, "edit", "2", "-b", "linux", "-c", "n2 body updated") - defer testutils.RemoveDir(t, testDir) + testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "2", "-b", "linux", "-c", "n2 body updated") // Test var noteCount, bookCount int @@ -282,13 +290,14 @@ func TestEditNote(t *testing.T) { func TestEditBook(t *testing.T) { t.Run("name flag", func(t *testing.T) { + _, opts := setupTestEnv(t) + // Setup - db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil) + db, dbPath := database.InitTestFileDB(t) testutils.Setup1(t, db) // Execute - testutils.RunDnoteCmd(t, opts, binaryName, "edit", "js", "-n", "js-edited") - defer testutils.RemoveDir(t, testDir) + testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "edit", "js", "-n", "js-edited") // Test var noteCount, bookCount int @@ -341,17 +350,18 @@ func TestRemoveNote(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("--yes=%t", tc.yesFlag), func(t *testing.T) { + _, opts := setupTestEnv(t) + // Setup - db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil) + db, dbPath := database.InitTestFileDB(t) testutils.Setup2(t, db) // Execute if tc.yesFlag { - testutils.RunDnoteCmd(t, opts, binaryName, "remove", "-y", "1") + testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "remove", "-y", "1") } else { - testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveNote, binaryName, "remove", "1") + testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveNote, binaryName, "--dbPath", dbPath, "remove", "1") } - defer testutils.RemoveDir(t, testDir) // Test var noteCount, bookCount, jsNoteCount, linuxNoteCount int @@ -428,19 +438,19 @@ func TestRemoveBook(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("--yes=%t", tc.yesFlag), func(t *testing.T) { + _, opts := setupTestEnv(t) + // Setup - db := database.InitTestDB(t, fmt.Sprintf("%s/%s/%s", testDir, consts.DnoteDirName, consts.DnoteDBFileName), nil) + db, dbPath := database.InitTestFileDB(t) testutils.Setup2(t, db) // Execute if tc.yesFlag { - testutils.RunDnoteCmd(t, opts, binaryName, "remove", "-y", "js") + testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "remove", "-y", "js") } else { - testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveBook, binaryName, "remove", "js") + testutils.MustWaitDnoteCmd(t, opts, testutils.ConfirmRemoveBook, binaryName, "--dbPath", dbPath, "remove", "js") } - defer testutils.RemoveDir(t, testDir) - // Test var noteCount, bookCount, jsNoteCount, linuxNoteCount int database.MustScan(t, "counting books", db.QueryRow("SELECT count(*) FROM books"), &bookCount) @@ -537,17 +547,9 @@ func TestDBPathFlag(t *testing.T) { } // Setup - use two different custom database paths - customDBPath1 := "./tmp/custom-test1.db" - customDBPath2 := "./tmp/custom-test2.db" - defer testutils.RemoveDir(t, "./tmp") - - customOpts := testutils.RunDnoteCmdOptions{ - Env: []string{ - fmt.Sprintf("XDG_CONFIG_HOME=%s", testDir), - fmt.Sprintf("XDG_DATA_HOME=%s", testDir), - fmt.Sprintf("XDG_CACHE_HOME=%s", testDir), - }, - } + testDir, customOpts := setupTestEnv(t) + customDBPath1 := fmt.Sprintf("%s/custom-test1.db", testDir) + customDBPath2 := fmt.Sprintf("%s/custom-test2.db", testDir) // Execute - add different notes to each database testutils.RunDnoteCmd(t, customOpts, binaryName, "--dbPath", customDBPath1, "add", "db1-book", "-c", "content in db1") diff --git a/pkg/cli/migrate/fixtures/local-12-pre-schema.sql b/pkg/cli/migrate/fixtures/local-12-pre-schema.sql index c501a460..5560af3d 100644 --- a/pkg/cli/migrate/fixtures/local-12-pre-schema.sql +++ b/pkg/cli/migrate/fixtures/local-12-pre-schema.sql @@ -38,13 +38,5 @@ CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); END; -CREATE TABLE actions - ( - uuid text PRIMARY KEY, - schema integer NOT NULL, - type text NOT NULL, - data text NOT NULL, - timestamp integer NOT NULL - ); CREATE UNIQUE INDEX idx_notes_uuid ON notes(uuid); CREATE INDEX idx_notes_book_uuid ON notes(book_uuid); diff --git a/pkg/cli/migrate/fixtures/local-14-pre-schema.sql b/pkg/cli/migrate/fixtures/local-14-pre-schema.sql new file mode 100644 index 00000000..5560af3d --- /dev/null +++ b/pkg/cli/migrate/fixtures/local-14-pre-schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE books + ( + uuid text PRIMARY KEY, + label text NOT NULL + , dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false); +CREATE TABLE system + ( + key string NOT NULL, + value text NOT NULL + ); +CREATE UNIQUE INDEX idx_books_label ON books(label); +CREATE UNIQUE INDEX idx_books_uuid ON books(uuid); +CREATE TABLE IF NOT EXISTS "notes" + ( + uuid text NOT NULL, + book_uuid text NOT NULL, + body text NOT NULL, + added_on integer NOT NULL, + edited_on integer DEFAULT 0, + public bool DEFAULT false, + dirty bool DEFAULT false, + usn int DEFAULT 0 NOT NULL, + deleted bool DEFAULT false + ); +CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'") +/* note_fts(body) */; +CREATE TABLE IF NOT EXISTS 'note_fts_data'(id INTEGER PRIMARY KEY, block BLOB); +CREATE TABLE IF NOT EXISTS 'note_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID; +CREATE TABLE IF NOT EXISTS 'note_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB); +CREATE TABLE IF NOT EXISTS 'note_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID; +CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN + INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); + END; +CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN + INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); + END; +CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN + INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); + INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); + END; +CREATE UNIQUE INDEX idx_notes_uuid ON notes(uuid); +CREATE INDEX idx_notes_book_uuid ON notes(book_uuid); diff --git a/pkg/cli/migrate/legacy_test.go b/pkg/cli/migrate/legacy_test.go index 00ebb7d7..4d1a1dc6 100644 --- a/pkg/cli/migrate/legacy_test.go +++ b/pkg/cli/migrate/legacy_test.go @@ -353,14 +353,18 @@ func TestMigrateToV7(t *testing.T) { } func TestMigrateToV8(t *testing.T) { - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true} - db := database.InitTestDB(t, "../tmp/.dnote/dnote-test.db", &opts) - defer database.TeardownTestDB(t, db) + tmpDir := t.TempDir() + dnoteDir := tmpDir + "/.dnote" + if err := os.MkdirAll(dnoteDir, 0755); err != nil { + t.Fatal(errors.Wrap(err, "creating legacy dnote directory")) + } + + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql") ctx := context.DnoteCtx{ Paths: context.Paths{ - Home: "../tmp", - LegacyDnote: "../tmp/.dnote", + Home: tmpDir, + LegacyDnote: dnoteDir, }, DB: db, } diff --git a/pkg/cli/migrate/migrate.go b/pkg/cli/migrate/migrate.go index b99cf7eb..eadfeda4 100644 --- a/pkg/cli/migrate/migrate.go +++ b/pkg/cli/migrate/migrate.go @@ -49,6 +49,7 @@ var LocalSequence = []migration{ lm11, lm12, lm13, + lm14, } // RemoteSequence is a list of remote migrations to be run diff --git a/pkg/cli/migrate/migrate_test.go b/pkg/cli/migrate/migrate_test.go index cd2619bd..591f1800 100644 --- a/pkg/cli/migrate/migrate_test.go +++ b/pkg/cli/migrate/migrate_test.go @@ -22,8 +22,8 @@ import ( "encoding/json" "fmt" "net/http" - "os" "net/http/httptest" + "os" "testing" "time" @@ -38,11 +38,13 @@ import ( "github.com/pkg/errors" ) -var paths context.Paths = context.Paths{ - Home: "../../tmp", - Cache: "../../tmp", - Config: "../../tmp", - Data: "../../tmp", +// initTestDBNoMigration initializes a test database with schema.sql but removes +// migration version data so tests can control the migration state themselves. +func initTestDBNoMigration(t *testing.T) *database.DB { + db := database.InitTestMemoryDBRaw(t, "") + // Remove migration versions from schema.sql so tests can set their own + database.MustExec(t, "clearing schema versions", db, "DELETE FROM system WHERE key IN (?, ?)", consts.SystemSchema, consts.SystemRemoteSchema) + return db } func TestExecute_bump_schema(t *testing.T) { @@ -60,11 +62,8 @@ func TestExecute_bump_schema(t *testing.T) { for _, tc := range testCases { func() { // set up - opts := database.TestDBOptions{SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := initTestDBNoMigration(t) + ctx := context.InitTestCtxWithDB(t, db) database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 8) @@ -117,11 +116,8 @@ func TestRun_nonfresh(t *testing.T) { for _, tc := range testCases { func() { // set up - opts := database.TestDBOptions{SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := initTestDBNoMigration(t) + ctx := context.InitTestCtxWithDB(t, db) database.MustExec(t, "inserting a schema", db, "INSERT INTO system (key, value) VALUES (?, ?)", tc.schemaKey, 2) database.MustExec(t, "creating a temporary table for testing", db, "CREATE TABLE migrate_run_test ( name string )") @@ -197,11 +193,8 @@ func TestRun_fresh(t *testing.T) { for _, tc := range testCases { func() { // set up - opts := database.TestDBOptions{SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := initTestDBNoMigration(t) + ctx := context.InitTestCtxWithDB(t, db) database.MustExec(t, "creating a temporary table for testing", db, "CREATE TABLE migrate_run_test ( name string )") @@ -271,11 +264,8 @@ func TestRun_up_to_date(t *testing.T) { for _, tc := range testCases { func() { // set up - opts := database.TestDBOptions{SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := initTestDBNoMigration(t) + ctx := context.InitTestCtxWithDB(t, db) database.MustExec(t, "creating a temporary table for testing", db, "CREATE TABLE migrate_run_test ( name string )") @@ -326,11 +316,8 @@ func TestRun_up_to_date(t *testing.T) { func TestLocalMigration1(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) data := testutils.MustMarshalJSON(t, actions.AddBookDataV1{BookName: "js"}) a1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting action", db, @@ -404,11 +391,8 @@ func TestLocalMigration1(t *testing.T) { func TestLocalMigration2(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) c1 := "note 1 - v1" c2 := "note 1 - v2" css := "css" @@ -491,11 +475,8 @@ func TestLocalMigration2(t *testing.T) { func TestLocalMigration3(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) data := testutils.MustMarshalJSON(t, actions.AddNoteDataV2{NoteUUID: "note-1-uuid", BookName: "js", Content: "note 1", Public: false}) a1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting action", db, @@ -566,11 +547,8 @@ func TestLocalMigration3(t *testing.T) { func TestLocalMigration4(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-1-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-1-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "css") @@ -610,11 +588,8 @@ func TestLocalMigration4(t *testing.T) { func TestLocalMigration5(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-5-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-5-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "css") @@ -672,11 +647,8 @@ func TestLocalMigration5(t *testing.T) { func TestLocalMigration6(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-5-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-5-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) data := testutils.MustMarshalJSON(t, actions.AddBookDataV1{BookName: "js"}) a1UUID := testutils.MustGenerateUUID(t) @@ -705,11 +677,8 @@ func TestLocalMigration6(t *testing.T) { func TestLocalMigration7_trash(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-7-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting trash book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "trash") @@ -738,11 +707,8 @@ func TestLocalMigration7_trash(t *testing.T) { func TestLocalMigration7_conflicts(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-7-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts") @@ -771,11 +737,8 @@ func TestLocalMigration7_conflicts(t *testing.T) { func TestLocalMigration7_conflicts_dup(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-7-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-7-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "conflicts") @@ -809,11 +772,8 @@ func TestLocalMigration7_conflicts_dup(t *testing.T) { func TestLocalMigration8(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-8-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-8-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1") @@ -846,13 +806,13 @@ func TestLocalMigration8(t *testing.T) { var n1AddedOn, n1EditedOn int64 var n1USN int var n1Public, n1Dirty, n1Deleted bool - database.MustScan(t, "scanning n1", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n1UUID), &n1BookUUID, &n1Body, &n1AddedOn, &n1EditedOn, &n1USN, &n1Public, &n1Dirty, &n1Deleted) + database.MustScan(t, "scanning n1", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n1UUID), &n1BookUUID, &n1Body, &n1AddedOn, &n1EditedOn, &n1USN, &n1Public, &n1Dirty, &n1Deleted) var n2BookUUID, n2Body string var n2AddedOn, n2EditedOn int64 var n2USN int var n2Public, n2Dirty, n2Deleted bool - database.MustScan(t, "scanning n2", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n2UUID), &n2BookUUID, &n2Body, &n2AddedOn, &n2EditedOn, &n2USN, &n2Public, &n2Dirty, &n2Deleted) + database.MustScan(t, "scanning n2", db.QueryRow("SELECT book_uuid, body, added_on, edited_on, usn, public, dirty, deleted FROM notes WHERE uuid = ?", n2UUID), &n2BookUUID, &n2Body, &n2AddedOn, &n2EditedOn, &n2USN, &n2Public, &n2Dirty, &n2Deleted) assert.Equal(t, n1BookUUID, b1UUID, "n1 BookUUID mismatch") assert.Equal(t, n1Body, "n1 Body", "n1 Body mismatch") @@ -875,11 +835,8 @@ func TestLocalMigration8(t *testing.T) { func TestLocalMigration9(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-9-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-9-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1") @@ -921,11 +878,8 @@ func TestLocalMigration9(t *testing.T) { func TestLocalMigration10(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-10-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-10-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book ", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "123") @@ -993,11 +947,8 @@ func TestLocalMigration10(t *testing.T) { func TestLocalMigration11(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-11-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) - - db := ctx.DB + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-11-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) b1UUID := testutils.MustGenerateUUID(t) database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "foo") @@ -1073,9 +1024,8 @@ func TestLocalMigration11(t *testing.T) { func TestLocalMigration12(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-12-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-12-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) data := []byte("editor: vim") path := fmt.Sprintf("%s/%s/dnoterc", ctx.Paths.Config, consts.DnoteDirName) @@ -1110,9 +1060,8 @@ func TestLocalMigration12(t *testing.T) { func TestLocalMigration13(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/local-12-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-12-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) data := []byte("editor: vim\napiEndpoint: https://test.com/api") @@ -1150,11 +1099,57 @@ func TestLocalMigration13(t *testing.T) { assert.Equal(t, cf.EnableUpgradeCheck, true, "enableUpgradeCheck mismatch") } +func TestLocalMigration14(t *testing.T) { + // set up + db := database.InitTestMemoryDBRaw(t, "./fixtures/local-14-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) + + b1UUID := testutils.MustGenerateUUID(t) + database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "b1") + + n1UUID := testutils.MustGenerateUUID(t) + database.MustExec(t, "inserting note", db, `INSERT INTO notes + (uuid, book_uuid, body, added_on, edited_on, public, dirty, usn, deleted) VALUES + (?, ?, ?, ?, ?, ?, ?, ?, ?)`, n1UUID, b1UUID, "test note", 1, 2, true, false, 0, false) + + // Execute + tx, err := db.Begin() + if err != nil { + t.Fatal(errors.Wrap(err, "beginning a transaction")) + } + + err = lm14.run(ctx, tx) + if err != nil { + tx.Rollback() + t.Fatal(errors.Wrap(err, "failed to run")) + } + + tx.Commit() + + // Test - verify public column was dropped by checking column names + rows, err := db.Query("SELECT name FROM pragma_table_info('notes')") + if err != nil { + t.Fatal(errors.Wrap(err, "getting table info")) + } + defer rows.Close() + + for rows.Next() { + var name string + err := rows.Scan(&name) + if err != nil { + t.Fatal(errors.Wrap(err, "scanning column name")) + } + + if name == "public" { + t.Fatal("public column still exists after migration") + } + } +} + func TestRemoteMigration1(t *testing.T) { // set up - opts := database.TestDBOptions{SchemaSQLPath: "./fixtures/remote-1-pre-schema.sql", SkipMigration: true} - ctx := context.InitTestCtx(t, paths, &opts) - defer context.TeardownTestCtx(t, ctx) + db := database.InitTestMemoryDBRaw(t, "./fixtures/remote-1-pre-schema.sql") + ctx := context.InitTestCtxWithDB(t, db) testutils.Login(t, &ctx) JSBookUUID := "existing-js-book-uuid" @@ -1194,7 +1189,6 @@ func TestRemoteMigration1(t *testing.T) { ctx.APIEndpoint = server.URL - db := ctx.DB database.MustExec(t, "inserting js book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", JSBookUUID, "js") database.MustExec(t, "inserting css book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", CSSBookUUID, "css") database.MustExec(t, "inserting linux book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", linuxBookUUID, "linux") diff --git a/pkg/cli/migrate/migrations.go b/pkg/cli/migrate/migrations.go index af5ae86e..09b86afc 100644 --- a/pkg/cli/migrate/migrations.go +++ b/pkg/cli/migrate/migrations.go @@ -572,6 +572,18 @@ var lm13 = migration{ }, } +var lm14 = migration{ + name: "drop-public-from-notes", + run: func(ctx context.DnoteCtx, tx *database.DB) error { + _, err := tx.Exec(`ALTER TABLE notes DROP COLUMN public;`) + if err != nil { + return errors.Wrap(err, "dropping public column from notes") + } + + return nil + }, +} + var rm1 = migration{ name: "sync-book-uuids-from-server", run: func(ctx context.DnoteCtx, tx *database.DB) error { diff --git a/pkg/cli/testutils/main.go b/pkg/cli/testutils/main.go index 6c6caa64..cefa6323 100644 --- a/pkg/cli/testutils/main.go +++ b/pkg/cli/testutils/main.go @@ -48,12 +48,15 @@ const ( // Timeout for waiting for prompts in tests const promptTimeout = 10 * time.Second -// Login simulates a logged in user by inserting credentials in the local database -func Login(t *testing.T, ctx *context.DnoteCtx) { - db := ctx.DB - +// LoginDB sets up login credentials in the database for tests +func LoginDB(t *testing.T, db *database.DB) { database.MustExec(t, "inserting sessionKey", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, "someSessionKey") database.MustExec(t, "inserting sessionKeyExpiry", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, time.Now().Add(24*time.Hour).Unix()) +} + +// Login simulates a logged in user by inserting credentials in the local database +func Login(t *testing.T, ctx *context.DnoteCtx) { + LoginDB(t, ctx.DB) ctx.SessionKey = "someSessionKey" ctx.SessionKeyExpiry = time.Now().Add(24 * time.Hour).Unix() diff --git a/pkg/cli/ui/editor_test.go b/pkg/cli/ui/editor_test.go index c2834a09..718c5337 100644 --- a/pkg/cli/ui/editor_test.go +++ b/pkg/cli/ui/editor_test.go @@ -30,11 +30,7 @@ import ( func TestGetTmpContentPath(t *testing.T) { t.Run("no collision", func(t *testing.T) { - ctx := context.InitTestCtx(t, context.Paths{ - Data: "../tmp", - Cache: "../tmp", - }, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) res, err := GetTmpContentPath(ctx) if err != nil { @@ -47,11 +43,7 @@ func TestGetTmpContentPath(t *testing.T) { t.Run("one existing session", func(t *testing.T) { // set up - ctx := context.InitTestCtx(t, context.Paths{ - Data: "../tmp2", - Cache: "../tmp2", - }, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) p := fmt.Sprintf("%s/%s", ctx.Paths.Cache, "DNOTE_TMPCONTENT_0.md") if _, err := os.Create(p); err != nil { @@ -71,11 +63,7 @@ func TestGetTmpContentPath(t *testing.T) { t.Run("two existing sessions", func(t *testing.T) { // set up - ctx := context.InitTestCtx(t, context.Paths{ - Data: "../tmp3", - Cache: "../tmp3", - }, nil) - defer context.TeardownTestCtx(t, ctx) + ctx := context.InitTestCtx(t) p1 := fmt.Sprintf("%s/%s", ctx.Paths.Cache, "DNOTE_TMPCONTENT_0.md") if _, err := os.Create(p1); err != nil { diff --git a/pkg/cli/utils/files.go b/pkg/cli/utils/files.go index b4b2d1df..00e898ec 100644 --- a/pkg/cli/utils/files.go +++ b/pkg/cli/utils/files.go @@ -55,6 +55,24 @@ func FileExists(filepath string) (bool, error) { return false, errors.Wrap(err, "getting file info") } +// EnsureDir creates a directory if it doesn't exist. +// Returns nil if the directory already exists or was successfully created. +func EnsureDir(path string) error { + ok, err := FileExists(path) + if err != nil { + return errors.Wrapf(err, "checking if dir exists at %s", path) + } + if ok { + return nil + } + + if err := os.MkdirAll(path, 0755); err != nil { + return errors.Wrapf(err, "creating directory at %s", path) + } + + return nil +} + // CopyDir copies a directory from src to dest, recursively copying nested // directories func CopyDir(src, dest string) error { diff --git a/pkg/cli/cmd/sync/main_test.go b/pkg/cli/utils/files_test.go similarity index 55% rename from pkg/cli/cmd/sync/main_test.go rename to pkg/cli/utils/files_test.go index e7a620b0..3c7c92bd 100644 --- a/pkg/cli/cmd/sync/main_test.go +++ b/pkg/cli/utils/files_test.go @@ -16,20 +16,30 @@ * along with Dnote. If not, see . */ -package sync +package utils import ( - "github.com/dnote/dnote/pkg/cli/context" + "os" "path/filepath" + "testing" + + "github.com/dnote/dnote/pkg/assert" ) -var testDir = "../../tmp" +func TestEnsureDir(t *testing.T) { + tmpDir := t.TempDir() + testPath := filepath.Join(tmpDir, "test", "nested", "dir") -var paths context.Paths = context.Paths{ - Home: testDir, - Cache: testDir, - Config: testDir, - Data: testDir, + // Create directory + err := EnsureDir(testPath) + assert.Equal(t, err, nil, "EnsureDir should succeed") + + // Verify it exists + info, err := os.Stat(testPath) + assert.Equal(t, err, nil, "directory should exist") + assert.Equal(t, info.IsDir(), true, "should be a directory") + + // Call again on existing directory - should not error + err = EnsureDir(testPath) + assert.Equal(t, err, nil, "EnsureDir should succeed on existing directory") } - -var dbPath = filepath.Join(testDir, "test.db") diff --git a/pkg/clock/clock.go b/pkg/clock/clock.go index f421d428..dda84b74 100644 --- a/pkg/clock/clock.go +++ b/pkg/clock/clock.go @@ -20,11 +20,10 @@ package clock import ( + "sync" "time" ) -//TODO: use mutex to avoid race - // Clock is an interface to the standard library time. // It is used to implement a real or a mock clock. The latter is used in tests. type Clock interface { @@ -39,16 +38,21 @@ func (c *clock) Now() time.Time { // Mock is a mock instance of clock type Mock struct { + mu sync.RWMutex currentTime time.Time } // SetNow sets the current time for the mock clock func (c *Mock) SetNow(t time.Time) { + c.mu.Lock() + defer c.mu.Unlock() c.currentTime = t } // Now returns the current time func (c *Mock) Now() time.Time { + c.mu.RLock() + defer c.mu.RUnlock() return c.currentTime } diff --git a/pkg/e2e/sync_test.go b/pkg/e2e/sync_test.go index 73ea3b31..10df15c9 100644 --- a/pkg/e2e/sync_test.go +++ b/pkg/e2e/sync_test.go @@ -28,13 +28,13 @@ import ( "net/http/httptest" "os" "os/exec" + "path/filepath" "strings" "testing" "time" "github.com/dnote/dnote/pkg/assert" "github.com/dnote/dnote/pkg/cli/consts" - "github.com/dnote/dnote/pkg/cli/context" cliDatabase "github.com/dnote/dnote/pkg/cli/database" "github.com/dnote/dnote/pkg/cli/testutils" clitest "github.com/dnote/dnote/pkg/cli/testutils" @@ -49,43 +49,65 @@ import ( ) var cliBinaryName string -var server *httptest.Server -var serverDb *gorm.DB var serverTime = time.Date(2017, time.March, 14, 21, 15, 0, 0, time.UTC) -var tmpDirPath string -var dnoteCmdOpts clitest.RunDnoteCmdOptions -var paths context.Paths - var testDir = "./tmp/.dnote" func init() { - tmpDirPath = fmt.Sprintf("%s/tmp", testDir) cliBinaryName = fmt.Sprintf("%s/test/cli/test-cli", testDir) - dnoteCmdOpts = clitest.RunDnoteCmdOptions{ +} + +// testEnv holds the test environment for a single test +type testEnv struct { + DB *cliDatabase.DB + CmdOpts clitest.RunDnoteCmdOptions + Server *httptest.Server + ServerDB *gorm.DB + TmpDir string +} + +// setupTestEnv creates an isolated test environment with its own database and temp directory +func setupTestEnv(t *testing.T) testEnv { + tmpDir := t.TempDir() + + // Create .dnote directory + dnoteDir := filepath.Join(tmpDir, consts.DnoteDirName) + if err := os.MkdirAll(dnoteDir, 0755); err != nil { + t.Fatal(errors.Wrap(err, "creating dnote directory")) + } + + // Create database at the expected path + dbPath := filepath.Join(dnoteDir, consts.DnoteDBFileName) + db := cliDatabase.InitTestFileDBRaw(t, dbPath) + + // Create server + server, serverDB := setupNewServer(t) + + // Create config file with this server's endpoint + apiEndpoint := fmt.Sprintf("%s/api", server.URL) + updateConfigAPIEndpoint(t, tmpDir, apiEndpoint) + + // Create command options with XDG paths pointing to temp dir + cmdOpts := clitest.RunDnoteCmdOptions{ Env: []string{ - fmt.Sprintf("XDG_CONFIG_HOME=%s", tmpDirPath), - fmt.Sprintf("XDG_DATA_HOME=%s", tmpDirPath), - fmt.Sprintf("XDG_CACHE_HOME=%s", tmpDirPath), + fmt.Sprintf("XDG_CONFIG_HOME=%s", tmpDir), + fmt.Sprintf("XDG_DATA_HOME=%s", tmpDir), + fmt.Sprintf("XDG_CACHE_HOME=%s", tmpDir), }, } - paths = context.Paths{ - Data: tmpDirPath, - Cache: tmpDirPath, - Config: tmpDirPath, - } -} - -func clearTmp(t *testing.T) { - if err := os.RemoveAll(tmpDirPath); err != nil { - t.Fatal("cleaning tmp dir") + return testEnv{ + DB: db, + CmdOpts: cmdOpts, + Server: server, + ServerDB: serverDB, + TmpDir: tmpDir, } } // setupTestServer creates a test server with its own database -func setupTestServer(dbPath string, serverTime time.Time) (*httptest.Server, *gorm.DB, error) { - db := apitest.InitDB(dbPath) +func setupTestServer(t *testing.T, serverTime time.Time) (*httptest.Server, *gorm.DB, error) { + db := apitest.InitMemoryDB(t) mockClock := clock.NewMock() mockClock.SetNow(serverTime) @@ -104,23 +126,46 @@ func setupTestServer(dbPath string, serverTime time.Time) (*httptest.Server, *go return server, db, nil } -func TestMain(m *testing.M) { - // Set up server database - use file-based DB for e2e tests - dbPath := fmt.Sprintf("%s/server.db", testDir) - - var err error - server, serverDb, err = setupTestServer(dbPath, serverTime) +// setupNewServer creates a new server and returns the server and database. +// This is useful when a test needs to switch to a new empty server. +func setupNewServer(t *testing.T) (*httptest.Server, *gorm.DB) { + server, serverDB, err := setupTestServer(t, serverTime) if err != nil { - panic(err) + t.Fatal(errors.Wrap(err, "setting up new test server")) } + t.Cleanup(func() { server.Close() }) - defer server.Close() + return server, serverDB +} - // Build binaries - apiEndpoint := fmt.Sprintf("%s/api", server.URL) - ldflags := fmt.Sprintf("-X main.apiEndpoint=%s", apiEndpoint) +// updateConfigAPIEndpoint updates the config file with the given API endpoint +func updateConfigAPIEndpoint(t *testing.T, tmpDir string, apiEndpoint string) { + dnoteDir := filepath.Join(tmpDir, consts.DnoteDirName) + configPath := filepath.Join(dnoteDir, consts.ConfigFilename) + configContent := fmt.Sprintf("apiEndpoint: %s\n", apiEndpoint) + if err := os.WriteFile(configPath, []byte(configContent), 0644); err != nil { + t.Fatal(errors.Wrap(err, "writing config file")) + } +} - cmd := exec.Command("go", "build", "--tags", "fts5", "-o", cliBinaryName, "-ldflags", ldflags, "github.com/dnote/dnote/pkg/cli") +// switchToEmptyServer closes the current server and creates a new empty server, +// updating the config file to point to it. +func switchToEmptyServer(t *testing.T, env *testEnv) { + // Close old server + env.Server.Close() + + // Create new empty server + env.Server, env.ServerDB = setupNewServer(t) + + // Update config file to point to new server + apiEndpoint := fmt.Sprintf("%s/api", env.Server.URL) + updateConfigAPIEndpoint(t, env.TmpDir, apiEndpoint) +} + +func TestMain(m *testing.M) { + // Build CLI binary without hardcoded API endpoint + // Each test will create its own server and config file + cmd := exec.Command("go", "build", "--tags", "fts5", "-o", cliBinaryName, "github.com/dnote/dnote/pkg/cli") var stderr bytes.Buffer cmd.Stderr = &stderr @@ -135,29 +180,29 @@ func TestMain(m *testing.M) { } // helpers -func setupUser(t *testing.T, db *cliDatabase.DB) database.User { - user := apitest.SetupUserData(serverDb, "alice@example.com", "pass1234") +func setupUser(t *testing.T, env testEnv) database.User { + user := apitest.SetupUserData(env.ServerDB, "alice@example.com", "pass1234") return user } -func setupUserAndLogin(t *testing.T, db *cliDatabase.DB) database.User { - user := setupUser(t, db) - login(t, db, user) +func setupUserAndLogin(t *testing.T, env testEnv) database.User { + user := setupUser(t, env) + login(t, env.DB, env.ServerDB, user) return user } // log in the user in CLI -func login(t *testing.T, db *cliDatabase.DB, user database.User) { - session := apitest.SetupSession(serverDb, user) +func login(t *testing.T, db *cliDatabase.DB, serverDB *gorm.DB, user database.User) { + session := apitest.SetupSession(serverDB, user) cliDatabase.MustExec(t, "inserting session_key", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, session.Key) cliDatabase.MustExec(t, "inserting session_key_expiry", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, session.ExpiresAt.Unix()) } -func apiCreateBook(t *testing.T, user database.User, name, message string) string { - res := doHTTPReq(t, "POST", "/v3/books", fmt.Sprintf(`{"name": "%s"}`, name), message, user) +func apiCreateBook(t *testing.T, env testEnv, user database.User, name, message string) string { + res := doHTTPReq(t, env, "POST", "/v3/books", fmt.Sprintf(`{"name": "%s"}`, name), message, user) var resp controllers.CreateBookResp if err := json.NewDecoder(res.Body).Decode(&resp); err != nil { @@ -168,16 +213,16 @@ func apiCreateBook(t *testing.T, user database.User, name, message string) strin return resp.Book.UUID } -func apiPatchBook(t *testing.T, user database.User, uuid, payload, message string) { - doHTTPReq(t, "PATCH", fmt.Sprintf("/v3/books/%s", uuid), payload, message, user) +func apiPatchBook(t *testing.T, env testEnv, user database.User, uuid, payload, message string) { + doHTTPReq(t, env, "PATCH", fmt.Sprintf("/v3/books/%s", uuid), payload, message, user) } -func apiDeleteBook(t *testing.T, user database.User, uuid, message string) { - doHTTPReq(t, "DELETE", fmt.Sprintf("/v3/books/%s", uuid), "", message, user) +func apiDeleteBook(t *testing.T, env testEnv, user database.User, uuid, message string) { + doHTTPReq(t, env, "DELETE", fmt.Sprintf("/v3/books/%s", uuid), "", message, user) } -func apiCreateNote(t *testing.T, user database.User, bookUUID, body, message string) string { - res := doHTTPReq(t, "POST", "/v3/notes", fmt.Sprintf(`{"book_uuid": "%s", "content": "%s"}`, bookUUID, body), message, user) +func apiCreateNote(t *testing.T, env testEnv, user database.User, bookUUID, body, message string) string { + res := doHTTPReq(t, env, "POST", "/v3/notes", fmt.Sprintf(`{"book_uuid": "%s", "content": "%s"}`, bookUUID, body), message, user) var resp controllers.CreateNoteResp if err := json.NewDecoder(res.Body).Decode(&resp); err != nil { @@ -188,16 +233,16 @@ func apiCreateNote(t *testing.T, user database.User, bookUUID, body, message str return resp.Result.UUID } -func apiPatchNote(t *testing.T, user database.User, noteUUID, payload, message string) { - doHTTPReq(t, "PATCH", fmt.Sprintf("/v3/notes/%s", noteUUID), payload, message, user) +func apiPatchNote(t *testing.T, env testEnv, user database.User, noteUUID, payload, message string) { + doHTTPReq(t, env, "PATCH", fmt.Sprintf("/v3/notes/%s", noteUUID), payload, message, user) } -func apiDeleteNote(t *testing.T, user database.User, noteUUID, message string) { - doHTTPReq(t, "DELETE", fmt.Sprintf("/v3/notes/%s", noteUUID), "", message, user) +func apiDeleteNote(t *testing.T, env testEnv, user database.User, noteUUID, message string) { + doHTTPReq(t, env, "DELETE", fmt.Sprintf("/v3/notes/%s", noteUUID), "", message, user) } -func doHTTPReq(t *testing.T, method, path, payload, message string, user database.User) *http.Response { - apiEndpoint := fmt.Sprintf("%s/api", server.URL) +func doHTTPReq(t *testing.T, env testEnv, method, path, payload, message string, user database.User) *http.Response { + apiEndpoint := fmt.Sprintf("%s/api", env.Server.URL) endpoint := fmt.Sprintf("%s%s", apiEndpoint, path) req, err := http.NewRequest(method, endpoint, strings.NewReader(payload)) @@ -205,7 +250,7 @@ func doHTTPReq(t *testing.T, method, path, payload, message string, user databas panic(errors.Wrap(err, "constructing http request")) } - res := apitest.HTTPAuthDo(t, serverDb, req, user) + res := apitest.HTTPAuthDo(t, env.ServerDB, req, user) if res.StatusCode >= 400 { bs, err := io.ReadAll(res.Body) if err != nil { @@ -218,29 +263,22 @@ func doHTTPReq(t *testing.T, method, path, payload, message string, user databas return res } -type setupFunc func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string -type assertFunc func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) +type setupFunc func(t *testing.T, env testEnv, user database.User) map[string]string +type assertFunc func(t *testing.T, env testEnv, user database.User, ids map[string]string) func testSyncCmd(t *testing.T, fullSync bool, setup setupFunc, assert assertFunc) { - // clean up - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) + env := setupTestEnv(t) - clearTmp(t) - - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - - user := setupUserAndLogin(t, ctx.DB) - ids := setup(t, ctx, user) + user := setupUserAndLogin(t, env) + ids := setup(t, env, user) if fullSync { - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "-f") } else { - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") } - assert(t, ctx, user, ids) + assert(t, env, user, ids) } type systemState struct { @@ -254,11 +292,7 @@ type systemState struct { } // checkState compares the state of the client and the server with the given system state -func checkState(t *testing.T, ctx context.DnoteCtx, user database.User, expected systemState) { - checkStateWithDB(t, ctx.DB, user, serverDb, expected) -} - -func checkStateWithDB(t *testing.T, clientDB *cliDatabase.DB, user database.User, serverDB *gorm.DB, expected systemState) { +func checkState(t *testing.T, clientDB *cliDatabase.DB, user database.User, serverDB *gorm.DB, expected systemState) { var clientBookCount, clientNoteCount int cliDatabase.MustScan(t, "counting client notes", clientDB.QueryRow("SELECT count(*) FROM notes"), &clientNoteCount) cliDatabase.MustScan(t, "counting client books", clientDB.QueryRow("SELECT count(*) FROM books"), &clientBookCount) @@ -284,13 +318,13 @@ func checkStateWithDB(t *testing.T, clientDB *cliDatabase.DB, user database.User // tests func TestSync_Empty(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { return map[string]string{} } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { // Test - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 0, clientLastMaxUSN: 0, @@ -307,19 +341,19 @@ func TestSync_Empty(t *testing.T) { func TestSync_oneway(t *testing.T) { t.Run("cli to api only", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) { - apitest.MustExec(t, serverDb.Model(&user).Update("max_usn", 0), "updating user max_usn") + setup := func(t *testing.T, env testEnv, user database.User) { + apitest.MustExec(t, env.ServerDB.Model(&user).Update("max_usn", 0), "updating user max_usn") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js2") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js2") } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User) { - cliDB := ctx.DB + assert := func(t *testing.T, env testEnv, user database.User) { + cliDB := env.DB // test client - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 3, clientBookCount: 2, clientLastMaxUSN: 5, @@ -359,11 +393,11 @@ func TestSync_oneway(t *testing.T) { // test server var apiBookJS, apiBookCSS database.Book var apiNote1JS, apiNote2JS, apiNote1CSS database.Note - apitest.MustExec(t, serverDb.Model(&database.Note{}).Where("uuid = ?", cliNote1JS.UUID).First(&apiNote1JS), "getting js1 note") - apitest.MustExec(t, serverDb.Model(&database.Note{}).Where("uuid = ?", cliNote2JS.UUID).First(&apiNote2JS), "getting js2 note") - apitest.MustExec(t, serverDb.Model(&database.Note{}).Where("uuid = ?", cliNote1CSS.UUID).First(&apiNote1CSS), "getting css1 note") - apitest.MustExec(t, serverDb.Model(&database.Book{}).Where("uuid = ?", cliBookJS.UUID).First(&apiBookJS), "getting js book") - apitest.MustExec(t, serverDb.Model(&database.Book{}).Where("uuid = ?", cliBookCSS.UUID).First(&apiBookCSS), "getting css book") + apitest.MustExec(t, env.ServerDB.Model(&database.Note{}).Where("uuid = ?", cliNote1JS.UUID).First(&apiNote1JS), "getting js1 note") + apitest.MustExec(t, env.ServerDB.Model(&database.Note{}).Where("uuid = ?", cliNote2JS.UUID).First(&apiNote2JS), "getting js2 note") + apitest.MustExec(t, env.ServerDB.Model(&database.Note{}).Where("uuid = ?", cliNote1CSS.UUID).First(&apiNote1CSS), "getting css1 note") + apitest.MustExec(t, env.ServerDB.Model(&database.Book{}).Where("uuid = ?", cliBookJS.UUID).First(&apiBookJS), "getting js book") + apitest.MustExec(t, env.ServerDB.Model(&database.Book{}).Where("uuid = ?", cliBookCSS.UUID).First(&apiBookCSS), "getting css book") // assert usn assert.NotEqual(t, apiNote1JS.USN, 0, "apiNote1JS usn mismatch") @@ -390,62 +424,56 @@ func TestSync_oneway(t *testing.T) { } t.Run("stepSync", func(t *testing.T) { - clearTmp(t) - defer apitest.ClearData(serverDb) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - user := setupUserAndLogin(t, ctx.DB) - setup(t, ctx, user) + env := setupTestEnv(t) + user := setupUserAndLogin(t, env) + setup(t, env, user) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - assert(t, ctx, user) + assert(t, env, user) }) t.Run("fullSync", func(t *testing.T) { - clearTmp(t) - defer apitest.ClearData(serverDb) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - user := setupUserAndLogin(t, ctx.DB) - setup(t, ctx, user) + env := setupTestEnv(t) + user := setupUserAndLogin(t, env) + setup(t, env, user) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "-f") - assert(t, ctx, user) + assert(t, env, user) }) }) t.Run("cli to api with edit and delete", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) { - apiDB := serverDb + setup := func(t *testing.T, env testEnv, user database.User) { + apiDB := env.ServerDB apitest.MustExec(t, apiDB.Model(&user).Update("max_usn", 0), "updating user max_usn") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js2") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js3") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css2") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js2") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js3") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css2") var nid, nid2 string - cliDB := ctx.DB + cliDB := env.DB cliDatabase.MustScan(t, "getting id of note to edit", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js3"), &nid) cliDatabase.MustScan(t, "getting id of note to delete", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "css2"), &nid2) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js3-edited") - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "css", nid2) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js3-edited") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "css", nid2) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css3") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css4") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css3") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css4") } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 6, clientBookCount: 2, clientLastMaxUSN: 8, @@ -546,62 +574,56 @@ func TestSync_oneway(t *testing.T) { } t.Run("stepSync", func(t *testing.T) { - clearTmp(t) - defer apitest.ClearData(serverDb) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - user := setupUserAndLogin(t, ctx.DB) - setup(t, ctx, user) + env := setupTestEnv(t) + user := setupUserAndLogin(t, env) + setup(t, env, user) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - assert(t, ctx, user) + assert(t, env, user) }) t.Run("fullSync", func(t *testing.T) { - clearTmp(t) - defer apitest.ClearData(serverDb) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - user := setupUserAndLogin(t, ctx.DB) - setup(t, ctx, user) + env := setupTestEnv(t) + user := setupUserAndLogin(t, env) + setup(t, env, user) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "-f") - assert(t, ctx, user) + assert(t, env, user) }) }) t.Run("api to cli", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - apiDB := serverDb + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + apiDB := env.ServerDB apitest.MustExec(t, apiDB.Model(&user).Update("max_usn", 0), "updating user max_usn") - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") - cssBookUUID := apiCreateBook(t, user, "css", "adding css book") - cssNote1UUID := apiCreateNote(t, user, cssBookUUID, "css1", "adding css note 1") - jsNote2UUID := apiCreateNote(t, user, jsBookUUID, "js2", "adding js note 2") - cssNote2UUID := apiCreateNote(t, user, cssBookUUID, "css2", "adding css note 2") - linuxBookUUID := apiCreateBook(t, user, "linux", "adding linux book") - linuxNote1UUID := apiCreateNote(t, user, linuxBookUUID, "linux1", "adding linux note 1") - apiPatchNote(t, user, jsNote2UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, linuxBookUUID), "moving js note 2 to linux") - apiDeleteNote(t, user, jsNote1UUID, "deleting js note 1") - cssNote3UUID := apiCreateNote(t, user, cssBookUUID, "css3", "adding css note 3") - bashBookUUID := apiCreateBook(t, user, "bash", "adding bash book") - bashNote1UUID := apiCreateNote(t, user, bashBookUUID, "bash1", "adding bash note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding css book") + cssNote1UUID := apiCreateNote(t, env, user, cssBookUUID, "css1", "adding css note 1") + jsNote2UUID := apiCreateNote(t, env, user, jsBookUUID, "js2", "adding js note 2") + cssNote2UUID := apiCreateNote(t, env, user, cssBookUUID, "css2", "adding css note 2") + linuxBookUUID := apiCreateBook(t, env, user, "linux", "adding linux book") + linuxNote1UUID := apiCreateNote(t, env, user, linuxBookUUID, "linux1", "adding linux note 1") + apiPatchNote(t, env, user, jsNote2UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, linuxBookUUID), "moving js note 2 to linux") + apiDeleteNote(t, env, user, jsNote1UUID, "deleting js note 1") + cssNote3UUID := apiCreateNote(t, env, user, cssBookUUID, "css3", "adding css note 3") + bashBookUUID := apiCreateBook(t, env, user, "bash", "adding bash book") + bashNote1UUID := apiCreateNote(t, env, user, bashBookUUID, "bash1", "adding bash note 1") // delete the linux book and its two notes - apiDeleteBook(t, user, linuxBookUUID, "deleting linux book") + apiDeleteBook(t, env, user, linuxBookUUID, "deleting linux book") - apiPatchNote(t, user, cssNote2UUID, fmt.Sprintf(`{"content": "%s"}`, "css2-edited"), "editing css 2 body") - bashNote2UUID := apiCreateNote(t, user, bashBookUUID, "bash2", "adding bash note 2") - linuxBook2UUID := apiCreateBook(t, user, "linux", "adding new linux book") - linux2Note1UUID := apiCreateNote(t, user, linuxBookUUID, "linux-new-1", "adding linux note 1") - apiDeleteBook(t, user, jsBookUUID, "deleting js book") + apiPatchNote(t, env, user, cssNote2UUID, fmt.Sprintf(`{"content": "%s"}`, "css2-edited"), "editing css 2 body") + bashNote2UUID := apiCreateNote(t, env, user, bashBookUUID, "bash2", "adding bash note 2") + linuxBook2UUID := apiCreateBook(t, env, user, "linux", "adding new linux book") + linux2Note1UUID := apiCreateNote(t, env, user, linuxBookUUID, "linux-new-1", "adding linux note 1") + apiDeleteBook(t, env, user, jsBookUUID, "deleting js book") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -621,11 +643,11 @@ func TestSync_oneway(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 6, clientBookCount: 3, clientLastMaxUSN: 21, @@ -768,41 +790,41 @@ func TestSync_oneway(t *testing.T) { func TestSync_twoway(t *testing.T) { t.Run("once", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") - cssBookUUID := apiCreateBook(t, user, "css", "adding css book") - cssNote1UUID := apiCreateNote(t, user, cssBookUUID, "css1", "adding css note 1") - jsNote2UUID := apiCreateNote(t, user, jsBookUUID, "js2", "adding js note 2") - cssNote2UUID := apiCreateNote(t, user, cssBookUUID, "css2", "adding css note 2") - linuxBookUUID := apiCreateBook(t, user, "linux", "adding linux book") - linuxNote1UUID := apiCreateNote(t, user, linuxBookUUID, "linux1", "adding linux note 1") - apiPatchNote(t, user, jsNote2UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, linuxBookUUID), "moving js note 2 to linux") - apiDeleteNote(t, user, jsNote1UUID, "deleting js note 1") - cssNote3UUID := apiCreateNote(t, user, cssBookUUID, "css3", "adding css note 3") - bashBookUUID := apiCreateBook(t, user, "bash", "adding bash book") - bashNote1UUID := apiCreateNote(t, user, bashBookUUID, "bash1", "adding bash note 1") - apiDeleteBook(t, user, linuxBookUUID, "deleting linux book") - apiPatchNote(t, user, cssNote2UUID, fmt.Sprintf(`{"content": "%s"}`, "css2-edited"), "editing css 2 body") - bashNote2UUID := apiCreateNote(t, user, bashBookUUID, "bash2", "adding bash note 2") - linuxBook2UUID := apiCreateBook(t, user, "linux", "adding new linux book") - linux2Note1UUID := apiCreateNote(t, user, linuxBookUUID, "linux-new-1", "adding linux note 1") - apiDeleteBook(t, user, jsBookUUID, "deleting js book") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding css book") + cssNote1UUID := apiCreateNote(t, env, user, cssBookUUID, "css1", "adding css note 1") + jsNote2UUID := apiCreateNote(t, env, user, jsBookUUID, "js2", "adding js note 2") + cssNote2UUID := apiCreateNote(t, env, user, cssBookUUID, "css2", "adding css note 2") + linuxBookUUID := apiCreateBook(t, env, user, "linux", "adding linux book") + linuxNote1UUID := apiCreateNote(t, env, user, linuxBookUUID, "linux1", "adding linux note 1") + apiPatchNote(t, env, user, jsNote2UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, linuxBookUUID), "moving js note 2 to linux") + apiDeleteNote(t, env, user, jsNote1UUID, "deleting js note 1") + cssNote3UUID := apiCreateNote(t, env, user, cssBookUUID, "css3", "adding css note 3") + bashBookUUID := apiCreateBook(t, env, user, "bash", "adding bash book") + bashNote1UUID := apiCreateNote(t, env, user, bashBookUUID, "bash1", "adding bash note 1") + apiDeleteBook(t, env, user, linuxBookUUID, "deleting linux book") + apiPatchNote(t, env, user, cssNote2UUID, fmt.Sprintf(`{"content": "%s"}`, "css2-edited"), "editing css 2 body") + bashNote2UUID := apiCreateNote(t, env, user, bashBookUUID, "bash2", "adding bash note 2") + linuxBook2UUID := apiCreateBook(t, env, user, "linux", "adding new linux book") + linux2Note1UUID := apiCreateNote(t, env, user, linuxBookUUID, "linux-new-1", "adding linux note 1") + apiDeleteBook(t, env, user, jsBookUUID, "deleting js book") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js3") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "algorithms", "-c", "algorithms1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js4") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "algorithms", "-c", "algorithms2") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "math", "-c", "math1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js3") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "algorithms", "-c", "algorithms1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js4") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "algorithms", "-c", "algorithms2") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "math", "-c", "math1") var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js3"), &nid) - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "algorithms") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css4") - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "algorithms") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css4") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) return map[string]string{ "jsBookUUID": jsBookUUID, @@ -822,11 +844,11 @@ func TestSync_twoway(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 9, clientBookCount: 6, clientLastMaxUSN: 27, @@ -1002,43 +1024,43 @@ func TestSync_twoway(t *testing.T) { }) t.Run("twice", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") - cssBookUUID := apiCreateBook(t, user, "css", "adding css book") - cssNote1UUID := apiCreateNote(t, user, cssBookUUID, "css1", "adding css note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding css book") + cssNote1UUID := apiCreateNote(t, env, user, cssBookUUID, "css1", "adding css note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js2") - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "math", "-c", "math1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js2") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "math", "-c", "math1") var nid string - cliDB := ctx.DB + cliDB := env.DB cliDatabase.MustScan(t, "getting id of note to edit", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "math1"), &nid) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "math", nid, "-c", "math1-edited") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "math", nid, "-c", "math1-edited") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - scssBookUUID := apiCreateBook(t, user, "scss", "adding a scss book") - apiPatchNote(t, user, cssNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, scssBookUUID), "moving css note 1 to scss") + scssBookUUID := apiCreateBook(t, env, user, "scss", "adding a scss book") + apiPatchNote(t, env, user, cssNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, scssBookUUID), "moving css note 1 to scss") var n1UUID string cliDatabase.MustScan(t, "getting math1-edited note UUID", cliDB.QueryRow("SELECT uuid FROM notes WHERE body = ?", "math1-edited"), &n1UUID) - apiPatchNote(t, user, n1UUID, fmt.Sprintf(`{"content": "%s", "public": true}`, "math1-edited"), "editing math1 note") + apiPatchNote(t, env, user, n1UUID, fmt.Sprintf(`{"content": "%s", "public": true}`, "math1-edited"), "editing math1 note") - cssNote2UUID := apiCreateNote(t, user, cssBookUUID, "css2", "adding css note 2") - apiDeleteBook(t, user, cssBookUUID, "deleting css book") + cssNote2UUID := apiCreateNote(t, env, user, cssBookUUID, "css2", "adding css note 2") + apiDeleteBook(t, env, user, cssBookUUID, "deleting css book") - bashBookUUID := apiCreateBook(t, user, "bash", "adding a bash book") - algorithmsBookUUID := apiCreateBook(t, user, "algorithms", "adding a algorithms book") + bashBookUUID := apiCreateBook(t, env, user, "bash", "adding a bash book") + algorithmsBookUUID := apiCreateBook(t, env, user, "algorithms", "adding a algorithms book") // 4. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js3") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "algorithms", "-c", "algorithms1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js3") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "algorithms", "-c", "algorithms1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1052,11 +1074,11 @@ func TestSync_twoway(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - apiDB := serverDb - cliDB := ctx.DB + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + apiDB := env.ServerDB + cliDB := env.DB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 5, clientBookCount: 6, clientLastMaxUSN: 17, @@ -1182,21 +1204,21 @@ func TestSync_twoway(t *testing.T) { }) t.Run("three times", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - goBookUUID := apiCreateBook(t, user, "go", "adding a go book") - goNote1UUID := apiCreateNote(t, user, goBookUUID, "go1", "adding go note 1") + goBookUUID := apiCreateBook(t, env, user, "go", "adding a go book") + goNote1UUID := apiCreateNote(t, env, user, goBookUUID, "go1", "adding go note 1") // 4. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "html", "-c", "html1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "html", "-c", "html1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1206,11 +1228,11 @@ func TestSync_twoway(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 4, clientBookCount: 4, clientLastMaxUSN: 8, @@ -1299,17 +1321,17 @@ func TestSync_twoway(t *testing.T) { func TestSync(t *testing.T) { t.Run("client adds a book and a note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") return map[string]string{} } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 2, @@ -1353,14 +1375,14 @@ func TestSync(t *testing.T) { }) t.Run("client deletes a book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1368,10 +1390,10 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 0, clientLastMaxUSN: 5, @@ -1403,18 +1425,18 @@ func TestSync(t *testing.T) { }) t.Run("client deletes a note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1422,11 +1444,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 1, clientLastMaxUSN: 3, @@ -1469,19 +1491,19 @@ func TestSync(t *testing.T) { }) t.Run("client edits a note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to edit", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1489,11 +1511,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 3, @@ -1540,14 +1562,14 @@ func TestSync(t *testing.T) { }) t.Run("client edits a book by renaming it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1555,11 +1577,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 3, @@ -1611,19 +1633,19 @@ func TestSync(t *testing.T) { }) t.Run("server adds a book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") return map[string]string{ "jsBookUUID": jsBookUUID, } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 1, clientLastMaxUSN: 1, @@ -1658,26 +1680,26 @@ func TestSync(t *testing.T) { }) t.Run("server edits a book by renaming it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiPatchBook(t, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-new-label"), "editing js book") + apiPatchBook(t, env, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-new-label"), "editing js book") return map[string]string{ "jsBookUUID": jsBookUUID, } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 1, clientLastMaxUSN: 2, @@ -1712,25 +1734,25 @@ func TestSync(t *testing.T) { }) t.Run("server deletes a book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiDeleteBook(t, user, jsBookUUID, "deleting js book") + apiDeleteBook(t, env, user, jsBookUUID, "deleting js book") return map[string]string{ "jsBookUUID": jsBookUUID, } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 0, clientLastMaxUSN: 2, @@ -1757,10 +1779,10 @@ func TestSync(t *testing.T) { }) t.Run("server adds a note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1768,11 +1790,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 2, @@ -1817,16 +1839,16 @@ func TestSync(t *testing.T) { }) t.Run("server edits a note body", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js note 1") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js note 1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1834,11 +1856,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 3, @@ -1883,17 +1905,17 @@ func TestSync(t *testing.T) { }) t.Run("server moves a note to another book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") - cssBookUUID := apiCreateBook(t, user, "css", "adding css book") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding css book") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1902,11 +1924,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 2, clientLastMaxUSN: 4, @@ -1958,16 +1980,16 @@ func TestSync(t *testing.T) { }) t.Run("server deletes a note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiDeleteNote(t, user, jsNote1UUID, "deleting js note 1") + apiDeleteNote(t, env, user, jsNote1UUID, "deleting js note 1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -1975,11 +1997,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 1, clientLastMaxUSN: 3, @@ -2020,19 +2042,19 @@ func TestSync(t *testing.T) { }) t.Run("client and server deletes the same book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiDeleteBook(t, user, jsBookUUID, "deleting js book") + apiDeleteBook(t, env, user, jsBookUUID, "deleting js book") // 4. on cli - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2040,10 +2062,10 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 0, clientLastMaxUSN: 6, @@ -2076,23 +2098,23 @@ func TestSync(t *testing.T) { }) t.Run("client and server deletes the same note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiDeleteNote(t, user, jsNote1UUID, "deleting js note 1") + apiDeleteNote(t, env, user, jsNote1UUID, "deleting js note 1") // 4. on cli var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js1"), &nid) - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2100,11 +2122,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - apiDB := serverDb - cliDB := ctx.DB + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + apiDB := env.ServerDB + cliDB := env.DB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 1, clientLastMaxUSN: 4, @@ -2148,19 +2170,19 @@ func TestSync(t *testing.T) { }) t.Run("server and client adds a note with same body", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 4. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2168,11 +2190,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 1, clientLastMaxUSN: 3, @@ -2222,13 +2244,13 @@ func TestSync(t *testing.T) { }) t.Run("server and client adds a book with same label", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2236,11 +2258,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -2297,16 +2319,16 @@ func TestSync(t *testing.T) { }) t.Run("server and client adds two sets of books with same labels", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") - cssBookUUID := apiCreateBook(t, user, "css", "adding css book") - cssNote1UUID := apiCreateNote(t, user, cssBookUUID, "css1", "adding css note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding css book") + cssNote1UUID := apiCreateNote(t, env, user, cssBookUUID, "css1", "adding css note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2316,11 +2338,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 4, clientBookCount: 4, clientLastMaxUSN: 8, @@ -2402,19 +2424,19 @@ func TestSync(t *testing.T) { }) t.Run("server and client adds notes to the same book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 4. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js2") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js2") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2422,11 +2444,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 1, clientLastMaxUSN: 3, @@ -2476,13 +2498,13 @@ func TestSync(t *testing.T) { }) t.Run("server and client adds a book with the same label and notes in it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js2") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js2") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2490,11 +2512,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -2550,22 +2572,22 @@ func TestSync(t *testing.T) { }) t.Run("client and server edits bodys of the same note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to edit", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited-from-client") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited-from-client") // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited-from-server"), "editing js note 1") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited-from-server"), "editing js note 1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2573,13 +2595,13 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB resolvedBody := "<<<<<<< Local\njs1-edited-from-client\n=======\njs1-edited-from-server\n>>>>>>> Server\n" - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 4, @@ -2626,21 +2648,21 @@ func TestSync(t *testing.T) { }) t.Run("clients deletes a note and server edits its body", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js note 1") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js note 1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2648,11 +2670,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 3, @@ -2699,22 +2721,22 @@ func TestSync(t *testing.T) { }) t.Run("clients deletes a note and server moves it to another book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") - cssBookUUID := apiCreateBook(t, user, "css", "adding css book") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding css book") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") var nid string cliDatabase.MustScan(t, "getting id of note to remove", cliDB.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", jsNote1UUID), &nid) - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveNote, cliBinaryName, "remove", "js", nid) // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2723,11 +2745,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 2, clientLastMaxUSN: 4, @@ -2783,23 +2805,23 @@ func TestSync(t *testing.T) { }) t.Run("server deletes a note and client edits it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiDeleteNote(t, user, jsNote1UUID, "deleting js note 1") + apiDeleteNote(t, env, user, jsNote1UUID, "deleting js note 1") // 4. on cli var nid string cliDatabase.MustScan(t, "getting id of note to edit", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js1"), &nid) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2807,11 +2829,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 4, @@ -2860,19 +2882,19 @@ func TestSync(t *testing.T) { }) t.Run("server deletes a book and client edits it by renaming it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiDeleteNote(t, user, jsNote1UUID, "deleting js note 1") + apiDeleteNote(t, env, user, jsNote1UUID, "deleting js note 1") // 4. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2880,11 +2902,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 1, clientLastMaxUSN: 4, @@ -2928,23 +2950,23 @@ func TestSync(t *testing.T) { }) t.Run("server deletes a book and client edits a note in it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - cliDB := ctx.DB + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + cliDB := env.DB // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiDeleteBook(t, user, jsBookUUID, "deleting js book") + apiDeleteBook(t, env, user, jsBookUUID, "deleting js book") // 4. on cli var nid string cliDatabase.MustScan(t, "getting id of note to edit", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js1"), &nid) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", nid, "-c", "js1-edited") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -2952,11 +2974,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 6, @@ -3005,17 +3027,17 @@ func TestSync(t *testing.T) { }) t.Run("client deletes a book and server edits it by renaming it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") // 3. on server - apiPatchBook(t, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-edited"), "editing js book") + apiPatchBook(t, env, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-edited"), "editing js book") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3023,11 +3045,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 1, clientLastMaxUSN: 5, @@ -3071,19 +3093,19 @@ func TestSync(t *testing.T) { }) t.Run("client deletes a book and server edits a note in it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js1 note") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"content": "%s"}`, "js1-edited"), "editing js1 note") // 4. on cli - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.ConfirmRemoveBook, cliBinaryName, "remove", "js") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3091,10 +3113,10 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 0, clientBookCount: 0, clientLastMaxUSN: 6, @@ -3127,17 +3149,17 @@ func TestSync(t *testing.T) { }) t.Run("client and server edit a book by renaming it to a same name", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited") // 3. on server - apiPatchBook(t, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-edited"), "editing js book") + apiPatchBook(t, env, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-edited"), "editing js book") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3145,11 +3167,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 4, @@ -3201,17 +3223,17 @@ func TestSync(t *testing.T) { }) t.Run("client and server edit a book by renaming it to different names", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited-client") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", "-n", "js-edited-client") // 3. on server - apiPatchBook(t, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-edited-server"), "editing js book") + apiPatchBook(t, env, user, jsBookUUID, fmt.Sprintf(`{"name": "%s"}`, "js-edited-server"), "editing js book") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3219,13 +3241,13 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { // In this case, server's change wins and overwrites that of client's - cliDB := ctx.DB - apiDB := serverDb + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 1, clientLastMaxUSN: 4, @@ -3277,17 +3299,17 @@ func TestSync(t *testing.T) { }) t.Run("client moves a note", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - cssBookUUID := apiCreateBook(t, user, "css", "adding a css book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding a css book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "1", "-b", "css") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "1", "-b", "css") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3296,11 +3318,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 2, clientLastMaxUSN: 4, @@ -3361,20 +3383,20 @@ func TestSync(t *testing.T) { }) t.Run("client and server each moves a note to a same book", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - cssBookUUID := apiCreateBook(t, user, "css", "adding a css book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding a css book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") // 3. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "1", "-b", "css") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "1", "-b", "css") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3383,11 +3405,11 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 2, clientLastMaxUSN: 5, @@ -3448,21 +3470,21 @@ func TestSync(t *testing.T) { }) t.Run("client and server each moves a note to different books", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - cssBookUUID := apiCreateBook(t, user, "css", "adding a css book") - linuxBookUUID := apiCreateBook(t, user, "linux", "adding a linux book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding a css book") + linuxBookUUID := apiCreateBook(t, env, user, "linux", "adding a linux book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - apiPatchNote(t, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") + apiPatchNote(t, env, user, jsNote1UUID, fmt.Sprintf(`{"book_uuid": "%s"}`, cssBookUUID), "moving js note 1 to css book") // 3. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "1", "-b", "linux") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "1", "-b", "linux") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3472,9 +3494,9 @@ func TestSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB expectedNote1JSBody := `<<<<<<< Local Moved to the book linux @@ -3484,7 +3506,7 @@ Moved to the book css js1` - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 1, clientBookCount: 4, clientLastMaxUSN: 7, @@ -3563,20 +3585,20 @@ js1` }) t.Run("client adds a new book and moves a note into it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") - cliDB := ctx.DB + cliDB := env.DB var nid string cliDatabase.MustScan(t, "getting id of note to edit", cliDB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js1"), &nid) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", "js", nid, "-b", "css") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", "js", nid, "-b", "css") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3584,11 +3606,11 @@ js1` } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 5, @@ -3661,23 +3683,23 @@ js1` }) t.Run("client adds a duplicate book and moves a note into it", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { // 1. on server - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") // 2. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // 3. on server - cssBookUUID := apiCreateBook(t, user, "css", "adding a css book") + cssBookUUID := apiCreateBook(t, env, user, "css", "adding a css book") // 3. on cli - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") var nid string - cliDatabase.MustScan(t, "getting id of note to edit", ctx.DB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js1"), &nid) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "edit", nid, "-b", "css") + cliDatabase.MustScan(t, "getting id of note to edit", env.DB.QueryRow("SELECT rowid FROM notes WHERE body = ?", "js1"), &nid) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "edit", nid, "-b", "css") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3686,11 +3708,11 @@ js1` } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 3, clientLastMaxUSN: 6, @@ -3774,11 +3796,11 @@ js1` func TestFullSync(t *testing.T) { t.Run("consecutively with stepSync", func(t *testing.T) { - setup := func(t *testing.T, ctx context.DnoteCtx, user database.User) map[string]string { - jsBookUUID := apiCreateBook(t, user, "js", "adding a js book") - jsNote1UUID := apiCreateNote(t, user, jsBookUUID, "js1", "adding js note 1") + setup := func(t *testing.T, env testEnv, user database.User) map[string]string { + jsBookUUID := apiCreateBook(t, env, user, "js", "adding a js book") + jsNote1UUID := apiCreateNote(t, env, user, jsBookUUID, "js1", "adding js note 1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") return map[string]string{ "jsBookUUID": jsBookUUID, @@ -3786,11 +3808,11 @@ func TestFullSync(t *testing.T) { } } - assert := func(t *testing.T, ctx context.DnoteCtx, user database.User, ids map[string]string) { - cliDB := ctx.DB - apiDB := serverDb + assert := func(t *testing.T, env testEnv, user database.User, ids map[string]string) { + cliDB := env.DB + apiDB := env.ServerDB - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -3850,38 +3872,26 @@ func TestFullSync(t *testing.T) { } t.Run("stepSync then fullSync", func(t *testing.T) { - // clean up - os.RemoveAll(tmpDirPath) - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) + env := setupTestEnv(t) + user := setupUserAndLogin(t, env) + ids := setup(t, env, user) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - user := setupUserAndLogin(t, ctx.DB) - ids := setup(t, ctx, user) - - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - assert(t, ctx, user, ids) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") - assert(t, ctx, user, ids) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + assert(t, env, user, ids) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "-f") + assert(t, env, user, ids) }) t.Run("fullSync then stepSync", func(t *testing.T) { - // clean up - os.RemoveAll(tmpDirPath) - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) + env := setupTestEnv(t) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + user := setupUserAndLogin(t, env) + ids := setup(t, env, user) - user := setupUserAndLogin(t, ctx.DB) - ids := setup(t, ctx, user) - - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "-f") - assert(t, ctx, user, ids) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") - assert(t, ctx, user, ids) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "-f") + assert(t, env, user, ids) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + assert(t, env, user, ids) }) }) } @@ -3891,24 +3901,17 @@ func TestSync_EmptyServer(t *testing.T) { // Test server data loss/wipe scenario (disaster recovery): // Verify empty server detection works when the server loses all its data - // clean up - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) + env := setupTestEnv(t) - clearTmp(t) - - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - - user := setupUserAndLogin(t, ctx.DB) + user := setupUserAndLogin(t, env) // Step 1: Create local data and sync to server - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // Verify sync succeeded - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -3918,17 +3921,18 @@ func TestSync_EmptyServer(t *testing.T) { serverUserMaxUSN: 4, }) - // Step 2: Clear all server data to simulate switching to a completely new empty server - apitest.ClearData(serverDb) - // Recreate user and session (simulating a new server) - user = setupUserAndLogin(t, ctx.DB) + // Step 2: Switch to a completely new empty server + switchToEmptyServer(t, &env) + + // Recreate user and session on new server + user = setupUserAndLogin(t, env) // Step 3: Sync again - should detect empty server and prompt user // User confirms with "y" - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync") // Step 4: Verify data was uploaded to the empty server - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -3941,10 +3945,10 @@ func TestSync_EmptyServer(t *testing.T) { // Verify the content is correct on both client and server var cliNote1JS, cliNote1CSS cliDatabase.Note var cliBookJS, cliBookCSS cliDatabase.Book - cliDatabase.MustScan(t, "finding cliNote1JS", ctx.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "js1"), &cliNote1JS.UUID, &cliNote1JS.Body) - cliDatabase.MustScan(t, "finding cliNote1CSS", ctx.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "css1"), &cliNote1CSS.UUID, &cliNote1CSS.Body) - cliDatabase.MustScan(t, "finding cliBookJS", ctx.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label) - cliDatabase.MustScan(t, "finding cliBookCSS", ctx.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label) + cliDatabase.MustScan(t, "finding cliNote1JS", env.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "js1"), &cliNote1JS.UUID, &cliNote1JS.Body) + cliDatabase.MustScan(t, "finding cliNote1CSS", env.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "css1"), &cliNote1CSS.UUID, &cliNote1CSS.Body) + cliDatabase.MustScan(t, "finding cliBookJS", env.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label) + cliDatabase.MustScan(t, "finding cliBookCSS", env.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label) assert.Equal(t, cliNote1JS.Body, "js1", "js note body mismatch") assert.Equal(t, cliNote1CSS.Body, "css1", "css note body mismatch") @@ -3954,10 +3958,10 @@ func TestSync_EmptyServer(t *testing.T) { // Verify on server side var serverNoteJS, serverNoteCSS database.Note var serverBookJS, serverBookCSS database.Book - apitest.MustExec(t, serverDb.Where("body = ?", "js1").First(&serverNoteJS), "finding server note js1") - apitest.MustExec(t, serverDb.Where("body = ?", "css1").First(&serverNoteCSS), "finding server note css1") - apitest.MustExec(t, serverDb.Where("label = ?", "js").First(&serverBookJS), "finding server book js") - apitest.MustExec(t, serverDb.Where("label = ?", "css").First(&serverBookCSS), "finding server book css") + apitest.MustExec(t, env.ServerDB.Where("body = ?", "js1").First(&serverNoteJS), "finding server note js1") + apitest.MustExec(t, env.ServerDB.Where("body = ?", "css1").First(&serverNoteCSS), "finding server note css1") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js").First(&serverBookJS), "finding server book js") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css").First(&serverBookCSS), "finding server book css") assert.Equal(t, serverNoteJS.Body, "js1", "server js note body mismatch") assert.Equal(t, serverNoteCSS.Body, "css1", "server css note body mismatch") @@ -3966,24 +3970,17 @@ func TestSync_EmptyServer(t *testing.T) { }) t.Run("user cancels empty server prompt", func(t *testing.T) { - // clean up - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) + env := setupTestEnv(t) - clearTmp(t) - - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - - user := setupUserAndLogin(t, ctx.DB) + user := setupUserAndLogin(t, env) // Step 1: Create local data and sync to server - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // Verify initial sync succeeded - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -3993,12 +3990,12 @@ func TestSync_EmptyServer(t *testing.T) { serverUserMaxUSN: 4, }) - // Step 2: Clear all server data - apitest.ClearData(serverDb) - user = setupUserAndLogin(t, ctx.DB) + // Step 2: Switch to empty server + switchToEmptyServer(t, &env) + user = setupUserAndLogin(t, env) // Step 3: Sync again but user cancels with "n" - output, err := clitest.WaitDnoteCmd(t, dnoteCmdOpts, clitest.UserCancelEmptyServerSync, cliBinaryName, "sync") + output, err := clitest.WaitDnoteCmd(t, env.CmdOpts, clitest.UserCancelEmptyServerSync, cliBinaryName, "sync") if err == nil { t.Fatal("Expected sync to fail when user cancels, but it succeeded") } @@ -4009,7 +4006,7 @@ func TestSync_EmptyServer(t *testing.T) { } // Step 4: Verify local state unchanged (transaction rolled back) - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4022,8 +4019,8 @@ func TestSync_EmptyServer(t *testing.T) { // Verify items still have original USN and dirty=false var book cliDatabase.Book var note cliDatabase.Note - cliDatabase.MustScan(t, "checking book state", ctx.DB.QueryRow("SELECT usn, dirty FROM books WHERE label = ?", "js"), &book.USN, &book.Dirty) - cliDatabase.MustScan(t, "checking note state", ctx.DB.QueryRow("SELECT usn, dirty FROM notes WHERE body = ?", "js1"), ¬e.USN, ¬e.Dirty) + cliDatabase.MustScan(t, "checking book state", env.DB.QueryRow("SELECT usn, dirty FROM books WHERE label = ?", "js"), &book.USN, &book.Dirty) + cliDatabase.MustScan(t, "checking note state", env.DB.QueryRow("SELECT usn, dirty FROM notes WHERE body = ?", "js1"), ¬e.USN, ¬e.Dirty) assert.NotEqual(t, book.USN, 0, "book USN should not be reset") assert.NotEqual(t, note.USN, 0, "note USN should not be reset") @@ -4035,24 +4032,17 @@ func TestSync_EmptyServer(t *testing.T) { // Test edge case: Server MaxUSN=0, local MaxUSN>0, but all items are deleted=true // Should NOT prompt because there's nothing to upload - // clean up - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) + env := setupTestEnv(t) - clearTmp(t) - - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - - user := setupUserAndLogin(t, ctx.DB) + user := setupUserAndLogin(t, env) // Step 1: Create local data and sync to server - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // Verify initial sync succeeded - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4063,35 +4053,35 @@ func TestSync_EmptyServer(t *testing.T) { }) // Step 2: Delete all local notes and books (mark as deleted) - cliDatabase.MustExec(t, "marking all books deleted", ctx.DB, "UPDATE books SET deleted = 1") - cliDatabase.MustExec(t, "marking all notes deleted", ctx.DB, "UPDATE notes SET deleted = 1") + cliDatabase.MustExec(t, "marking all books deleted", env.DB, "UPDATE books SET deleted = 1") + cliDatabase.MustExec(t, "marking all notes deleted", env.DB, "UPDATE notes SET deleted = 1") - // Step 3: Clear server data to simulate switching to empty server - apitest.ClearData(serverDb) - user = setupUserAndLogin(t, ctx.DB) + // Step 3: Switch to empty server + switchToEmptyServer(t, &env) + user = setupUserAndLogin(t, env) // Step 4: Sync - should NOT prompt because bookCount=0 and noteCount=0 (counting only deleted=0) // This should complete without user interaction - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // Verify no data was uploaded (server still empty, but client still has deleted items) // Check server is empty var serverNoteCount, serverBookCount int64 - apitest.MustExec(t, serverDb.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") - apitest.MustExec(t, serverDb.Model(&database.Book{}).Count(&serverBookCount), "counting server books") + apitest.MustExec(t, env.ServerDB.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") + apitest.MustExec(t, env.ServerDB.Model(&database.Book{}).Count(&serverBookCount), "counting server books") assert.Equal(t, serverNoteCount, int64(0), "server should have no notes") assert.Equal(t, serverBookCount, int64(0), "server should have no books") // Check client still has the deleted items locally var clientNoteCount, clientBookCount int - cliDatabase.MustScan(t, "counting client notes", ctx.DB.QueryRow("SELECT count(*) FROM notes WHERE deleted = 1"), &clientNoteCount) - cliDatabase.MustScan(t, "counting client books", ctx.DB.QueryRow("SELECT count(*) FROM books WHERE deleted = 1"), &clientBookCount) + cliDatabase.MustScan(t, "counting client notes", env.DB.QueryRow("SELECT count(*) FROM notes WHERE deleted = 1"), &clientNoteCount) + cliDatabase.MustScan(t, "counting client books", env.DB.QueryRow("SELECT count(*) FROM books WHERE deleted = 1"), &clientBookCount) assert.Equal(t, clientNoteCount, 2, "client should still have 2 deleted notes") assert.Equal(t, clientBookCount, 2, "client should still have 2 deleted books") // Verify lastMaxUSN was reset to 0 var lastMaxUSN int - cliDatabase.MustScan(t, "getting lastMaxUSN", ctx.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) + cliDatabase.MustScan(t, "getting lastMaxUSN", env.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) assert.Equal(t, lastMaxUSN, 0, "lastMaxUSN should be reset to 0") }) @@ -4113,23 +4103,17 @@ func TestSync_EmptyServer(t *testing.T) { // 4. Retrying sendChanges to upload the renamed books // - Result: Both clients' data is preserved (4 books total) - // Clean up - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) - clearTmp(t) + env := setupTestEnv(t) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - - user := setupUserAndLogin(t, ctx.DB) + user := setupUserAndLogin(t, env) // Step 1: Create local data and sync to establish lastMaxUSN > 0 - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // Verify initial sync succeeded - checkState(t, ctx, user, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4139,9 +4123,11 @@ func TestSync_EmptyServer(t *testing.T) { serverUserMaxUSN: 4, }) - // Step 2: Clear server to simulate switching to empty server - apitest.ClearData(serverDb) - user = setupUserAndLogin(t, ctx.DB) + // Step 2: Switch to new empty server to simulate switching to empty server + switchToEmptyServer(t, &env) + + // Create user on new server and login + user = setupUserAndLogin(t, env) // Step 3: Trigger sync which will detect empty server and prompt user // Inside the callback (before confirming), we simulate Client B uploading via API. @@ -4154,10 +4140,10 @@ func TestSync_EmptyServer(t *testing.T) { // Now Client B uploads the same data via API (after Client A got the sync state from the server // but before its sync decision) // This creates the race condition: Client A thinks server is empty, but Client B uploads data - jsBookUUID := apiCreateBook(t, user, "js", "client B creating js book") - cssBookUUID := apiCreateBook(t, user, "css", "client B creating css book") - apiCreateNote(t, user, jsBookUUID, "js1", "client B creating js note") - apiCreateNote(t, user, cssBookUUID, "css1", "client B creating css note") + jsBookUUID := apiCreateBook(t, env, user, "js", "client B creating js book") + cssBookUUID := apiCreateBook(t, env, user, "css", "client B creating css book") + apiCreateNote(t, env, user, jsBookUUID, "js1", "client B creating js note") + apiCreateNote(t, env, user, cssBookUUID, "css1", "client B creating css note") // Now user confirms if _, err := io.WriteString(stdin, "y\n"); err != nil { @@ -4174,10 +4160,10 @@ func TestSync_EmptyServer(t *testing.T) { // - mergeBook renames Client A's books to js_2, css_2 // - Renamed books are uploaded // - Both clients' data is preserved. - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, raceCallback, cliBinaryName, "sync") + clitest.MustWaitDnoteCmd(t, env.CmdOpts, raceCallback, cliBinaryName, "sync") // Verify final state - both clients' data preserved - checkStateWithDB(t, ctx.DB, user, serverDb, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 4, // Both clients' notes clientBookCount: 4, // js, css, js_2, css_2 clientLastMaxUSN: 8, // 4 from Client B + 4 from Client A's renamed books/notes @@ -4189,10 +4175,10 @@ func TestSync_EmptyServer(t *testing.T) { // Verify server has both clients' books var svrBookJS, svrBookCSS, svrBookJS2, svrBookCSS2 database.Book - apitest.MustExec(t, serverDb.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") - apitest.MustExec(t, serverDb.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") - apitest.MustExec(t, serverDb.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") - apitest.MustExec(t, serverDb.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") assert.Equal(t, svrBookJS.Label, "js", "server should have book 'js' (Client B)") assert.Equal(t, svrBookCSS.Label, "css", "server should have book 'css' (Client B)") @@ -4201,10 +4187,10 @@ func TestSync_EmptyServer(t *testing.T) { // Verify client has all books var cliBookJS, cliBookCSS, cliBookJS2, cliBookCSS2 cliDatabase.Book - cliDatabase.MustScan(t, "finding client book 'js'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) - cliDatabase.MustScan(t, "finding client book 'css'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) - cliDatabase.MustScan(t, "finding client book 'js_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) - cliDatabase.MustScan(t, "finding client book 'css_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) + cliDatabase.MustScan(t, "finding client book 'js'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) + cliDatabase.MustScan(t, "finding client book 'css'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) + cliDatabase.MustScan(t, "finding client book 'js_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) + cliDatabase.MustScan(t, "finding client book 'css_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) // Verify client UUIDs match server assert.Equal(t, cliBookJS.UUID, svrBookJS.UUID, "client 'js' UUID should match server") @@ -4225,27 +4211,17 @@ func TestSync_EmptyServer(t *testing.T) { // 2. No false detection when switching back to non-empty servers // 3. Both servers maintain independent state across multiple switches - // Clean up - clearTmp(t) - - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + env := setupTestEnv(t) // Create Server A with its own database - dbPathA := fmt.Sprintf("%s/serverA.db", testDir) - defer os.Remove(dbPathA) - - serverA, serverDbA, err := setupTestServer(dbPathA, serverTime) + serverA, serverDBA, err := setupTestServer(t, serverTime) if err != nil { t.Fatal(errors.Wrap(err, "setting up server A")) } defer serverA.Close() // Create Server B with its own database - dbPathB := fmt.Sprintf("%s/serverB.db", testDir) - defer os.Remove(dbPathB) - - serverB, serverDbB, err := setupTestServer(dbPathB, serverTime) + serverB, serverDBB, err := setupTestServer(t, serverTime) if err != nil { t.Fatal(errors.Wrap(err, "setting up server B")) } @@ -4254,17 +4230,17 @@ func TestSync_EmptyServer(t *testing.T) { // Step 1: Set up user on Server A and sync apiEndpointA := fmt.Sprintf("%s/api", serverA.URL) - userA := apitest.SetupUserData(serverDbA, "alice@example.com", "pass1234") - sessionA := apitest.SetupSession(serverDbA, userA) - cliDatabase.MustExec(t, "inserting session_key", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, sessionA.Key) - cliDatabase.MustExec(t, "inserting session_key_expiry", ctx.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, sessionA.ExpiresAt.Unix()) + userA := apitest.SetupUserData(serverDBA, "alice@example.com", "pass1234") + sessionA := apitest.SetupSession(serverDBA, userA) + cliDatabase.MustExec(t, "inserting session_key", env.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, sessionA.Key) + cliDatabase.MustExec(t, "inserting session_key_expiry", env.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, sessionA.ExpiresAt.Unix()) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) // Verify sync to Server A succeeded - checkStateWithDB(t, ctx.DB, userA, serverDbA, systemState{ + checkState(t, env.DB, userA, serverDBA, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4278,16 +4254,16 @@ func TestSync_EmptyServer(t *testing.T) { apiEndpointB := fmt.Sprintf("%s/api", serverB.URL) // Set up user on Server B - userB := apitest.SetupUserData(serverDbB, "alice@example.com", "pass1234") - sessionB := apitest.SetupSession(serverDbB, userB) - cliDatabase.MustExec(t, "updating session_key for B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) - cliDatabase.MustExec(t, "updating session_key_expiry for B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + userB := apitest.SetupUserData(serverDBB, "alice@example.com", "pass1234") + sessionB := apitest.SetupSession(serverDBB, userB) + cliDatabase.MustExec(t, "updating session_key for B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry for B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) // Should detect empty server and prompt - clitest.MustWaitDnoteCmd(t, dnoteCmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) // Verify Server B now has data - checkStateWithDB(t, ctx.DB, userB, serverDbB, systemState{ + checkState(t, env.DB, userB, serverDBB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4298,14 +4274,14 @@ func TestSync_EmptyServer(t *testing.T) { }) // Step 3: Switch back to Server A and sync - cliDatabase.MustExec(t, "updating session_key back to A", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.Key, consts.SystemSessionKey) - cliDatabase.MustExec(t, "updating session_key_expiry back to A", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + cliDatabase.MustExec(t, "updating session_key back to A", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry back to A", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) // Should NOT trigger empty server detection (Server A has MaxUSN > 0) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) // Verify Server A still has its data - checkStateWithDB(t, ctx.DB, userA, serverDbA, systemState{ + checkState(t, env.DB, userA, serverDBA, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4316,14 +4292,14 @@ func TestSync_EmptyServer(t *testing.T) { }) // Step 4: Switch back to Server B and sync again - cliDatabase.MustExec(t, "updating session_key back to B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) - cliDatabase.MustExec(t, "updating session_key_expiry back to B", ctx.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + cliDatabase.MustExec(t, "updating session_key back to B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry back to B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) // Should NOT trigger empty server detection (Server B now has MaxUSN > 0 from Step 2) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) // Verify both servers maintain independent state - checkStateWithDB(t, ctx.DB, userB, serverDbB, systemState{ + checkState(t, env.DB, userB, serverDBB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4347,33 +4323,27 @@ func TestSync_FreshClientConcurrent(t *testing.T) { // Expected: Client A should pull server data first, detect duplicate book names, // rename local books to avoid conflicts (js→js_2), then upload successfully. - // Clean up - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) - clearTmp(t) + env := setupTestEnv(t) - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) - - user := setupUserAndLogin(t, ctx.DB) + user := setupUserAndLogin(t, env) // Client A: Create local data (never sync) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") // Client B: Upload same book names to server via API - jsBookUUID := apiCreateBook(t, user, "js", "client B creating js book") - cssBookUUID := apiCreateBook(t, user, "css", "client B creating css book") - apiCreateNote(t, user, jsBookUUID, "js2", "client B note") - apiCreateNote(t, user, cssBookUUID, "css2", "client B note") + jsBookUUID := apiCreateBook(t, env, user, "js", "client B creating js book") + cssBookUUID := apiCreateBook(t, env, user, "css", "client B creating css book") + apiCreateNote(t, env, user, jsBookUUID, "js2", "client B note") + apiCreateNote(t, env, user, cssBookUUID, "css2", "client B note") // Client A syncs - should handle the conflict gracefully // Expected: pulls server data, renames local books to js_2/css_2, uploads successfully - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") // Verify: Should have 4 books and 4 notes on both client and server // USN breakdown: 2 books + 2 notes from Client B (USN 1-4), then 2 books + 2 notes from Client A (USN 5-8) - checkStateWithDB(t, ctx.DB, user, serverDb, systemState{ + checkState(t, env.DB, user, env.ServerDB, systemState{ clientNoteCount: 4, clientBookCount: 4, clientLastMaxUSN: 8, @@ -4385,10 +4355,10 @@ func TestSync_FreshClientConcurrent(t *testing.T) { // Verify server has all 4 books with correct names var svrBookJS, svrBookCSS, svrBookJS2, svrBookCSS2 database.Book - apitest.MustExec(t, serverDb.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") - apitest.MustExec(t, serverDb.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") - apitest.MustExec(t, serverDb.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") - apitest.MustExec(t, serverDb.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") assert.Equal(t, svrBookJS.Label, "js", "server should have book 'js' (Client B)") assert.Equal(t, svrBookCSS.Label, "css", "server should have book 'css' (Client B)") @@ -4397,10 +4367,10 @@ func TestSync_FreshClientConcurrent(t *testing.T) { // Verify server has all 4 notes with correct content var svrNoteJS1, svrNoteJS2, svrNoteCSS1, svrNoteCSS2 database.Note - apitest.MustExec(t, serverDb.Where("body = ?", "js1").First(&svrNoteJS1), "finding server note 'js1'") - apitest.MustExec(t, serverDb.Where("body = ?", "js2").First(&svrNoteJS2), "finding server note 'js2'") - apitest.MustExec(t, serverDb.Where("body = ?", "css1").First(&svrNoteCSS1), "finding server note 'css1'") - apitest.MustExec(t, serverDb.Where("body = ?", "css2").First(&svrNoteCSS2), "finding server note 'css2'") + apitest.MustExec(t, env.ServerDB.Where("body = ?", "js1").First(&svrNoteJS1), "finding server note 'js1'") + apitest.MustExec(t, env.ServerDB.Where("body = ?", "js2").First(&svrNoteJS2), "finding server note 'js2'") + apitest.MustExec(t, env.ServerDB.Where("body = ?", "css1").First(&svrNoteCSS1), "finding server note 'css1'") + apitest.MustExec(t, env.ServerDB.Where("body = ?", "css2").First(&svrNoteCSS2), "finding server note 'css2'") assert.Equal(t, svrNoteJS1.BookUUID, svrBookJS2.UUID, "note 'js1' should belong to book 'js_2' (Client A)") assert.Equal(t, svrNoteJS2.BookUUID, svrBookJS.UUID, "note 'js2' should belong to book 'js' (Client B)") @@ -4409,10 +4379,10 @@ func TestSync_FreshClientConcurrent(t *testing.T) { // Verify client has all 4 books var cliBookJS, cliBookCSS, cliBookJS2, cliBookCSS2 cliDatabase.Book - cliDatabase.MustScan(t, "finding client book 'js'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) - cliDatabase.MustScan(t, "finding client book 'css'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) - cliDatabase.MustScan(t, "finding client book 'js_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) - cliDatabase.MustScan(t, "finding client book 'css_2'", ctx.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) + cliDatabase.MustScan(t, "finding client book 'js'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) + cliDatabase.MustScan(t, "finding client book 'css'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) + cliDatabase.MustScan(t, "finding client book 'js_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) + cliDatabase.MustScan(t, "finding client book 'css_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) // Verify client UUIDs match server assert.Equal(t, cliBookJS.UUID, svrBookJS.UUID, "client 'js' UUID should match server") @@ -4428,10 +4398,10 @@ func TestSync_FreshClientConcurrent(t *testing.T) { // Verify client has all 4 notes var cliNoteJS1, cliNoteJS2, cliNoteCSS1, cliNoteCSS2 cliDatabase.Note - cliDatabase.MustScan(t, "finding client note 'js1'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "js1"), &cliNoteJS1.UUID, &cliNoteJS1.Body, &cliNoteJS1.USN) - cliDatabase.MustScan(t, "finding client note 'js2'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "js2"), &cliNoteJS2.UUID, &cliNoteJS2.Body, &cliNoteJS2.USN) - cliDatabase.MustScan(t, "finding client note 'css1'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "css1"), &cliNoteCSS1.UUID, &cliNoteCSS1.Body, &cliNoteCSS1.USN) - cliDatabase.MustScan(t, "finding client note 'css2'", ctx.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "css2"), &cliNoteCSS2.UUID, &cliNoteCSS2.Body, &cliNoteCSS2.USN) + cliDatabase.MustScan(t, "finding client note 'js1'", env.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "js1"), &cliNoteJS1.UUID, &cliNoteJS1.Body, &cliNoteJS1.USN) + cliDatabase.MustScan(t, "finding client note 'js2'", env.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "js2"), &cliNoteJS2.UUID, &cliNoteJS2.Body, &cliNoteJS2.USN) + cliDatabase.MustScan(t, "finding client note 'css1'", env.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "css1"), &cliNoteCSS1.UUID, &cliNoteCSS1.Body, &cliNoteCSS1.USN) + cliDatabase.MustScan(t, "finding client note 'css2'", env.DB.QueryRow("SELECT uuid, body, usn FROM notes WHERE body = ?", "css2"), &cliNoteCSS2.UUID, &cliNoteCSS2.Body, &cliNoteCSS2.USN) // Verify client note UUIDs match server assert.Equal(t, cliNoteJS1.UUID, svrNoteJS1.UUID, "client note 'js1' UUID should match server") @@ -4449,34 +4419,28 @@ func TestSync_FreshClientConcurrent(t *testing.T) { // TestSync_ConvergeSameBookNames tests that two clients don't enter an infinite sync loop if they // try to sync books with the same names. Books shouldn't get marked dirty when re-downloaded from server. func TestSync_ConvergeSameBookNames(t *testing.T) { - // Clean up and prepare server - apitest.ClearData(serverDb) - defer apitest.ClearData(serverDb) - - clearTmp(t) - - ctx := context.InitTestCtx(t, paths, nil) - defer context.TeardownTestCtx(t, ctx) + env := setupTestEnv(t) + tmpDir := t.TempDir() // Setup two separate client databases - client1DB := fmt.Sprintf("%s/client1.db", tmpDirPath) - client2DB := fmt.Sprintf("%s/client2.db", tmpDirPath) + client1DB := fmt.Sprintf("%s/client1.db", tmpDir) + client2DB := fmt.Sprintf("%s/client2.db", tmpDir) defer os.Remove(client1DB) defer os.Remove(client2DB) // Set up sessions - user := setupUser(t, ctx.DB) + user := setupUser(t, env) db1 := testutils.MustOpenDatabase(t, client1DB) db2 := testutils.MustOpenDatabase(t, client2DB) defer db1.Close() defer db2.Close() // Client 1: First sync to empty server - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "add", "testbook", "-c", "client1 note1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "add", "anotherbook", "-c", "client1 note2") - login(t, db1, user) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") - checkStateWithDB(t, db1, user, serverDb, systemState{ + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client1DB, "add", "testbook", "-c", "client1 note1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client1DB, "add", "anotherbook", "-c", "client1 note2") + login(t, db1, env.ServerDB, user) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") + checkState(t, db1, user, env.ServerDB, systemState{ clientNoteCount: 2, clientBookCount: 2, clientLastMaxUSN: 4, @@ -4487,12 +4451,12 @@ func TestSync_ConvergeSameBookNames(t *testing.T) { }) // Client 2: Sync (downloads client 1's data, adds own notes) ===== - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "add", "testbook", "-c", "client2 note1") - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "add", "anotherbook", "-c", "client2 note2") - login(t, db2, user) - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client2DB, "add", "testbook", "-c", "client2 note1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client2DB, "add", "anotherbook", "-c", "client2 note2") + login(t, db2, env.ServerDB, user) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client2DB, "sync") // Verify state after client2 sync - checkStateWithDB(t, db2, user, serverDb, systemState{ + checkState(t, db2, user, env.ServerDB, systemState{ clientNoteCount: 4, clientBookCount: 2, clientLastMaxUSN: 8, @@ -4503,11 +4467,11 @@ func TestSync_ConvergeSameBookNames(t *testing.T) { }) // Client 1: Sync again. It downloads client2's changes (2 extra notes). - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") // Verify MaxUSN did not increase (client1 should only download, not upload) // Client1 still has: 2 original books + 4 notes (2 own + 2 from client2) - checkStateWithDB(t, db1, user, serverDb, systemState{ + checkState(t, db1, user, env.ServerDB, systemState{ clientNoteCount: 4, clientBookCount: 2, clientLastMaxUSN: 8, @@ -4521,10 +4485,10 @@ func TestSync_ConvergeSameBookNames(t *testing.T) { // Both clients should be able to sync without any changes (MaxUSN stays at 8) for range 3 { // Client 2 syncs - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client2DB, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client2DB, "sync") // Verify client2 state unchanged - checkStateWithDB(t, db2, user, serverDb, systemState{ + checkState(t, db2, user, env.ServerDB, systemState{ clientNoteCount: 4, clientBookCount: 2, clientLastMaxUSN: 8, @@ -4535,10 +4499,10 @@ func TestSync_ConvergeSameBookNames(t *testing.T) { }) // Client 1 syncs - clitest.RunDnoteCmd(t, dnoteCmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client1DB, "sync") // Verify client1 state unchanged - checkStateWithDB(t, db1, user, serverDb, systemState{ + checkState(t, db1, user, env.ServerDB, systemState{ clientNoteCount: 4, clientBookCount: 2, clientLastMaxUSN: 8, diff --git a/pkg/server/.env.test b/pkg/server/.env.test deleted file mode 100644 index b9cf3101..00000000 --- a/pkg/server/.env.test +++ /dev/null @@ -1 +0,0 @@ -APP_ENV=TEST diff --git a/pkg/server/app/notes_test.go b/pkg/server/app/notes_test.go index 38195079..6ee55b8f 100644 --- a/pkg/server/app/notes_test.go +++ b/pkg/server/app/notes_test.go @@ -33,8 +33,6 @@ import ( func TestCreateNote(t *testing.T) { serverTime := time.Date(2017, time.March, 14, 21, 15, 0, 0, time.UTC) - mockClock := clock.NewMock() - mockClock.SetNow(serverTime) ts1 := time.Date(2018, time.November, 12, 10, 11, 0, 0, time.UTC).UnixNano() ts2 := time.Date(2018, time.November, 15, 0, 1, 10, 0, time.UTC).UnixNano() @@ -75,6 +73,10 @@ func TestCreateNote(t *testing.T) { for idx, tc := range testCases { func() { + // Create a new clock for each test case to avoid race conditions in parallel tests + mockClock := clock.NewMock() + mockClock.SetNow(serverTime) + db := testutils.InitMemoryDB(t) user := testutils.SetupUserData(db, "user@test.com", "password123") diff --git a/pkg/server/testutils/main.go b/pkg/server/testutils/main.go index 45c547d0..6b7c21b6 100644 --- a/pkg/server/testutils/main.go +++ b/pkg/server/testutils/main.go @@ -67,26 +67,6 @@ func InitMemoryDB(t *testing.T) *gorm.DB { return db } -// ClearData deletes all records from the database -func ClearData(db *gorm.DB) { - // Delete in order: child tables first, parent tables last - if err := db.Where("1 = 1").Delete(&database.Note{}).Error; err != nil { - panic(errors.Wrap(err, "Failed to clear notes")) - } - if err := db.Where("1 = 1").Delete(&database.Book{}).Error; err != nil { - panic(errors.Wrap(err, "Failed to clear books")) - } - if err := db.Where("1 = 1").Delete(&database.Token{}).Error; err != nil { - panic(errors.Wrap(err, "Failed to clear tokens")) - } - if err := db.Where("1 = 1").Delete(&database.Session{}).Error; err != nil { - panic(errors.Wrap(err, "Failed to clear sessions")) - } - if err := db.Where("1 = 1").Delete(&database.User{}).Error; err != nil { - panic(errors.Wrap(err, "Failed to clear users")) - } -} - // MustUUID generates a UUID and fails the test on error func MustUUID(t *testing.T) string { uuid, err := helpers.GenUUID() diff --git a/scripts/cli/test.sh b/scripts/cli/test.sh index e66db37a..42e0ad86 100755 --- a/scripts/cli/test.sh +++ b/scripts/cli/test.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -# test.sh runs test files sequentially -# https://stackoverflow.com/questions/23715302/go-how-to-run-tests-for-multiple-packages +# test.sh runs tests for CLI packages set -eux dir=$(dirname "${BASH_SOURCE[0]}") @@ -8,7 +7,5 @@ pushd "$dir/../../pkg/cli" # clear tmp dir in case not properly torn down rm -rf "./tmp" -go test -a ./... \ - -p 1\ - --tags "fts5" +go test ./... --tags "fts5" popd diff --git a/scripts/e2e/test.sh b/scripts/e2e/test.sh index 8ff94364..8713bb89 100755 --- a/scripts/e2e/test.sh +++ b/scripts/e2e/test.sh @@ -4,10 +4,6 @@ set -eux dir=$(dirname "${BASH_SOURCE[0]}") basePath=$(realpath "$dir/../../") -set -a -source "$basePath/pkg/server/.env.test" -set +a - pushd "$basePath"/pkg/e2e -go test --tags "fts5" ./... -p 1 -v -timeout 5m +go test --tags "fts5" ./... -v -timeout 5m popd diff --git a/scripts/server/test-local.sh b/scripts/server/test-local.sh index ce50d7d6..504ef444 100755 --- a/scripts/server/test-local.sh +++ b/scripts/server/test-local.sh @@ -5,8 +5,4 @@ set -ex dir=$(dirname "${BASH_SOURCE[0]}") -set -a -source "$dir/../../pkg/server/.env.test" -set +a - "$dir/test.sh" "$1" From a46afb821f298a03e68bfa465f2219b4cb78b9d0 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 26 Oct 2025 11:43:17 -0700 Subject: [PATCH 22/33] Fix an edge case of repeated syncs due to orphaned note (#704) * Split sync test * Reproduce a bug * Fix a bug * Fix in a more correct way * Add debug logs --- pkg/cli/client/client.go | 4 +- pkg/cli/cmd/sync/sync.go | 196 +++++- pkg/cli/cmd/sync/sync_test.go | 147 +++- pkg/cli/infra/init.go | 2 +- pkg/cli/log/log.go | 19 +- pkg/cli/migrate/migrate.go | 2 +- pkg/e2e/{sync_test.go => sync/basic_test.go} | 703 +------------------ pkg/e2e/sync/edge_cases_test.go | 73 ++ pkg/e2e/sync/empty_server_test.go | 449 ++++++++++++ pkg/e2e/sync/main_test.go | 59 ++ pkg/e2e/sync/testutils.go | 300 ++++++++ pkg/server/controllers/notes.go | 2 +- 12 files changed, 1204 insertions(+), 752 deletions(-) rename pkg/e2e/{sync_test.go => sync/basic_test.go} (86%) create mode 100644 pkg/e2e/sync/edge_cases_test.go create mode 100644 pkg/e2e/sync/empty_server_test.go create mode 100644 pkg/e2e/sync/main_test.go create mode 100644 pkg/e2e/sync/testutils.go diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index 1e122a3d..3fea9d21 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -176,7 +176,7 @@ func doReq(ctx context.DnoteCtx, method, path, body string, options *requestOpti return nil, errors.Wrap(err, "getting request") } - log.Debug("HTTP request: %+v\n", req) + log.Debug("HTTP %s %s\n", method, path) hc := getHTTPClient(ctx, options) res, err := hc.Do(req) @@ -184,7 +184,7 @@ func doReq(ctx context.DnoteCtx, method, path, body string, options *requestOpti return res, errors.Wrap(err, "making http request") } - log.Debug("HTTP response: %+v\n", res) + log.Debug("HTTP %d %s\n", res.StatusCode, res.Status) if err = checkRespErr(res); err != nil { return res, errors.Wrap(err, "server responded with an error") diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index fd870751..fcfc31fd 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -90,6 +90,7 @@ type syncList struct { ExpungedNotes map[string]bool ExpungedBooks map[string]bool MaxUSN int + UserMaxUSN int // Server's actual max USN (for distinguishing empty fragment vs empty server) MaxCurrentTime int64 } @@ -104,6 +105,7 @@ func processFragments(fragments []client.SyncFragment) (syncList, error) { expungedNotes := map[string]bool{} expungedBooks := map[string]bool{} var maxUSN int + var userMaxUSN int var maxCurrentTime int64 for _, fragment := range fragments { @@ -123,6 +125,9 @@ func processFragments(fragments []client.SyncFragment) (syncList, error) { if fragment.FragMaxUSN > maxUSN { maxUSN = fragment.FragMaxUSN } + if fragment.UserMaxUSN > userMaxUSN { + userMaxUSN = fragment.UserMaxUSN + } if fragment.CurrentTime > maxCurrentTime { maxCurrentTime = fragment.CurrentTime } @@ -134,6 +139,7 @@ func processFragments(fragments []client.SyncFragment) (syncList, error) { ExpungedNotes: expungedNotes, ExpungedBooks: expungedBooks, MaxUSN: maxUSN, + UserMaxUSN: userMaxUSN, MaxCurrentTime: maxCurrentTime, } @@ -180,11 +186,68 @@ func getSyncFragments(ctx context.DnoteCtx, afterUSN int) ([]client.SyncFragment } } - log.Debug("received sync fragments: %+v\n", buf) + log.Debug("received sync fragments: %+v\n", redactSyncFragments(buf)) return buf, nil } +// redactSyncFragments returns a deep copy of sync fragments with sensitive fields (note body, book label) removed for safe logging +func redactSyncFragments(fragments []client.SyncFragment) []client.SyncFragment { + redacted := make([]client.SyncFragment, len(fragments)) + for i, frag := range fragments { + // Create new notes with redacted bodies + notes := make([]client.SyncFragNote, len(frag.Notes)) + for j, note := range frag.Notes { + notes[j] = client.SyncFragNote{ + UUID: note.UUID, + BookUUID: note.BookUUID, + USN: note.USN, + CreatedAt: note.CreatedAt, + UpdatedAt: note.UpdatedAt, + AddedOn: note.AddedOn, + EditedOn: note.EditedOn, + Body: func() string { + if note.Body != "" { + return "" + } + return "" + }(), + Deleted: note.Deleted, + } + } + + // Create new books with redacted labels + books := make([]client.SyncFragBook, len(frag.Books)) + for j, book := range frag.Books { + books[j] = client.SyncFragBook{ + UUID: book.UUID, + USN: book.USN, + CreatedAt: book.CreatedAt, + UpdatedAt: book.UpdatedAt, + AddedOn: book.AddedOn, + Label: func() string { + if book.Label != "" { + return "" + } + return "" + }(), + Deleted: book.Deleted, + } + } + + redacted[i] = client.SyncFragment{ + FragMaxUSN: frag.FragMaxUSN, + UserMaxUSN: frag.UserMaxUSN, + CurrentTime: frag.CurrentTime, + Notes: notes, + Books: books, + ExpungedNotes: frag.ExpungedNotes, + ExpungedBooks: frag.ExpungedBooks, + } + } + return redacted +} + // resolveLabel resolves a book label conflict by repeatedly appending an increasing integer // to the label until it finds a unique label. It returns the first non-conflicting label. func resolveLabel(tx *database.DB, label string) (string, error) { @@ -540,6 +603,8 @@ func fullSync(ctx context.DnoteCtx, tx *database.DB) error { log.Debug("performing a full sync\n") log.Info("resolving delta.") + log.DebugNewline() + list, err := getSyncList(ctx, 0) if err != nil { return errors.Wrap(err, "getting sync list") @@ -547,6 +612,8 @@ func fullSync(ctx context.DnoteCtx, tx *database.DB) error { fmt.Printf(" (total %d).", list.getLength()) + log.DebugNewline() + // clean resources that are in erroneous states if err := cleanLocalNotes(tx, &list); err != nil { return errors.Wrap(err, "cleaning up local notes") @@ -577,7 +644,7 @@ func fullSync(ctx context.DnoteCtx, tx *database.DB) error { } } - err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN) + err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN, list.UserMaxUSN) if err != nil { return errors.Wrap(err, "saving sync state") } @@ -592,6 +659,8 @@ func stepSync(ctx context.DnoteCtx, tx *database.DB, afterUSN int) error { log.Info("resolving delta.") + log.DebugNewline() + list, err := getSyncList(ctx, afterUSN) if err != nil { return errors.Wrap(err, "getting sync list") @@ -621,7 +690,7 @@ func stepSync(ctx context.DnoteCtx, tx *database.DB, afterUSN int) error { } } - err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN) + err = saveSyncState(tx, list.MaxCurrentTime, list.MaxUSN, list.UserMaxUSN) if err != nil { return errors.Wrap(err, "saving sync state") } @@ -677,13 +746,9 @@ func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) { } else { resp, err := client.CreateBook(ctx, book.Label) if err != nil { - // If we get a 409 conflict, it means another client uploaded data. - if isConflictError(err) { - log.Debug("409 conflict creating book %s, will retry after sync\n", book.Label) - isBehind = true - continue - } - return isBehind, errors.Wrap(err, "creating a book") + log.Debug("error creating book (will retry after stepSync): %v\n", err) + isBehind = true + continue } _, err = tx.Exec("UPDATE notes SET book_uuid = ? WHERE book_uuid = ?", resp.Book.UUID, book.UUID) @@ -755,9 +820,91 @@ func sendBooks(ctx context.DnoteCtx, tx *database.DB) (bool, error) { return isBehind, nil } +// findOrphanedNotes returns a list of all orphaned notes +func findOrphanedNotes(db *database.DB) (int, []struct{ noteUUID, bookUUID string }, error) { + var orphanCount int + err := db.QueryRow(` + SELECT COUNT(*) FROM notes n + WHERE NOT EXISTS ( + SELECT 1 FROM books b + WHERE b.uuid = n.book_uuid + AND NOT b.deleted + ) + `).Scan(&orphanCount) + if err != nil { + return 0, nil, err + } + + if orphanCount == 0 { + return 0, nil, nil + } + + rows, err := db.Query(` + SELECT n.uuid, n.book_uuid + FROM notes n + WHERE NOT EXISTS ( + SELECT 1 FROM books b + WHERE b.uuid = n.book_uuid + AND NOT b.deleted + ) + `) + if err != nil { + return orphanCount, nil, err + } + defer rows.Close() + + var orphans []struct{ noteUUID, bookUUID string } + for rows.Next() { + var noteUUID, bookUUID string + if err := rows.Scan(¬eUUID, &bookUUID); err != nil { + continue + } + orphans = append(orphans, struct{ noteUUID, bookUUID string }{noteUUID, bookUUID}) + } + + return orphanCount, orphans, nil +} + +func warnOrphanedNotes(tx *database.DB) { + count, orphans, err := findOrphanedNotes(tx) + if err != nil { + log.Debug("error checking orphaned notes: %v\n", err) + return + } + + if count == 0 { + return + } + + log.Debug("Found %d orphaned notes (book doesn't exist locally):\n", count) + for _, o := range orphans { + log.Debug("note %s (book %s)\n", o.noteUUID, o.bookUUID) + } +} + +// checkPostSyncIntegrity checks for data integrity issues after sync and warns the user +func checkPostSyncIntegrity(db *database.DB) { + count, orphans, err := findOrphanedNotes(db) + if err != nil { + log.Debug("error checking orphaned notes: %v\n", err) + return + } + + if count == 0 { + return + } + + log.Warnf("Found %d orphaned notes (referencing non-existent or deleted books):\n", count) + for _, o := range orphans { + log.Plainf(" - note %s (missing book: %s)\n", o.noteUUID, o.bookUUID) + } +} + func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) { isBehind := false + warnOrphanedNotes(tx) + rows, err := tx.Query("SELECT uuid, book_uuid, body, deleted, usn, added_on FROM notes WHERE dirty") if err != nil { return isBehind, errors.Wrap(err, "getting syncable notes") @@ -771,7 +918,7 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) { return isBehind, errors.Wrap(err, "scanning a syncable note") } - log.Debug("sending note %s\n", note.UUID) + log.Debug("sending note %s (book: %s)\n", note.UUID, note.BookUUID) var respUSN int @@ -788,8 +935,7 @@ func sendNotes(ctx context.DnoteCtx, tx *database.DB) (bool, error) { } else { resp, err := client.CreateNote(ctx, note.BookUUID, note.Body) if err != nil { - // If we get a 409 conflict, it means another client uploaded data. - log.Debug("error creating note (will retry after sync): %v\n", err) + log.Debug("failed to create note %s (book: %s): %v\n", note.UUID, note.BookUUID, err) isBehind = true continue } @@ -866,6 +1012,8 @@ func sendChanges(ctx context.DnoteCtx, tx *database.DB) (bool, error) { fmt.Printf(" (total %d).", delta) + log.DebugNewline() + behind1, err := sendBooks(ctx, tx) if err != nil { return behind1, errors.Wrap(err, "sending books") @@ -899,10 +1047,24 @@ func updateLastSyncAt(tx *database.DB, val int64) error { return nil } -func saveSyncState(tx *database.DB, serverTime int64, serverMaxUSN int) error { - if err := updateLastMaxUSN(tx, serverMaxUSN); err != nil { - return errors.Wrap(err, "updating last max usn") +func saveSyncState(tx *database.DB, serverTime int64, serverMaxUSN int, userMaxUSN int) error { + // Handle last_max_usn update based on server state: + // - If serverMaxUSN > 0: we got data, update to serverMaxUSN + // - If serverMaxUSN == 0 && userMaxUSN > 0: empty fragment (caught up), preserve existing + // - If serverMaxUSN == 0 && userMaxUSN == 0: empty server, reset to 0 + if serverMaxUSN > 0 { + if err := updateLastMaxUSN(tx, serverMaxUSN); err != nil { + return errors.Wrap(err, "updating last max usn") + } + } else if userMaxUSN == 0 { + // Server is empty, reset to 0 + if err := updateLastMaxUSN(tx, 0); err != nil { + return errors.Wrap(err, "updating last max usn") + } } + // else: empty fragment but server has data, preserve existing last_max_usn + + // Always update last_sync_at (we did communicate with server) if err := updateLastSyncAt(tx, serverTime); err != nil { return errors.Wrap(err, "updating last sync at") } @@ -1065,6 +1227,8 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc { log.Success("success\n") + checkPostSyncIntegrity(ctx.DB) + if err := upgrade.Check(ctx); err != nil { log.Error(errors.Wrap(err, "automatically checking updates").Error()) } diff --git a/pkg/cli/cmd/sync/sync_test.go b/pkg/cli/cmd/sync/sync_test.go index 828179f5..6c22e926 100644 --- a/pkg/cli/cmd/sync/sync_test.go +++ b/pkg/cli/cmd/sync/sync_test.go @@ -36,7 +36,6 @@ import ( "github.com/pkg/errors" ) - func TestProcessFragments(t *testing.T) { fragments := []client.SyncFragment{ { @@ -98,6 +97,7 @@ func TestProcessFragments(t *testing.T) { ExpungedNotes: map[string]bool{}, ExpungedBooks: map[string]bool{}, MaxUSN: 10, + UserMaxUSN: 10, MaxCurrentTime: 1550436136, } @@ -1796,41 +1796,132 @@ func TestMergeBook(t *testing.T) { } func TestSaveServerState(t *testing.T) { - // set up - db := database.InitTestMemoryDB(t) - testutils.LoginDB(t, db) + t.Run("with data received", func(t *testing.T) { + // set up + db := database.InitTestMemoryDB(t) + testutils.LoginDB(t, db) - database.MustExec(t, "inserting last synced at", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastSyncAt, int64(1231108742)) - database.MustExec(t, "inserting last max usn", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastMaxUSN, 8) + database.MustExec(t, "inserting last synced at", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastSyncAt, int64(1231108742)) + database.MustExec(t, "inserting last max usn", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastMaxUSN, 8) - // execute - tx, err := db.Begin() - if err != nil { - t.Fatal(errors.Wrap(err, "beginning a transaction").Error()) - } + // execute + tx, err := db.Begin() + if err != nil { + t.Fatal(errors.Wrap(err, "beginning a transaction").Error()) + } - serverTime := int64(1541108743) - serverMaxUSN := 100 + serverTime := int64(1541108743) + serverMaxUSN := 100 + userMaxUSN := 100 - err = saveSyncState(tx, serverTime, serverMaxUSN) - if err != nil { - tx.Rollback() - t.Fatal(errors.Wrap(err, "executing").Error()) - } + err = saveSyncState(tx, serverTime, serverMaxUSN, userMaxUSN) + if err != nil { + tx.Rollback() + t.Fatal(errors.Wrap(err, "executing").Error()) + } - tx.Commit() + tx.Commit() - // test - var lastSyncedAt int64 - var lastMaxUSN int + // test + var lastSyncedAt int64 + var lastMaxUSN int - database.MustScan(t, "getting system value", - db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastSyncAt), &lastSyncedAt) - database.MustScan(t, "getting system value", - db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) + database.MustScan(t, "getting system value", + db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastSyncAt), &lastSyncedAt) + database.MustScan(t, "getting system value", + db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) - assert.Equal(t, lastSyncedAt, serverTime, "last synced at mismatch") - assert.Equal(t, lastMaxUSN, serverMaxUSN, "last max usn mismatch") + assert.Equal(t, lastSyncedAt, serverTime, "last synced at mismatch") + assert.Equal(t, lastMaxUSN, serverMaxUSN, "last max usn mismatch") + }) + + t.Run("with empty fragment but server has data - preserves last_max_usn", func(t *testing.T) { + // This tests the fix for the infinite sync bug where empty fragments + // would reset last_max_usn to 0, causing the client to re-download all data. + // When serverMaxUSN=0 (no data in fragment) but userMaxUSN>0 (server has data), + // we're caught up and should preserve the existing last_max_usn. + + // set up + db := database.InitTestMemoryDB(t) + testutils.LoginDB(t, db) + + existingLastMaxUSN := 100 + database.MustExec(t, "inserting last synced at", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastSyncAt, int64(1231108742)) + database.MustExec(t, "inserting last max usn", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastMaxUSN, existingLastMaxUSN) + + // execute + tx, err := db.Begin() + if err != nil { + t.Fatal(errors.Wrap(err, "beginning a transaction").Error()) + } + + serverTime := int64(1541108743) + serverMaxUSN := 0 // Empty fragment (no data in this sync) + userMaxUSN := 150 // Server's actual max USN (higher than ours) + + err = saveSyncState(tx, serverTime, serverMaxUSN, userMaxUSN) + if err != nil { + tx.Rollback() + t.Fatal(errors.Wrap(err, "executing").Error()) + } + + tx.Commit() + + // test + var lastSyncedAt int64 + var lastMaxUSN int + + database.MustScan(t, "getting system value", + db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastSyncAt), &lastSyncedAt) + database.MustScan(t, "getting system value", + db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) + + assert.Equal(t, lastSyncedAt, serverTime, "last synced at should be updated") + // last_max_usn should NOT be updated to 0, it should preserve the existing value + assert.Equal(t, lastMaxUSN, existingLastMaxUSN, "last max usn should be preserved when fragment is empty but server has data") + }) + + t.Run("with empty server - resets last_max_usn to 0", func(t *testing.T) { + // When both serverMaxUSN=0 and userMaxUSN=0, the server is truly empty + // and we should reset last_max_usn to 0. + + // set up + db := database.InitTestMemoryDB(t) + testutils.LoginDB(t, db) + + database.MustExec(t, "inserting last synced at", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastSyncAt, int64(1231108742)) + database.MustExec(t, "inserting last max usn", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemLastMaxUSN, 50) + + // execute + tx, err := db.Begin() + if err != nil { + t.Fatal(errors.Wrap(err, "beginning a transaction").Error()) + } + + serverTime := int64(1541108743) + serverMaxUSN := 0 // Empty fragment + userMaxUSN := 0 // Server is actually empty + + err = saveSyncState(tx, serverTime, serverMaxUSN, userMaxUSN) + if err != nil { + tx.Rollback() + t.Fatal(errors.Wrap(err, "executing").Error()) + } + + tx.Commit() + + // test + var lastSyncedAt int64 + var lastMaxUSN int + + database.MustScan(t, "getting system value", + db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastSyncAt), &lastSyncedAt) + database.MustScan(t, "getting system value", + db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) + + assert.Equal(t, lastSyncedAt, serverTime, "last synced at should be updated") + assert.Equal(t, lastMaxUSN, 0, "last max usn should be reset to 0 when server is empty") + }) } // TestSendBooks tests that books are put to correct 'buckets' by running a test server and recording the diff --git a/pkg/cli/infra/init.go b/pkg/cli/infra/init.go index 1e572cf7..b87cfdd4 100644 --- a/pkg/cli/infra/init.go +++ b/pkg/cli/infra/init.go @@ -137,7 +137,7 @@ func Init(versionTag, apiEndpoint, dbPath string) (*context.DnoteCtx, error) { return nil, errors.Wrap(err, "setting up the context") } - log.Debug("Running with Dnote context: %+v\n", context.Redact(ctx)) + log.Debug("context: %+v\n", context.Redact(ctx)) return &ctx, nil } diff --git a/pkg/cli/log/log.go b/pkg/cli/log/log.go index 36c8cdd1..dc78e2b4 100644 --- a/pkg/cli/log/log.go +++ b/pkg/cli/log/log.go @@ -25,6 +25,11 @@ import ( "github.com/fatih/color" ) +const ( + debugEnvName = "DNOTE_DEBUG" + debugEnvValue = "1" +) + var ( // ColorRed is a red foreground color ColorRed = color.New(color.FgRed) @@ -105,9 +110,21 @@ func Askf(msg string, masked bool, v ...interface{}) { fmt.Fprintf(color.Output, "%s%s %s: ", indent, symbol, fmt.Sprintf(msg, v...)) } +// isDebug returns true if debug mode is enabled +func isDebug() bool { + return os.Getenv(debugEnvName) == debugEnvValue +} + // Debug prints to the console if DNOTE_DEBUG is set func Debug(msg string, v ...interface{}) { - if os.Getenv("DNOTE_DEBUG") == "1" { + if isDebug() { fmt.Fprintf(color.Output, "%s %s", ColorGray.Sprint("DEBUG:"), fmt.Sprintf(msg, v...)) } } + +// DebugNewline prints a newline only in debug mode +func DebugNewline() { + if isDebug() { + fmt.Println() + } +} diff --git a/pkg/cli/migrate/migrate.go b/pkg/cli/migrate/migrate.go index eadfeda4..d579ffb7 100644 --- a/pkg/cli/migrate/migrate.go +++ b/pkg/cli/migrate/migrate.go @@ -144,7 +144,7 @@ func Run(ctx context.DnoteCtx, migrations []migration, mode int) error { return errors.Wrap(err, "getting the current schema") } - log.Debug("current schema: %s %d of %d\n", consts.SystemSchema, schema, len(migrations)) + log.Debug("%s: %d of %d\n", schemaKey, schema, len(migrations)) toRun := migrations[schema:] diff --git a/pkg/e2e/sync_test.go b/pkg/e2e/sync/basic_test.go similarity index 86% rename from pkg/e2e/sync_test.go rename to pkg/e2e/sync/basic_test.go index 10df15c9..4986229a 100644 --- a/pkg/e2e/sync_test.go +++ b/pkg/e2e/sync/basic_test.go @@ -16,307 +16,21 @@ * along with Dnote. If not, see . */ -package main +package sync import ( - "bytes" - "encoding/json" "fmt" - "io" - "log" - "net/http" - "net/http/httptest" "os" - "os/exec" - "path/filepath" - "strings" "testing" - "time" "github.com/dnote/dnote/pkg/assert" - "github.com/dnote/dnote/pkg/cli/consts" cliDatabase "github.com/dnote/dnote/pkg/cli/database" "github.com/dnote/dnote/pkg/cli/testutils" clitest "github.com/dnote/dnote/pkg/cli/testutils" - "github.com/dnote/dnote/pkg/clock" - "github.com/dnote/dnote/pkg/server/app" - "github.com/dnote/dnote/pkg/server/controllers" "github.com/dnote/dnote/pkg/server/database" - "github.com/dnote/dnote/pkg/server/mailer" apitest "github.com/dnote/dnote/pkg/server/testutils" - "github.com/pkg/errors" - "gorm.io/gorm" ) -var cliBinaryName string -var serverTime = time.Date(2017, time.March, 14, 21, 15, 0, 0, time.UTC) - -var testDir = "./tmp/.dnote" - -func init() { - cliBinaryName = fmt.Sprintf("%s/test/cli/test-cli", testDir) -} - -// testEnv holds the test environment for a single test -type testEnv struct { - DB *cliDatabase.DB - CmdOpts clitest.RunDnoteCmdOptions - Server *httptest.Server - ServerDB *gorm.DB - TmpDir string -} - -// setupTestEnv creates an isolated test environment with its own database and temp directory -func setupTestEnv(t *testing.T) testEnv { - tmpDir := t.TempDir() - - // Create .dnote directory - dnoteDir := filepath.Join(tmpDir, consts.DnoteDirName) - if err := os.MkdirAll(dnoteDir, 0755); err != nil { - t.Fatal(errors.Wrap(err, "creating dnote directory")) - } - - // Create database at the expected path - dbPath := filepath.Join(dnoteDir, consts.DnoteDBFileName) - db := cliDatabase.InitTestFileDBRaw(t, dbPath) - - // Create server - server, serverDB := setupNewServer(t) - - // Create config file with this server's endpoint - apiEndpoint := fmt.Sprintf("%s/api", server.URL) - updateConfigAPIEndpoint(t, tmpDir, apiEndpoint) - - // Create command options with XDG paths pointing to temp dir - cmdOpts := clitest.RunDnoteCmdOptions{ - Env: []string{ - fmt.Sprintf("XDG_CONFIG_HOME=%s", tmpDir), - fmt.Sprintf("XDG_DATA_HOME=%s", tmpDir), - fmt.Sprintf("XDG_CACHE_HOME=%s", tmpDir), - }, - } - - return testEnv{ - DB: db, - CmdOpts: cmdOpts, - Server: server, - ServerDB: serverDB, - TmpDir: tmpDir, - } -} - -// setupTestServer creates a test server with its own database -func setupTestServer(t *testing.T, serverTime time.Time) (*httptest.Server, *gorm.DB, error) { - db := apitest.InitMemoryDB(t) - - mockClock := clock.NewMock() - mockClock.SetNow(serverTime) - - a := app.NewTest() - a.Clock = mockClock - a.EmailTemplates = mailer.Templates{} - a.EmailBackend = &apitest.MockEmailbackendImplementation{} - a.DB = db - - server, err := controllers.NewServer(&a) - if err != nil { - return nil, nil, errors.Wrap(err, "initializing server") - } - - return server, db, nil -} - -// setupNewServer creates a new server and returns the server and database. -// This is useful when a test needs to switch to a new empty server. -func setupNewServer(t *testing.T) (*httptest.Server, *gorm.DB) { - server, serverDB, err := setupTestServer(t, serverTime) - if err != nil { - t.Fatal(errors.Wrap(err, "setting up new test server")) - } - t.Cleanup(func() { server.Close() }) - - return server, serverDB -} - -// updateConfigAPIEndpoint updates the config file with the given API endpoint -func updateConfigAPIEndpoint(t *testing.T, tmpDir string, apiEndpoint string) { - dnoteDir := filepath.Join(tmpDir, consts.DnoteDirName) - configPath := filepath.Join(dnoteDir, consts.ConfigFilename) - configContent := fmt.Sprintf("apiEndpoint: %s\n", apiEndpoint) - if err := os.WriteFile(configPath, []byte(configContent), 0644); err != nil { - t.Fatal(errors.Wrap(err, "writing config file")) - } -} - -// switchToEmptyServer closes the current server and creates a new empty server, -// updating the config file to point to it. -func switchToEmptyServer(t *testing.T, env *testEnv) { - // Close old server - env.Server.Close() - - // Create new empty server - env.Server, env.ServerDB = setupNewServer(t) - - // Update config file to point to new server - apiEndpoint := fmt.Sprintf("%s/api", env.Server.URL) - updateConfigAPIEndpoint(t, env.TmpDir, apiEndpoint) -} - -func TestMain(m *testing.M) { - // Build CLI binary without hardcoded API endpoint - // Each test will create its own server and config file - cmd := exec.Command("go", "build", "--tags", "fts5", "-o", cliBinaryName, "github.com/dnote/dnote/pkg/cli") - - var stderr bytes.Buffer - cmd.Stderr = &stderr - - if err := cmd.Run(); err != nil { - log.Print(errors.Wrap(err, "building a CLI binary").Error()) - log.Print(stderr.String()) - os.Exit(1) - } - - os.Exit(m.Run()) -} - -// helpers -func setupUser(t *testing.T, env testEnv) database.User { - user := apitest.SetupUserData(env.ServerDB, "alice@example.com", "pass1234") - - return user -} - -func setupUserAndLogin(t *testing.T, env testEnv) database.User { - user := setupUser(t, env) - login(t, env.DB, env.ServerDB, user) - - return user -} - -// log in the user in CLI -func login(t *testing.T, db *cliDatabase.DB, serverDB *gorm.DB, user database.User) { - session := apitest.SetupSession(serverDB, user) - - cliDatabase.MustExec(t, "inserting session_key", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, session.Key) - cliDatabase.MustExec(t, "inserting session_key_expiry", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, session.ExpiresAt.Unix()) -} - -func apiCreateBook(t *testing.T, env testEnv, user database.User, name, message string) string { - res := doHTTPReq(t, env, "POST", "/v3/books", fmt.Sprintf(`{"name": "%s"}`, name), message, user) - - var resp controllers.CreateBookResp - if err := json.NewDecoder(res.Body).Decode(&resp); err != nil { - t.Fatal(errors.Wrap(err, "decoding payload for adding book")) - return "" - } - - return resp.Book.UUID -} - -func apiPatchBook(t *testing.T, env testEnv, user database.User, uuid, payload, message string) { - doHTTPReq(t, env, "PATCH", fmt.Sprintf("/v3/books/%s", uuid), payload, message, user) -} - -func apiDeleteBook(t *testing.T, env testEnv, user database.User, uuid, message string) { - doHTTPReq(t, env, "DELETE", fmt.Sprintf("/v3/books/%s", uuid), "", message, user) -} - -func apiCreateNote(t *testing.T, env testEnv, user database.User, bookUUID, body, message string) string { - res := doHTTPReq(t, env, "POST", "/v3/notes", fmt.Sprintf(`{"book_uuid": "%s", "content": "%s"}`, bookUUID, body), message, user) - - var resp controllers.CreateNoteResp - if err := json.NewDecoder(res.Body).Decode(&resp); err != nil { - t.Fatal(errors.Wrap(err, "decoding payload for adding note")) - return "" - } - - return resp.Result.UUID -} - -func apiPatchNote(t *testing.T, env testEnv, user database.User, noteUUID, payload, message string) { - doHTTPReq(t, env, "PATCH", fmt.Sprintf("/v3/notes/%s", noteUUID), payload, message, user) -} - -func apiDeleteNote(t *testing.T, env testEnv, user database.User, noteUUID, message string) { - doHTTPReq(t, env, "DELETE", fmt.Sprintf("/v3/notes/%s", noteUUID), "", message, user) -} - -func doHTTPReq(t *testing.T, env testEnv, method, path, payload, message string, user database.User) *http.Response { - apiEndpoint := fmt.Sprintf("%s/api", env.Server.URL) - endpoint := fmt.Sprintf("%s%s", apiEndpoint, path) - - req, err := http.NewRequest(method, endpoint, strings.NewReader(payload)) - if err != nil { - panic(errors.Wrap(err, "constructing http request")) - } - - res := apitest.HTTPAuthDo(t, env.ServerDB, req, user) - if res.StatusCode >= 400 { - bs, err := io.ReadAll(res.Body) - if err != nil { - panic(errors.Wrap(err, "parsing response body for error")) - } - - t.Errorf("%s. HTTP status %d. Message: %s", message, res.StatusCode, string(bs)) - } - - return res -} - -type setupFunc func(t *testing.T, env testEnv, user database.User) map[string]string -type assertFunc func(t *testing.T, env testEnv, user database.User, ids map[string]string) - -func testSyncCmd(t *testing.T, fullSync bool, setup setupFunc, assert assertFunc) { - env := setupTestEnv(t) - - user := setupUserAndLogin(t, env) - ids := setup(t, env, user) - - if fullSync { - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "-f") - } else { - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - } - - assert(t, env, user, ids) -} - -type systemState struct { - clientNoteCount int - clientBookCount int - clientLastMaxUSN int - clientLastSyncAt int64 - serverNoteCount int64 - serverBookCount int64 - serverUserMaxUSN int -} - -// checkState compares the state of the client and the server with the given system state -func checkState(t *testing.T, clientDB *cliDatabase.DB, user database.User, serverDB *gorm.DB, expected systemState) { - var clientBookCount, clientNoteCount int - cliDatabase.MustScan(t, "counting client notes", clientDB.QueryRow("SELECT count(*) FROM notes"), &clientNoteCount) - cliDatabase.MustScan(t, "counting client books", clientDB.QueryRow("SELECT count(*) FROM books"), &clientBookCount) - assert.Equal(t, clientNoteCount, expected.clientNoteCount, "client note count mismatch") - assert.Equal(t, clientBookCount, expected.clientBookCount, "client book count mismatch") - - var clientLastMaxUSN int - var clientLastSyncAt int64 - cliDatabase.MustScan(t, "finding system last_max_usn", clientDB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &clientLastMaxUSN) - cliDatabase.MustScan(t, "finding system last_sync_at", clientDB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastSyncAt), &clientLastSyncAt) - assert.Equal(t, clientLastMaxUSN, expected.clientLastMaxUSN, "client last_max_usn mismatch") - assert.Equal(t, clientLastSyncAt, expected.clientLastSyncAt, "client last_sync_at mismatch") - - var serverBookCount, serverNoteCount int64 - apitest.MustExec(t, serverDB.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") - apitest.MustExec(t, serverDB.Model(&database.Book{}).Count(&serverBookCount), "counting api notes") - assert.Equal(t, serverNoteCount, expected.serverNoteCount, "server note count mismatch") - assert.Equal(t, serverBookCount, expected.serverBookCount, "server book count mismatch") - var serverUser database.User - apitest.MustExec(t, serverDB.Where("id = ?", user.ID).First(&serverUser), "finding user") - assert.Equal(t, serverUser.MaxUSN, expected.serverUserMaxUSN, "user max_usn mismatch") -} - -// tests func TestSync_Empty(t *testing.T) { setup := func(t *testing.T, env testEnv, user database.User) map[string]string { return map[string]string{} @@ -3896,421 +3610,6 @@ func TestFullSync(t *testing.T) { }) } -func TestSync_EmptyServer(t *testing.T) { - t.Run("sync to empty server after syncing to non-empty server", func(t *testing.T) { - // Test server data loss/wipe scenario (disaster recovery): - // Verify empty server detection works when the server loses all its data - - env := setupTestEnv(t) - - user := setupUserAndLogin(t, env) - - // Step 1: Create local data and sync to server - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - - // Verify sync succeeded - checkState(t, env.DB, user, env.ServerDB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Step 2: Switch to a completely new empty server - switchToEmptyServer(t, &env) - - // Recreate user and session on new server - user = setupUserAndLogin(t, env) - - // Step 3: Sync again - should detect empty server and prompt user - // User confirms with "y" - clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync") - - // Step 4: Verify data was uploaded to the empty server - checkState(t, env.DB, user, env.ServerDB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Verify the content is correct on both client and server - var cliNote1JS, cliNote1CSS cliDatabase.Note - var cliBookJS, cliBookCSS cliDatabase.Book - cliDatabase.MustScan(t, "finding cliNote1JS", env.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "js1"), &cliNote1JS.UUID, &cliNote1JS.Body) - cliDatabase.MustScan(t, "finding cliNote1CSS", env.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "css1"), &cliNote1CSS.UUID, &cliNote1CSS.Body) - cliDatabase.MustScan(t, "finding cliBookJS", env.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label) - cliDatabase.MustScan(t, "finding cliBookCSS", env.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label) - - assert.Equal(t, cliNote1JS.Body, "js1", "js note body mismatch") - assert.Equal(t, cliNote1CSS.Body, "css1", "css note body mismatch") - assert.Equal(t, cliBookJS.Label, "js", "js book label mismatch") - assert.Equal(t, cliBookCSS.Label, "css", "css book label mismatch") - - // Verify on server side - var serverNoteJS, serverNoteCSS database.Note - var serverBookJS, serverBookCSS database.Book - apitest.MustExec(t, env.ServerDB.Where("body = ?", "js1").First(&serverNoteJS), "finding server note js1") - apitest.MustExec(t, env.ServerDB.Where("body = ?", "css1").First(&serverNoteCSS), "finding server note css1") - apitest.MustExec(t, env.ServerDB.Where("label = ?", "js").First(&serverBookJS), "finding server book js") - apitest.MustExec(t, env.ServerDB.Where("label = ?", "css").First(&serverBookCSS), "finding server book css") - - assert.Equal(t, serverNoteJS.Body, "js1", "server js note body mismatch") - assert.Equal(t, serverNoteCSS.Body, "css1", "server css note body mismatch") - assert.Equal(t, serverBookJS.Label, "js", "server js book label mismatch") - assert.Equal(t, serverBookCSS.Label, "css", "server css book label mismatch") - }) - - t.Run("user cancels empty server prompt", func(t *testing.T) { - env := setupTestEnv(t) - - user := setupUserAndLogin(t, env) - - // Step 1: Create local data and sync to server - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - - // Verify initial sync succeeded - checkState(t, env.DB, user, env.ServerDB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Step 2: Switch to empty server - switchToEmptyServer(t, &env) - user = setupUserAndLogin(t, env) - - // Step 3: Sync again but user cancels with "n" - output, err := clitest.WaitDnoteCmd(t, env.CmdOpts, clitest.UserCancelEmptyServerSync, cliBinaryName, "sync") - if err == nil { - t.Fatal("Expected sync to fail when user cancels, but it succeeded") - } - - // Verify the prompt appeared - if !strings.Contains(output, clitest.PromptEmptyServer) { - t.Fatalf("Expected empty server warning in output, got: %s", output) - } - - // Step 4: Verify local state unchanged (transaction rolled back) - checkState(t, env.DB, user, env.ServerDB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 0, - serverBookCount: 0, - serverUserMaxUSN: 0, - }) - - // Verify items still have original USN and dirty=false - var book cliDatabase.Book - var note cliDatabase.Note - cliDatabase.MustScan(t, "checking book state", env.DB.QueryRow("SELECT usn, dirty FROM books WHERE label = ?", "js"), &book.USN, &book.Dirty) - cliDatabase.MustScan(t, "checking note state", env.DB.QueryRow("SELECT usn, dirty FROM notes WHERE body = ?", "js1"), ¬e.USN, ¬e.Dirty) - - assert.NotEqual(t, book.USN, 0, "book USN should not be reset") - assert.NotEqual(t, note.USN, 0, "note USN should not be reset") - assert.Equal(t, book.Dirty, false, "book should not be marked dirty") - assert.Equal(t, note.Dirty, false, "note should not be marked dirty") - }) - - t.Run("all local data is marked deleted - should not upload", func(t *testing.T) { - // Test edge case: Server MaxUSN=0, local MaxUSN>0, but all items are deleted=true - // Should NOT prompt because there's nothing to upload - - env := setupTestEnv(t) - - user := setupUserAndLogin(t, env) - - // Step 1: Create local data and sync to server - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - - // Verify initial sync succeeded - checkState(t, env.DB, user, env.ServerDB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Step 2: Delete all local notes and books (mark as deleted) - cliDatabase.MustExec(t, "marking all books deleted", env.DB, "UPDATE books SET deleted = 1") - cliDatabase.MustExec(t, "marking all notes deleted", env.DB, "UPDATE notes SET deleted = 1") - - // Step 3: Switch to empty server - switchToEmptyServer(t, &env) - user = setupUserAndLogin(t, env) - - // Step 4: Sync - should NOT prompt because bookCount=0 and noteCount=0 (counting only deleted=0) - // This should complete without user interaction - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - - // Verify no data was uploaded (server still empty, but client still has deleted items) - // Check server is empty - var serverNoteCount, serverBookCount int64 - apitest.MustExec(t, env.ServerDB.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") - apitest.MustExec(t, env.ServerDB.Model(&database.Book{}).Count(&serverBookCount), "counting server books") - assert.Equal(t, serverNoteCount, int64(0), "server should have no notes") - assert.Equal(t, serverBookCount, int64(0), "server should have no books") - - // Check client still has the deleted items locally - var clientNoteCount, clientBookCount int - cliDatabase.MustScan(t, "counting client notes", env.DB.QueryRow("SELECT count(*) FROM notes WHERE deleted = 1"), &clientNoteCount) - cliDatabase.MustScan(t, "counting client books", env.DB.QueryRow("SELECT count(*) FROM books WHERE deleted = 1"), &clientBookCount) - assert.Equal(t, clientNoteCount, 2, "client should still have 2 deleted notes") - assert.Equal(t, clientBookCount, 2, "client should still have 2 deleted books") - - // Verify lastMaxUSN was reset to 0 - var lastMaxUSN int - cliDatabase.MustScan(t, "getting lastMaxUSN", env.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) - assert.Equal(t, lastMaxUSN, 0, "lastMaxUSN should be reset to 0") - }) - - t.Run("race condition - other client uploads first", func(t *testing.T) { - // This test exercises a race condition that can occur during sync: - // While Client A is waiting for user input, Client B uploads data to the server. - // - // The empty server scenario is the natural place to test this because - // an empty server detection triggers a prompt, at which point the test - // can make client B upload data. We trigger the race condition deterministically. - // - // Test flow: - // - Client A detects empty server and prompts user - // - While waiting for confirmation, Client B uploads the same data via API - // - Client A continues and handles the 409 conflict gracefully by: - // 1. Detecting the 409 error when trying to CREATE books that already exist - // 2. Running stepSync to pull the server's books (js, css) - // 3. mergeBook renames local conflicts (js→js_2, css→css_2) - // 4. Retrying sendChanges to upload the renamed books - // - Result: Both clients' data is preserved (4 books total) - - env := setupTestEnv(t) - - user := setupUserAndLogin(t, env) - - // Step 1: Create local data and sync to establish lastMaxUSN > 0 - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") - - // Verify initial sync succeeded - checkState(t, env.DB, user, env.ServerDB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Step 2: Switch to new empty server to simulate switching to empty server - switchToEmptyServer(t, &env) - - // Create user on new server and login - user = setupUserAndLogin(t, env) - - // Step 3: Trigger sync which will detect empty server and prompt user - // Inside the callback (before confirming), we simulate Client B uploading via API. - // We wait for the empty server prompt to ensure Client B uploads AFTER - // GetSyncState but BEFORE the sync decision, creating the race condition deterministically - raceCallback := func(stdout io.Reader, stdin io.WriteCloser) error { - // First, wait for the prompt to ensure Client A has obtained the sync state from the server. - clitest.MustWaitForPrompt(t, stdout, clitest.PromptEmptyServer) - - // Now Client B uploads the same data via API (after Client A got the sync state from the server - // but before its sync decision) - // This creates the race condition: Client A thinks server is empty, but Client B uploads data - jsBookUUID := apiCreateBook(t, env, user, "js", "client B creating js book") - cssBookUUID := apiCreateBook(t, env, user, "css", "client B creating css book") - apiCreateNote(t, env, user, jsBookUUID, "js1", "client B creating js note") - apiCreateNote(t, env, user, cssBookUUID, "css1", "client B creating css note") - - // Now user confirms - if _, err := io.WriteString(stdin, "y\n"); err != nil { - return errors.Wrap(err, "confirming sync") - } - - return nil - } - - // Step 4: Client A runs sync with race condition - // The 409 conflict is automatically handled: - // - When 409 is detected, isBehind flag is set - // - stepSync pulls Client B's data - // - mergeBook renames Client A's books to js_2, css_2 - // - Renamed books are uploaded - // - Both clients' data is preserved. - clitest.MustWaitDnoteCmd(t, env.CmdOpts, raceCallback, cliBinaryName, "sync") - - // Verify final state - both clients' data preserved - checkState(t, env.DB, user, env.ServerDB, systemState{ - clientNoteCount: 4, // Both clients' notes - clientBookCount: 4, // js, css, js_2, css_2 - clientLastMaxUSN: 8, // 4 from Client B + 4 from Client A's renamed books/notes - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 4, - serverBookCount: 4, - serverUserMaxUSN: 8, - }) - - // Verify server has both clients' books - var svrBookJS, svrBookCSS, svrBookJS2, svrBookCSS2 database.Book - apitest.MustExec(t, env.ServerDB.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") - apitest.MustExec(t, env.ServerDB.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") - apitest.MustExec(t, env.ServerDB.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") - apitest.MustExec(t, env.ServerDB.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") - - assert.Equal(t, svrBookJS.Label, "js", "server should have book 'js' (Client B)") - assert.Equal(t, svrBookCSS.Label, "css", "server should have book 'css' (Client B)") - assert.Equal(t, svrBookJS2.Label, "js_2", "server should have book 'js_2' (Client A renamed)") - assert.Equal(t, svrBookCSS2.Label, "css_2", "server should have book 'css_2' (Client A renamed)") - - // Verify client has all books - var cliBookJS, cliBookCSS, cliBookJS2, cliBookCSS2 cliDatabase.Book - cliDatabase.MustScan(t, "finding client book 'js'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) - cliDatabase.MustScan(t, "finding client book 'css'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) - cliDatabase.MustScan(t, "finding client book 'js_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) - cliDatabase.MustScan(t, "finding client book 'css_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) - - // Verify client UUIDs match server - assert.Equal(t, cliBookJS.UUID, svrBookJS.UUID, "client 'js' UUID should match server") - assert.Equal(t, cliBookCSS.UUID, svrBookCSS.UUID, "client 'css' UUID should match server") - assert.Equal(t, cliBookJS2.UUID, svrBookJS2.UUID, "client 'js_2' UUID should match server") - assert.Equal(t, cliBookCSS2.UUID, svrBookCSS2.UUID, "client 'css_2' UUID should match server") - - // Verify all items have non-zero USN (synced successfully) - assert.NotEqual(t, cliBookJS.USN, 0, "client 'js' should have non-zero USN") - assert.NotEqual(t, cliBookCSS.USN, 0, "client 'css' should have non-zero USN") - assert.NotEqual(t, cliBookJS2.USN, 0, "client 'js_2' should have non-zero USN") - assert.NotEqual(t, cliBookCSS2.USN, 0, "client 'css_2' should have non-zero USN") - }) - - t.Run("sync to server A, then B, then back to A, then back to B", func(t *testing.T) { - // Test switching between two actual servers to verify: - // 1. Empty server detection works when switching to empty server - // 2. No false detection when switching back to non-empty servers - // 3. Both servers maintain independent state across multiple switches - - env := setupTestEnv(t) - - // Create Server A with its own database - serverA, serverDBA, err := setupTestServer(t, serverTime) - if err != nil { - t.Fatal(errors.Wrap(err, "setting up server A")) - } - defer serverA.Close() - - // Create Server B with its own database - serverB, serverDBB, err := setupTestServer(t, serverTime) - if err != nil { - t.Fatal(errors.Wrap(err, "setting up server B")) - } - defer serverB.Close() - - // Step 1: Set up user on Server A and sync - apiEndpointA := fmt.Sprintf("%s/api", serverA.URL) - - userA := apitest.SetupUserData(serverDBA, "alice@example.com", "pass1234") - sessionA := apitest.SetupSession(serverDBA, userA) - cliDatabase.MustExec(t, "inserting session_key", env.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, sessionA.Key) - cliDatabase.MustExec(t, "inserting session_key_expiry", env.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, sessionA.ExpiresAt.Unix()) - - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) - - // Verify sync to Server A succeeded - checkState(t, env.DB, userA, serverDBA, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Step 2: Switch to Server B (empty) and sync - apiEndpointB := fmt.Sprintf("%s/api", serverB.URL) - - // Set up user on Server B - userB := apitest.SetupUserData(serverDBB, "alice@example.com", "pass1234") - sessionB := apitest.SetupSession(serverDBB, userB) - cliDatabase.MustExec(t, "updating session_key for B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) - cliDatabase.MustExec(t, "updating session_key_expiry for B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) - - // Should detect empty server and prompt - clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) - - // Verify Server B now has data - checkState(t, env.DB, userB, serverDBB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Step 3: Switch back to Server A and sync - cliDatabase.MustExec(t, "updating session_key back to A", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.Key, consts.SystemSessionKey) - cliDatabase.MustExec(t, "updating session_key_expiry back to A", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) - - // Should NOT trigger empty server detection (Server A has MaxUSN > 0) - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) - - // Verify Server A still has its data - checkState(t, env.DB, userA, serverDBA, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - - // Step 4: Switch back to Server B and sync again - cliDatabase.MustExec(t, "updating session_key back to B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) - cliDatabase.MustExec(t, "updating session_key_expiry back to B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) - - // Should NOT trigger empty server detection (Server B now has MaxUSN > 0 from Step 2) - clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) - - // Verify both servers maintain independent state - checkState(t, env.DB, userB, serverDBB, systemState{ - clientNoteCount: 2, - clientBookCount: 2, - clientLastMaxUSN: 4, - clientLastSyncAt: serverTime.Unix(), - serverNoteCount: 2, - serverBookCount: 2, - serverUserMaxUSN: 4, - }) - }) -} - func TestSync_FreshClientConcurrent(t *testing.T) { // Test the core issue: Fresh client (never synced, lastMaxUSN=0) syncing to a server // that already has data uploaded by another client. diff --git a/pkg/e2e/sync/edge_cases_test.go b/pkg/e2e/sync/edge_cases_test.go new file mode 100644 index 00000000..3f37c131 --- /dev/null +++ b/pkg/e2e/sync/edge_cases_test.go @@ -0,0 +1,73 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package sync + +import ( + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/consts" + cliDatabase "github.com/dnote/dnote/pkg/cli/database" + clitest "github.com/dnote/dnote/pkg/cli/testutils" + "github.com/google/uuid" +) + +// TestSync_EmptyFragmentPreservesLastMaxUSN verifies that last_max_usn is not reset to 0 +// when sync receives an empty response from the server. +// +// Scenario: Client has orphaned note (references non-existent book). During sync: +// 1. Downloads data successfully (last_max_usn=3) +// 2. Upload fails (orphaned note -> 500 error, triggers retry stepSync) +// 3. Retry stepSync gets 0 fragments (already at latest USN) +// 4. last_max_usn should stay at 3, not reset to 0 +func TestSync_EmptyFragmentPreservesLastMaxUSN(t *testing.T) { + env := setupTestEnv(t) + user := setupUserAndLogin(t, env) + + // Create data on server (max_usn=3) + bookUUID := apiCreateBook(t, env, user, "javascript", "creating book via API") + apiCreateNote(t, env, user, bookUUID, "note1 content", "creating note1 via API") + apiCreateNote(t, env, user, bookUUID, "note2 content", "creating note2 via API") + + // Create orphaned note locally (will fail to upload) + orphanedNote := cliDatabase.Note{ + UUID: uuid.New().String(), + BookUUID: uuid.New().String(), // non-existent book + Body: "orphaned note content", + AddedOn: 1234567890, + EditedOn: 0, + USN: 0, + Deleted: false, + Dirty: true, + } + if err := orphanedNote.Insert(env.DB); err != nil { + t.Fatal(err) + } + + // Run sync (downloads data, upload fails, retry gets 0 fragments) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + + // Verify last_max_usn is preserved at 3, not reset to 0 + var lastMaxUSN int + cliDatabase.MustScan(t, "finding system last_max_usn", + env.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), + &lastMaxUSN) + + assert.Equal(t, lastMaxUSN, 3, "last_max_usn should be 3 after syncing") +} diff --git a/pkg/e2e/sync/empty_server_test.go b/pkg/e2e/sync/empty_server_test.go new file mode 100644 index 00000000..a35086f9 --- /dev/null +++ b/pkg/e2e/sync/empty_server_test.go @@ -0,0 +1,449 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package sync + +import ( + "fmt" + "io" + "strings" + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/consts" + cliDatabase "github.com/dnote/dnote/pkg/cli/database" + clitest "github.com/dnote/dnote/pkg/cli/testutils" + "github.com/dnote/dnote/pkg/server/database" + apitest "github.com/dnote/dnote/pkg/server/testutils" + "github.com/pkg/errors" +) + +func TestSync_EmptyServer(t *testing.T) { + t.Run("sync to empty server after syncing to non-empty server", func(t *testing.T) { + // Test server data loss/wipe scenario (disaster recovery): + // Verify empty server detection works when the server loses all its data + + env := setupTestEnv(t) + + user := setupUserAndLogin(t, env) + + // Step 1: Create local data and sync to server + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + + // Verify sync succeeded + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Switch to a completely new empty server + switchToEmptyServer(t, &env) + + // Recreate user and session on new server + user = setupUserAndLogin(t, env) + + // Step 3: Sync again - should detect empty server and prompt user + // User confirms with "y" + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync") + + // Step 4: Verify data was uploaded to the empty server + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Verify the content is correct on both client and server + var cliNote1JS, cliNote1CSS cliDatabase.Note + var cliBookJS, cliBookCSS cliDatabase.Book + cliDatabase.MustScan(t, "finding cliNote1JS", env.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "js1"), &cliNote1JS.UUID, &cliNote1JS.Body) + cliDatabase.MustScan(t, "finding cliNote1CSS", env.DB.QueryRow("SELECT uuid, body FROM notes WHERE body = ?", "css1"), &cliNote1CSS.UUID, &cliNote1CSS.Body) + cliDatabase.MustScan(t, "finding cliBookJS", env.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label) + cliDatabase.MustScan(t, "finding cliBookCSS", env.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label) + + assert.Equal(t, cliNote1JS.Body, "js1", "js note body mismatch") + assert.Equal(t, cliNote1CSS.Body, "css1", "css note body mismatch") + assert.Equal(t, cliBookJS.Label, "js", "js book label mismatch") + assert.Equal(t, cliBookCSS.Label, "css", "css book label mismatch") + + // Verify on server side + var serverNoteJS, serverNoteCSS database.Note + var serverBookJS, serverBookCSS database.Book + apitest.MustExec(t, env.ServerDB.Where("body = ?", "js1").First(&serverNoteJS), "finding server note js1") + apitest.MustExec(t, env.ServerDB.Where("body = ?", "css1").First(&serverNoteCSS), "finding server note css1") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js").First(&serverBookJS), "finding server book js") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css").First(&serverBookCSS), "finding server book css") + + assert.Equal(t, serverNoteJS.Body, "js1", "server js note body mismatch") + assert.Equal(t, serverNoteCSS.Body, "css1", "server css note body mismatch") + assert.Equal(t, serverBookJS.Label, "js", "server js book label mismatch") + assert.Equal(t, serverBookCSS.Label, "css", "server css book label mismatch") + }) + + t.Run("user cancels empty server prompt", func(t *testing.T) { + env := setupTestEnv(t) + + user := setupUserAndLogin(t, env) + + // Step 1: Create local data and sync to server + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + + // Verify initial sync succeeded + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Switch to empty server + switchToEmptyServer(t, &env) + user = setupUserAndLogin(t, env) + + // Step 3: Sync again but user cancels with "n" + output, err := clitest.WaitDnoteCmd(t, env.CmdOpts, clitest.UserCancelEmptyServerSync, cliBinaryName, "sync") + if err == nil { + t.Fatal("Expected sync to fail when user cancels, but it succeeded") + } + + // Verify the prompt appeared + if !strings.Contains(output, clitest.PromptEmptyServer) { + t.Fatalf("Expected empty server warning in output, got: %s", output) + } + + // Step 4: Verify local state unchanged (transaction rolled back) + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 0, + serverBookCount: 0, + serverUserMaxUSN: 0, + }) + + // Verify items still have original USN and dirty=false + var book cliDatabase.Book + var note cliDatabase.Note + cliDatabase.MustScan(t, "checking book state", env.DB.QueryRow("SELECT usn, dirty FROM books WHERE label = ?", "js"), &book.USN, &book.Dirty) + cliDatabase.MustScan(t, "checking note state", env.DB.QueryRow("SELECT usn, dirty FROM notes WHERE body = ?", "js1"), ¬e.USN, ¬e.Dirty) + + assert.NotEqual(t, book.USN, 0, "book USN should not be reset") + assert.NotEqual(t, note.USN, 0, "note USN should not be reset") + assert.Equal(t, book.Dirty, false, "book should not be marked dirty") + assert.Equal(t, note.Dirty, false, "note should not be marked dirty") + }) + + t.Run("all local data is marked deleted - should not upload", func(t *testing.T) { + // Test edge case: Server MaxUSN=0, local MaxUSN>0, but all items are deleted=true + // Should NOT prompt because there's nothing to upload + + env := setupTestEnv(t) + + user := setupUserAndLogin(t, env) + + // Step 1: Create local data and sync to server + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + + // Verify initial sync succeeded + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Delete all local notes and books (mark as deleted) + cliDatabase.MustExec(t, "marking all books deleted", env.DB, "UPDATE books SET deleted = 1") + cliDatabase.MustExec(t, "marking all notes deleted", env.DB, "UPDATE notes SET deleted = 1") + + // Step 3: Switch to empty server + switchToEmptyServer(t, &env) + user = setupUserAndLogin(t, env) + + // Step 4: Sync - should NOT prompt because bookCount=0 and noteCount=0 (counting only deleted=0) + // This should complete without user interaction + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + + // Verify no data was uploaded (server still empty, but client still has deleted items) + // Check server is empty + var serverNoteCount, serverBookCount int64 + apitest.MustExec(t, env.ServerDB.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") + apitest.MustExec(t, env.ServerDB.Model(&database.Book{}).Count(&serverBookCount), "counting server books") + assert.Equal(t, serverNoteCount, int64(0), "server should have no notes") + assert.Equal(t, serverBookCount, int64(0), "server should have no books") + + // Check client still has the deleted items locally + var clientNoteCount, clientBookCount int + cliDatabase.MustScan(t, "counting client notes", env.DB.QueryRow("SELECT count(*) FROM notes WHERE deleted = 1"), &clientNoteCount) + cliDatabase.MustScan(t, "counting client books", env.DB.QueryRow("SELECT count(*) FROM books WHERE deleted = 1"), &clientBookCount) + assert.Equal(t, clientNoteCount, 2, "client should still have 2 deleted notes") + assert.Equal(t, clientBookCount, 2, "client should still have 2 deleted books") + + // Verify lastMaxUSN was reset to 0 + var lastMaxUSN int + cliDatabase.MustScan(t, "getting lastMaxUSN", env.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &lastMaxUSN) + assert.Equal(t, lastMaxUSN, 0, "lastMaxUSN should be reset to 0") + }) + + t.Run("race condition - other client uploads first", func(t *testing.T) { + // This test exercises a race condition that can occur during sync: + // While Client A is waiting for user input, Client B uploads data to the server. + // + // The empty server scenario is the natural place to test this because + // an empty server detection triggers a prompt, at which point the test + // can make client B upload data. We trigger the race condition deterministically. + // + // Test flow: + // - Client A detects empty server and prompts user + // - While waiting for confirmation, Client B uploads the same data via API + // - Client A continues and handles the 409 conflict gracefully by: + // 1. Detecting the 409 error when trying to CREATE books that already exist + // 2. Running stepSync to pull the server's books (js, css) + // 3. mergeBook renames local conflicts (js→js_2, css→css_2) + // 4. Retrying sendChanges to upload the renamed books + // - Result: Both clients' data is preserved (4 books total) + + env := setupTestEnv(t) + + user := setupUserAndLogin(t, env) + + // Step 1: Create local data and sync to establish lastMaxUSN > 0 + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + + // Verify initial sync succeeded + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Switch to new empty server to simulate switching to empty server + switchToEmptyServer(t, &env) + + // Create user on new server and login + user = setupUserAndLogin(t, env) + + // Step 3: Trigger sync which will detect empty server and prompt user + // Inside the callback (before confirming), we simulate Client B uploading via API. + // We wait for the empty server prompt to ensure Client B uploads AFTER + // GetSyncState but BEFORE the sync decision, creating the race condition deterministically + raceCallback := func(stdout io.Reader, stdin io.WriteCloser) error { + // First, wait for the prompt to ensure Client A has obtained the sync state from the server. + clitest.MustWaitForPrompt(t, stdout, clitest.PromptEmptyServer) + + // Now Client B uploads the same data via API (after Client A got the sync state from the server + // but before its sync decision) + // This creates the race condition: Client A thinks server is empty, but Client B uploads data + jsBookUUID := apiCreateBook(t, env, user, "js", "client B creating js book") + cssBookUUID := apiCreateBook(t, env, user, "css", "client B creating css book") + apiCreateNote(t, env, user, jsBookUUID, "js1", "client B creating js note") + apiCreateNote(t, env, user, cssBookUUID, "css1", "client B creating css note") + + // Now user confirms + if _, err := io.WriteString(stdin, "y\n"); err != nil { + return errors.Wrap(err, "confirming sync") + } + + return nil + } + + // Step 4: Client A runs sync with race condition + // The 409 conflict is automatically handled: + // - When 409 is detected, isBehind flag is set + // - stepSync pulls Client B's data + // - mergeBook renames Client A's books to js_2, css_2 + // - Renamed books are uploaded + // - Both clients' data is preserved. + clitest.MustWaitDnoteCmd(t, env.CmdOpts, raceCallback, cliBinaryName, "sync") + + // Verify final state - both clients' data preserved + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 4, // Both clients' notes + clientBookCount: 4, // js, css, js_2, css_2 + clientLastMaxUSN: 8, // 4 from Client B + 4 from Client A's renamed books/notes + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 4, + serverUserMaxUSN: 8, + }) + + // Verify server has both clients' books + var svrBookJS, svrBookCSS, svrBookJS2, svrBookCSS2 database.Book + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js").First(&svrBookJS), "finding server book 'js'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css").First(&svrBookCSS), "finding server book 'css'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "js_2").First(&svrBookJS2), "finding server book 'js_2'") + apitest.MustExec(t, env.ServerDB.Where("label = ?", "css_2").First(&svrBookCSS2), "finding server book 'css_2'") + + assert.Equal(t, svrBookJS.Label, "js", "server should have book 'js' (Client B)") + assert.Equal(t, svrBookCSS.Label, "css", "server should have book 'css' (Client B)") + assert.Equal(t, svrBookJS2.Label, "js_2", "server should have book 'js_2' (Client A renamed)") + assert.Equal(t, svrBookCSS2.Label, "css_2", "server should have book 'css_2' (Client A renamed)") + + // Verify client has all books + var cliBookJS, cliBookCSS, cliBookJS2, cliBookCSS2 cliDatabase.Book + cliDatabase.MustScan(t, "finding client book 'js'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js"), &cliBookJS.UUID, &cliBookJS.Label, &cliBookJS.USN) + cliDatabase.MustScan(t, "finding client book 'css'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css"), &cliBookCSS.UUID, &cliBookCSS.Label, &cliBookCSS.USN) + cliDatabase.MustScan(t, "finding client book 'js_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "js_2"), &cliBookJS2.UUID, &cliBookJS2.Label, &cliBookJS2.USN) + cliDatabase.MustScan(t, "finding client book 'css_2'", env.DB.QueryRow("SELECT uuid, label, usn FROM books WHERE label = ?", "css_2"), &cliBookCSS2.UUID, &cliBookCSS2.Label, &cliBookCSS2.USN) + + // Verify client UUIDs match server + assert.Equal(t, cliBookJS.UUID, svrBookJS.UUID, "client 'js' UUID should match server") + assert.Equal(t, cliBookCSS.UUID, svrBookCSS.UUID, "client 'css' UUID should match server") + assert.Equal(t, cliBookJS2.UUID, svrBookJS2.UUID, "client 'js_2' UUID should match server") + assert.Equal(t, cliBookCSS2.UUID, svrBookCSS2.UUID, "client 'css_2' UUID should match server") + + // Verify all items have non-zero USN (synced successfully) + assert.NotEqual(t, cliBookJS.USN, 0, "client 'js' should have non-zero USN") + assert.NotEqual(t, cliBookCSS.USN, 0, "client 'css' should have non-zero USN") + assert.NotEqual(t, cliBookJS2.USN, 0, "client 'js_2' should have non-zero USN") + assert.NotEqual(t, cliBookCSS2.USN, 0, "client 'css_2' should have non-zero USN") + }) + + t.Run("sync to server A, then B, then back to A, then back to B", func(t *testing.T) { + // Test switching between two actual servers to verify: + // 1. Empty server detection works when switching to empty server + // 2. No false detection when switching back to non-empty servers + // 3. Both servers maintain independent state across multiple switches + + env := setupTestEnv(t) + + // Create Server A with its own database + serverA, serverDBA, err := setupTestServer(t, serverTime) + if err != nil { + t.Fatal(errors.Wrap(err, "setting up server A")) + } + defer serverA.Close() + + // Create Server B with its own database + serverB, serverDBB, err := setupTestServer(t, serverTime) + if err != nil { + t.Fatal(errors.Wrap(err, "setting up server B")) + } + defer serverB.Close() + + // Step 1: Set up user on Server A and sync + apiEndpointA := fmt.Sprintf("%s/api", serverA.URL) + + userA := apitest.SetupUserData(serverDBA, "alice@example.com", "pass1234") + sessionA := apitest.SetupSession(serverDBA, userA) + cliDatabase.MustExec(t, "inserting session_key", env.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, sessionA.Key) + cliDatabase.MustExec(t, "inserting session_key_expiry", env.DB, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, sessionA.ExpiresAt.Unix()) + + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) + + // Verify sync to Server A succeeded + checkState(t, env.DB, userA, serverDBA, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 2: Switch to Server B (empty) and sync + apiEndpointB := fmt.Sprintf("%s/api", serverB.URL) + + // Set up user on Server B + userB := apitest.SetupUserData(serverDBB, "alice@example.com", "pass1234") + sessionB := apitest.SetupSession(serverDBB, userB) + cliDatabase.MustExec(t, "updating session_key for B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry for B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + + // Should detect empty server and prompt + clitest.MustWaitDnoteCmd(t, env.CmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) + + // Verify Server B now has data + checkState(t, env.DB, userB, serverDBB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 3: Switch back to Server A and sync + cliDatabase.MustExec(t, "updating session_key back to A", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry back to A", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionA.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + + // Should NOT trigger empty server detection (Server A has MaxUSN > 0) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointA) + + // Verify Server A still has its data + checkState(t, env.DB, userA, serverDBA, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + + // Step 4: Switch back to Server B and sync again + cliDatabase.MustExec(t, "updating session_key back to B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.Key, consts.SystemSessionKey) + cliDatabase.MustExec(t, "updating session_key_expiry back to B", env.DB, "UPDATE system SET value = ? WHERE key = ?", sessionB.ExpiresAt.Unix(), consts.SystemSessionKeyExpiry) + + // Should NOT trigger empty server detection (Server B now has MaxUSN > 0 from Step 2) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "--apiEndpoint", apiEndpointB) + + // Verify both servers maintain independent state + checkState(t, env.DB, userB, serverDBB, systemState{ + clientNoteCount: 2, + clientBookCount: 2, + clientLastMaxUSN: 4, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + }) + }) +} diff --git a/pkg/e2e/sync/main_test.go b/pkg/e2e/sync/main_test.go new file mode 100644 index 00000000..b5d517f5 --- /dev/null +++ b/pkg/e2e/sync/main_test.go @@ -0,0 +1,59 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package sync + +import ( + "bytes" + "fmt" + "log" + "os" + "os/exec" + "testing" + "time" + + "github.com/pkg/errors" +) + +var cliBinaryName string +var serverTime = time.Date(2017, time.March, 14, 21, 15, 0, 0, time.UTC) + +var testDir = "./tmp/" + +func init() { + cliBinaryName = fmt.Sprintf("%s/test-cli", testDir) +} + +func TestMain(m *testing.M) { + // Build CLI binary without hardcoded API endpoint + // Each test will create its own server and config file + cmd := exec.Command("go", "build", "--tags", "fts5", "-o", cliBinaryName, "github.com/dnote/dnote/pkg/cli") + + var stderr bytes.Buffer + cmd.Stderr = &stderr + + if err := cmd.Run(); err != nil { + log.Print(errors.Wrap(err, "building a CLI binary").Error()) + log.Print(stderr.String()) + os.Exit(1) + } + + os.Exit(m.Run()) +} diff --git a/pkg/e2e/sync/testutils.go b/pkg/e2e/sync/testutils.go new file mode 100644 index 00000000..def7bc47 --- /dev/null +++ b/pkg/e2e/sync/testutils.go @@ -0,0 +1,300 @@ +/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors + * + * This file is part of Dnote. + * + * Dnote is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Dnote 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Dnote. If not, see . + */ + +package sync + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/consts" + cliDatabase "github.com/dnote/dnote/pkg/cli/database" + clitest "github.com/dnote/dnote/pkg/cli/testutils" + "github.com/dnote/dnote/pkg/clock" + "github.com/dnote/dnote/pkg/server/app" + "github.com/dnote/dnote/pkg/server/controllers" + "github.com/dnote/dnote/pkg/server/database" + "github.com/dnote/dnote/pkg/server/mailer" + apitest "github.com/dnote/dnote/pkg/server/testutils" + "github.com/pkg/errors" + "gorm.io/gorm" +) + +// testEnv holds the test environment for a single test +type testEnv struct { + DB *cliDatabase.DB + CmdOpts clitest.RunDnoteCmdOptions + Server *httptest.Server + ServerDB *gorm.DB + TmpDir string +} + +// setupTestEnv creates an isolated test environment with its own database and temp directory +func setupTestEnv(t *testing.T) testEnv { + tmpDir := t.TempDir() + + // Create .dnote directory + dnoteDir := filepath.Join(tmpDir, consts.DnoteDirName) + if err := os.MkdirAll(dnoteDir, 0755); err != nil { + t.Fatal(errors.Wrap(err, "creating dnote directory")) + } + + // Create database at the expected path + dbPath := filepath.Join(dnoteDir, consts.DnoteDBFileName) + db := cliDatabase.InitTestFileDBRaw(t, dbPath) + + // Create server + server, serverDB := setupNewServer(t) + + // Create config file with this server's endpoint + apiEndpoint := fmt.Sprintf("%s/api", server.URL) + updateConfigAPIEndpoint(t, tmpDir, apiEndpoint) + + // Create command options with XDG paths pointing to temp dir + cmdOpts := clitest.RunDnoteCmdOptions{ + Env: []string{ + fmt.Sprintf("XDG_CONFIG_HOME=%s", tmpDir), + fmt.Sprintf("XDG_DATA_HOME=%s", tmpDir), + fmt.Sprintf("XDG_CACHE_HOME=%s", tmpDir), + }, + } + + return testEnv{ + DB: db, + CmdOpts: cmdOpts, + Server: server, + ServerDB: serverDB, + TmpDir: tmpDir, + } +} + +// setupTestServer creates a test server with its own database +func setupTestServer(t *testing.T, serverTime time.Time) (*httptest.Server, *gorm.DB, error) { + db := apitest.InitMemoryDB(t) + + mockClock := clock.NewMock() + mockClock.SetNow(serverTime) + + a := app.NewTest() + a.Clock = mockClock + a.EmailTemplates = mailer.Templates{} + a.EmailBackend = &apitest.MockEmailbackendImplementation{} + a.DB = db + + server, err := controllers.NewServer(&a) + if err != nil { + return nil, nil, errors.Wrap(err, "initializing server") + } + + return server, db, nil +} + +// setupNewServer creates a new server and returns the server and database. +// This is useful when a test needs to switch to a new empty server. +func setupNewServer(t *testing.T) (*httptest.Server, *gorm.DB) { + server, serverDB, err := setupTestServer(t, serverTime) + if err != nil { + t.Fatal(errors.Wrap(err, "setting up new test server")) + } + t.Cleanup(func() { server.Close() }) + + return server, serverDB +} + +// updateConfigAPIEndpoint updates the config file with the given API endpoint +func updateConfigAPIEndpoint(t *testing.T, tmpDir string, apiEndpoint string) { + dnoteDir := filepath.Join(tmpDir, consts.DnoteDirName) + configPath := filepath.Join(dnoteDir, consts.ConfigFilename) + configContent := fmt.Sprintf("apiEndpoint: %s\n", apiEndpoint) + if err := os.WriteFile(configPath, []byte(configContent), 0644); err != nil { + t.Fatal(errors.Wrap(err, "writing config file")) + } +} + +// switchToEmptyServer closes the current server and creates a new empty server, +// updating the config file to point to it. +func switchToEmptyServer(t *testing.T, env *testEnv) { + // Close old server + env.Server.Close() + + // Create new empty server + env.Server, env.ServerDB = setupNewServer(t) + + // Update config file to point to new server + apiEndpoint := fmt.Sprintf("%s/api", env.Server.URL) + updateConfigAPIEndpoint(t, env.TmpDir, apiEndpoint) +} + +// setupUser creates a test user in the server database +func setupUser(t *testing.T, env testEnv) database.User { + user := apitest.SetupUserData(env.ServerDB, "alice@example.com", "pass1234") + + return user +} + +// setupUserAndLogin creates a test user and logs them in on the CLI +func setupUserAndLogin(t *testing.T, env testEnv) database.User { + user := setupUser(t, env) + login(t, env.DB, env.ServerDB, user) + + return user +} + +// login logs in the user in CLI +func login(t *testing.T, db *cliDatabase.DB, serverDB *gorm.DB, user database.User) { + session := apitest.SetupSession(serverDB, user) + + cliDatabase.MustExec(t, "inserting session_key", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKey, session.Key) + cliDatabase.MustExec(t, "inserting session_key_expiry", db, "INSERT INTO system (key, value) VALUES (?, ?)", consts.SystemSessionKeyExpiry, session.ExpiresAt.Unix()) +} + +// apiCreateBook creates a book via the API and returns its UUID +func apiCreateBook(t *testing.T, env testEnv, user database.User, name, message string) string { + res := doHTTPReq(t, env, "POST", "/v3/books", fmt.Sprintf(`{"name": "%s"}`, name), message, user) + + var resp controllers.CreateBookResp + if err := json.NewDecoder(res.Body).Decode(&resp); err != nil { + t.Fatal(errors.Wrap(err, "decoding payload for adding book")) + return "" + } + + return resp.Book.UUID +} + +// apiPatchBook updates a book via the API +func apiPatchBook(t *testing.T, env testEnv, user database.User, uuid, payload, message string) { + doHTTPReq(t, env, "PATCH", fmt.Sprintf("/v3/books/%s", uuid), payload, message, user) +} + +// apiDeleteBook deletes a book via the API +func apiDeleteBook(t *testing.T, env testEnv, user database.User, uuid, message string) { + doHTTPReq(t, env, "DELETE", fmt.Sprintf("/v3/books/%s", uuid), "", message, user) +} + +// apiCreateNote creates a note via the API and returns its UUID +func apiCreateNote(t *testing.T, env testEnv, user database.User, bookUUID, body, message string) string { + res := doHTTPReq(t, env, "POST", "/v3/notes", fmt.Sprintf(`{"book_uuid": "%s", "content": "%s"}`, bookUUID, body), message, user) + + var resp controllers.CreateNoteResp + if err := json.NewDecoder(res.Body).Decode(&resp); err != nil { + t.Fatal(errors.Wrap(err, "decoding payload for adding note")) + return "" + } + + return resp.Result.UUID +} + +// apiPatchNote updates a note via the API +func apiPatchNote(t *testing.T, env testEnv, user database.User, noteUUID, payload, message string) { + doHTTPReq(t, env, "PATCH", fmt.Sprintf("/v3/notes/%s", noteUUID), payload, message, user) +} + +// apiDeleteNote deletes a note via the API +func apiDeleteNote(t *testing.T, env testEnv, user database.User, noteUUID, message string) { + doHTTPReq(t, env, "DELETE", fmt.Sprintf("/v3/notes/%s", noteUUID), "", message, user) +} + +// doHTTPReq performs an authenticated HTTP request and checks for errors +func doHTTPReq(t *testing.T, env testEnv, method, path, payload, message string, user database.User) *http.Response { + apiEndpoint := fmt.Sprintf("%s/api", env.Server.URL) + endpoint := fmt.Sprintf("%s%s", apiEndpoint, path) + + req, err := http.NewRequest(method, endpoint, strings.NewReader(payload)) + if err != nil { + panic(errors.Wrap(err, "constructing http request")) + } + + res := apitest.HTTPAuthDo(t, env.ServerDB, req, user) + if res.StatusCode >= 400 { + bs, err := io.ReadAll(res.Body) + if err != nil { + panic(errors.Wrap(err, "parsing response body for error")) + } + + t.Errorf("%s. HTTP status %d. Message: %s", message, res.StatusCode, string(bs)) + } + + return res +} + +// setupFunc is a function that sets up test data and returns IDs for assertions +type setupFunc func(t *testing.T, env testEnv, user database.User) map[string]string + +// assertFunc is a function that asserts the expected state after sync +type assertFunc func(t *testing.T, env testEnv, user database.User, ids map[string]string) + +// testSyncCmd is a test helper that sets up a test environment, runs setup, syncs, and asserts +func testSyncCmd(t *testing.T, fullSync bool, setup setupFunc, assert assertFunc) { + env := setupTestEnv(t) + + user := setupUserAndLogin(t, env) + ids := setup(t, env, user) + + if fullSync { + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync", "-f") + } else { + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + } + + assert(t, env, user, ids) +} + +// systemState represents the expected state of the sync system +type systemState struct { + clientNoteCount int + clientBookCount int + clientLastMaxUSN int + clientLastSyncAt int64 + serverNoteCount int64 + serverBookCount int64 + serverUserMaxUSN int +} + +// checkState compares the state of the client and the server with the given system state +func checkState(t *testing.T, clientDB *cliDatabase.DB, user database.User, serverDB *gorm.DB, expected systemState) { + var clientBookCount, clientNoteCount int + cliDatabase.MustScan(t, "counting client notes", clientDB.QueryRow("SELECT count(*) FROM notes"), &clientNoteCount) + cliDatabase.MustScan(t, "counting client books", clientDB.QueryRow("SELECT count(*) FROM books"), &clientBookCount) + assert.Equal(t, clientNoteCount, expected.clientNoteCount, "client note count mismatch") + assert.Equal(t, clientBookCount, expected.clientBookCount, "client book count mismatch") + + var clientLastMaxUSN int + var clientLastSyncAt int64 + cliDatabase.MustScan(t, "finding system last_max_usn", clientDB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), &clientLastMaxUSN) + cliDatabase.MustScan(t, "finding system last_sync_at", clientDB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastSyncAt), &clientLastSyncAt) + assert.Equal(t, clientLastMaxUSN, expected.clientLastMaxUSN, "client last_max_usn mismatch") + assert.Equal(t, clientLastSyncAt, expected.clientLastSyncAt, "client last_sync_at mismatch") + + var serverBookCount, serverNoteCount int64 + apitest.MustExec(t, serverDB.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes") + apitest.MustExec(t, serverDB.Model(&database.Book{}).Count(&serverBookCount), "counting api notes") + assert.Equal(t, serverNoteCount, expected.serverNoteCount, "server note count mismatch") + assert.Equal(t, serverBookCount, expected.serverBookCount, "server book count mismatch") + var serverUser database.User + apitest.MustExec(t, serverDB.Where("id = ?", user.ID).First(&serverUser), "finding user") + assert.Equal(t, serverUser.MaxUSN, expected.serverUserMaxUSN, "user max_usn mismatch") +} diff --git a/pkg/server/controllers/notes.go b/pkg/server/controllers/notes.go index dd34a78d..4db709da 100644 --- a/pkg/server/controllers/notes.go +++ b/pkg/server/controllers/notes.go @@ -218,7 +218,7 @@ func (n *Notes) create(r *http.Request) (database.Note, error) { var book database.Book if err := n.app.DB.Where("uuid = ? AND user_id = ?", params.BookUUID, user.ID).First(&book).Error; err != nil { - return database.Note{}, errors.Wrap(err, "finding book") + return database.Note{}, errors.Wrapf(err, "finding book %s", params.BookUUID) } client := getClientType(r) From ae290a226fd7cc38acb41ea2d92268b6e94156f3 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 26 Oct 2025 16:59:53 -0700 Subject: [PATCH 23/33] Auto vacuum and manage connections (#705) * Test concurrent sync * Auto vacuum and manage connection --- pkg/cli/database/testutils.go | 3 +- pkg/e2e/sync/edge_cases_test.go | 93 +++++++++++++++++++++++++++++++++ pkg/server/app/books.go | 1 + pkg/server/app/notes.go | 1 + pkg/server/app/users.go | 2 + pkg/server/cmd/start.go | 8 +++ pkg/server/controllers/books.go | 5 ++ pkg/server/database/database.go | 63 ++++++++++++++++++++++ 8 files changed, 175 insertions(+), 1 deletion(-) diff --git a/pkg/cli/database/testutils.go b/pkg/cli/database/testutils.go index 16685686..59824034 100644 --- a/pkg/cli/database/testutils.go +++ b/pkg/cli/database/testutils.go @@ -63,7 +63,8 @@ func InitTestMemoryDB(t *testing.T) *DB { // InitTestFileDB initializes a file-based test database with the default schema. func InitTestFileDB(t *testing.T) (*DB, string) { - dbPath := filepath.Join(t.TempDir(), "dnote.db") + uuid := mustGenerateTestUUID(t) + dbPath := filepath.Join(t.TempDir(), fmt.Sprintf("dnote-%s.db", uuid)) db := InitTestFileDBRaw(t, dbPath) return db, dbPath } diff --git a/pkg/e2e/sync/edge_cases_test.go b/pkg/e2e/sync/edge_cases_test.go index 3f37c131..ef1e0923 100644 --- a/pkg/e2e/sync/edge_cases_test.go +++ b/pkg/e2e/sync/edge_cases_test.go @@ -19,6 +19,7 @@ package sync import ( + "io" "testing" "github.com/dnote/dnote/pkg/assert" @@ -26,6 +27,7 @@ import ( cliDatabase "github.com/dnote/dnote/pkg/cli/database" clitest "github.com/dnote/dnote/pkg/cli/testutils" "github.com/google/uuid" + "github.com/pkg/errors" ) // TestSync_EmptyFragmentPreservesLastMaxUSN verifies that last_max_usn is not reset to 0 @@ -71,3 +73,94 @@ func TestSync_EmptyFragmentPreservesLastMaxUSN(t *testing.T) { assert.Equal(t, lastMaxUSN, 3, "last_max_usn should be 3 after syncing") } + +// TestSync_ConcurrentInitialSync reproduces the issue where two clients with identical +// local data syncing simultaneously to an empty server results in 500 errors. +// +// This demonstrates the race condition: +// - Client1 starts sync to empty server, gets empty server state +// - Client2 syncs. +// - Client1 tries to create same books → 409 "duplicate" +// - Client1 tries to create notes with wrong UUIDs → 500 "record not found" +// - stepSync recovers by renaming local books with _2 suffix +func TestSync_ConcurrentInitialSync(t *testing.T) { + env := setupTestEnv(t) + + user := setupUserAndLogin(t, env) + + // Step 1: Create local data and sync + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "add", "javascript", "-c", "js note from client1") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "sync") + checkState(t, env.DB, user, env.ServerDB, systemState{ + clientNoteCount: 1, + clientBookCount: 1, + clientLastMaxUSN: 2, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 1, + serverBookCount: 1, + serverUserMaxUSN: 2, + }) + + // Step 2: Switch to new empty server to simulate concurrent initial sync scenario + switchToEmptyServer(t, &env) + user = setupUserAndLogin(t, env) + + // Set up client2 with separate database + client2DB, client2DBPath := cliDatabase.InitTestFileDB(t) + login(t, client2DB, env.ServerDB, user) + client2DB.Close() // Close so CLI can access the database + + // Step 3: Client1 syncs to empty server, but during sync Client2 uploads same data + // This simulates the race condition deterministically + raceCallback := func(stdout io.Reader, stdin io.WriteCloser) error { + // Wait for empty server prompt to ensure Client1 has called GetSyncState + clitest.MustWaitForPrompt(t, stdout, clitest.PromptEmptyServer) + + // Now Client2 creates the same book and note via CLI (creating the race condition) + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client2DBPath, "add", "javascript", "-c", "js note from client2") + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client2DBPath, "sync") + + // User confirms sync + if _, err := io.WriteString(stdin, "y\n"); err != nil { + return errors.Wrap(err, "confirming sync") + } + + return nil + } + + // Client1 continues sync - will hit 409 conflict, then 500 error, then recover + clitest.MustWaitDnoteCmd(t, env.CmdOpts, raceCallback, cliBinaryName, "sync") + + // After sync: + // - Server has 2 books: "javascript" (from client2) and "javascript_2" (from client1 renamed) + // - Server has 2 notes + // - Both clients should converge to the same state + expectedState := systemState{ + clientNoteCount: 2, // both notes + clientBookCount: 2, // javascript and javascript_2 + clientLastMaxUSN: 4, // 2 books + 2 notes + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 2, + serverBookCount: 2, + serverUserMaxUSN: 4, + } + checkState(t, env.DB, user, env.ServerDB, expectedState) + + // Client2 syncs again to download client1's data + clitest.RunDnoteCmd(t, env.CmdOpts, cliBinaryName, "--dbPath", client2DBPath, "sync") + client2DB = clitest.MustOpenDatabase(t, client2DBPath) + defer client2DB.Close() + + // Client2 should have converged to the same state as client1 + checkState(t, client2DB, user, env.ServerDB, expectedState) + + // Verify no orphaned notes on server + var orphanedCount int + if err := env.ServerDB.Raw(` + SELECT COUNT(*) FROM notes + WHERE book_uuid NOT IN (SELECT uuid FROM books) + `).Scan(&orphanedCount).Error; err != nil { + t.Fatal(err) + } + assert.Equal(t, orphanedCount, 0, "server should have no orphaned notes after sync") +} diff --git a/pkg/server/app/books.go b/pkg/server/app/books.go index a476a0c4..ae7b355f 100644 --- a/pkg/server/app/books.go +++ b/pkg/server/app/books.go @@ -37,6 +37,7 @@ func (a *App) CreateBook(user database.User, name string) (database.Book, error) uuid, err := helpers.GenUUID() if err != nil { + tx.Rollback() return database.Book{}, err } diff --git a/pkg/server/app/notes.go b/pkg/server/app/notes.go index e9f6f60b..7f25123a 100644 --- a/pkg/server/app/notes.go +++ b/pkg/server/app/notes.go @@ -55,6 +55,7 @@ func (a *App) CreateNote(user database.User, bookUUID, content string, addedOn * uuid, err := helpers.GenUUID() if err != nil { + tx.Rollback() return database.Note{}, err } diff --git a/pkg/server/app/users.go b/pkg/server/app/users.go index 6e9535e7..eb53c5a4 100644 --- a/pkg/server/app/users.go +++ b/pkg/server/app/users.go @@ -66,9 +66,11 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d var count int64 if err := tx.Model(&database.User{}).Where("email = ?", email).Count(&count).Error; err != nil { + tx.Rollback() return database.User{}, pkgErrors.Wrap(err, "counting user") } if count > 0 { + tx.Rollback() return database.User{}, ErrDuplicateEmail } diff --git a/pkg/server/cmd/start.go b/pkg/server/cmd/start.go index cbbc60ed..dee5913c 100644 --- a/pkg/server/cmd/start.go +++ b/pkg/server/cmd/start.go @@ -22,10 +22,12 @@ import ( "fmt" "net/http" "os" + "time" "github.com/dnote/dnote/pkg/server/buildinfo" "github.com/dnote/dnote/pkg/server/config" "github.com/dnote/dnote/pkg/server/controllers" + "github.com/dnote/dnote/pkg/server/database" "github.com/dnote/dnote/pkg/server/log" "github.com/pkg/errors" ) @@ -67,6 +69,12 @@ func startCmd(args []string) { } }() + // Start WAL checkpointing to prevent WAL file from growing unbounded. + database.StartWALCheckpointing(app.DB, 5*time.Minute) + + // Start periodic VACUUM to reclaim space and defragment database. + database.StartPeriodicVacuum(app.DB, 24*time.Hour) + ctl := controllers.New(&app) rc := controllers.RouteConfig{ WebRoutes: controllers.NewWebRoutes(&app, ctl), diff --git a/pkg/server/controllers/books.go b/pkg/server/controllers/books.go index 1b4f3810..c721b594 100644 --- a/pkg/server/controllers/books.go +++ b/pkg/server/controllers/books.go @@ -203,11 +203,13 @@ func (b *Books) update(r *http.Request) (database.Book, error) { var book database.Book if err := tx.Where("user_id = ? AND uuid = ?", user.ID, uuid).First(&book).Error; err != nil { + tx.Rollback() return database.Book{}, pkgErrors.Wrap(err, "finding book") } var params updateBookPayload if err := parseRequestData(r, ¶ms); err != nil { + tx.Rollback() return database.Book{}, pkgErrors.Wrap(err, "decoding payload") } @@ -253,11 +255,13 @@ func (b *Books) del(r *http.Request) (database.Book, error) { var book database.Book if err := tx.Where("user_id = ? AND uuid = ?", user.ID, uuid).First(&book).Error; err != nil { + tx.Rollback() return database.Book{}, pkgErrors.Wrap(err, "finding a book") } var notes []database.Note if err := tx.Where("book_uuid = ? AND NOT deleted", uuid).Order("usn ASC").Find(¬es).Error; err != nil { + tx.Rollback() return database.Book{}, pkgErrors.Wrap(err, "finding notes for the book") } @@ -270,6 +274,7 @@ func (b *Books) del(r *http.Request) (database.Book, error) { book, err := b.app.DeleteBook(tx, *user, book) if err != nil { + tx.Rollback() return database.Book{}, pkgErrors.Wrap(err, "deleting the book") } diff --git a/pkg/server/database/database.go b/pkg/server/database/database.go index f73d45af..2c5241b4 100644 --- a/pkg/server/database/database.go +++ b/pkg/server/database/database.go @@ -21,6 +21,7 @@ package database import ( "os" "path/filepath" + "time" "github.com/pkg/errors" "gorm.io/driver/sqlite" @@ -58,5 +59,67 @@ func Open(dbPath string) *gorm.DB { panic(errors.Wrap(err, "opening database conection")) } + // Get underlying *sql.DB to configure connection pool + sqlDB, err := db.DB() + if err != nil { + panic(errors.Wrap(err, "getting underlying database connection")) + } + + // Configure connection pool for SQLite with WAL mode + sqlDB.SetMaxOpenConns(25) + sqlDB.SetMaxIdleConns(5) + sqlDB.SetConnMaxLifetime(0) // Doesn't expire. + + // Apply performance PRAGMAs + pragmas := []string{ + "PRAGMA journal_mode=WAL", // Enable WAL mode for better concurrency + "PRAGMA synchronous=NORMAL", // Balance between safety and speed + "PRAGMA cache_size=-64000", // 64MB cache (negative = KB) + "PRAGMA busy_timeout=5000", // Wait up to 5s for locks + "PRAGMA foreign_keys=ON", // Enforce foreign key constraints + "PRAGMA temp_store=MEMORY", // Store temp tables in memory + } + + for _, pragma := range pragmas { + if err := db.Exec(pragma).Error; err != nil { + panic(errors.Wrapf(err, "executing pragma: %s", pragma)) + } + } + return db } + +// StartWALCheckpointing starts a background goroutine that periodically +// checkpoints the WAL file to prevent it from growing unbounded +func StartWALCheckpointing(db *gorm.DB, interval time.Duration) { + go func() { + ticker := time.NewTicker(interval) + defer ticker.Stop() + + for range ticker.C { + // TRUNCATE mode removes the WAL file after checkpointing + if err := db.Exec("PRAGMA wal_checkpoint(TRUNCATE)").Error; err != nil { + // Log error but don't panic - this is a background maintenance task + // TODO: Use proper logging once available + _ = err + } + } + }() +} + +// StartPeriodicVacuum runs full VACUUM on a schedule to reclaim space and defragment. +// WARNING: VACUUM acquires an exclusive lock and blocks all database operations briefly. +func StartPeriodicVacuum(db *gorm.DB, interval time.Duration) { + go func() { + ticker := time.NewTicker(interval) + defer ticker.Stop() + + for range ticker.C { + if err := db.Exec("VACUUM").Error; err != nil { + // Log error but don't panic - this is a background maintenance task + // TODO: Use proper logging once available + _ = err + } + } + }() +} From 63147492638daf492c8814c6264845736775817c Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:54:24 -0700 Subject: [PATCH 24/33] Improve empty server sync when multiple clients exist (#706) * Fix dbPath * Require full sync when after another client uploads to an empty server * Avoid orphan notes with empty sync --- pkg/cli/client/client.go | 3 + pkg/cli/cmd/sync/sync.go | 22 +++ pkg/cli/main.go | 24 ++- pkg/e2e/sync/empty_server_test.go | 282 ++++++++++++++++++++++++++++++ pkg/server/app/helpers.go | 20 ++- pkg/server/controllers/sync.go | 2 +- pkg/server/database/models.go | 11 +- 7 files changed, 354 insertions(+), 10 deletions(-) diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index 3fea9d21..083b9392 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -285,6 +285,9 @@ func GetSyncFragment(ctx context.DnoteCtx, afterUSN int) (GetSyncFragmentResp, e path := fmt.Sprintf("/v3/sync/fragment?%s", queryStr) res, err := doAuthorizedReq(ctx, "GET", path, "", nil) + if err != nil { + return GetSyncFragmentResp{}, errors.Wrap(err, "making the request") + } body, err := io.ReadAll(res.Body) if err != nil { diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index fcfc31fd..f8f2aec0 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -1173,6 +1173,28 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc { log.Debug("prepared empty server sync: marked %d books and %d notes as dirty\n", bookCount, noteCount) } + // If full sync will be triggered by FullSyncBefore (not manual --full flag), + // and client has more data than server, prepare local data for upload to avoid orphaning notes. + // The lastMaxUSN > syncState.MaxUSN check prevents duplicate uploads when switching + // back to a server that already has our data. + if !isFullSync && lastSyncAt < syncState.FullSyncBefore && lastMaxUSN > syncState.MaxUSN { + log.Debug("full sync triggered by FullSyncBefore: preparing local data for upload\n") + log.Debug("server.FullSyncBefore=%d, local.lastSyncAt=%d, local.MaxUSN=%d, server.MaxUSN=%d, books=%d, notes=%d\n", + syncState.FullSyncBefore, lastSyncAt, lastMaxUSN, syncState.MaxUSN, bookCount, noteCount) + + if err := prepareEmptyServerSync(tx); err != nil { + return errors.Wrap(err, "preparing local data for full sync") + } + + // Re-fetch lastMaxUSN after prepareEmptyServerSync + lastMaxUSN, err = getLastMaxUSN(tx) + if err != nil { + return errors.Wrap(err, "getting the last max_usn after prepare") + } + + log.Debug("prepared for full sync: marked %d books and %d notes as dirty\n", bookCount, noteCount) + } + var syncErr error if isFullSync || lastSyncAt < syncState.FullSyncBefore { syncErr = fullSync(ctx, tx) diff --git a/pkg/cli/main.go b/pkg/cli/main.go index 1ba97358..dfdac5a7 100644 --- a/pkg/cli/main.go +++ b/pkg/cli/main.go @@ -20,6 +20,7 @@ package main import ( "os" + "strings" "github.com/dnote/dnote/pkg/cli/infra" "github.com/dnote/dnote/pkg/cli/log" @@ -45,10 +46,29 @@ import ( var apiEndpoint string var versionTag = "master" +// parseDBPath extracts --dbPath flag value from command line arguments +// regardless of where it appears (before or after subcommand). +// Returns empty string if not found. +func parseDBPath(args []string) string { + for i, arg := range args { + // Handle --dbPath=value + if strings.HasPrefix(arg, "--dbPath=") { + return strings.TrimPrefix(arg, "--dbPath=") + } + // Handle --dbPath value + if arg == "--dbPath" && i+1 < len(args) { + return args[i+1] + } + } + return "" +} + func main() { // Parse flags early to get --dbPath before initializing database - root.GetRoot().ParseFlags(os.Args[1:]) - dbPath := root.GetDBPathFlag() + // We need to manually parse --dbPath because it can appear after the subcommand + // (e.g., "dnote sync --full --dbPath=./custom.db") and root.ParseFlags only + // parses flags before the subcommand. + dbPath := parseDBPath(os.Args[1:]) // Initialize context - defaultAPIEndpoint is used when creating new config file ctx, err := infra.Init(versionTag, apiEndpoint, dbPath) diff --git a/pkg/e2e/sync/empty_server_test.go b/pkg/e2e/sync/empty_server_test.go index a35086f9..ad7308e9 100644 --- a/pkg/e2e/sync/empty_server_test.go +++ b/pkg/e2e/sync/empty_server_test.go @@ -19,8 +19,11 @@ package sync import ( + "database/sql" "fmt" "io" + "os" + "strconv" "strings" "testing" @@ -446,4 +449,283 @@ func TestSync_EmptyServer(t *testing.T) { serverUserMaxUSN: 4, }) }) + + t.Run("two clients with identical copied database sync to empty server", func(t *testing.T) { + // Suppose we have two clients and server becomes empty (migration). + // After the first client sync to empty server, the second client should trigger full sync. + // Without the full sync, client2 will do step sync asking for changes after its stale USN, + // get nothing from server, and potentially orphan notes during full sync. + + // Step 1: Create client1 with data and sync to ORIGINAL server + env1 := setupTestEnv(t) + user := setupUserAndLogin(t, env1) + + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "add", "js", "-c", "js1") + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "add", "css", "-c", "css1") + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "sync") + // Add more data to create a higher USN + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "add", "go", "-c", "go1") + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "add", "rust", "-c", "rust1") + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "sync") + // Verify initial sync succeeded (now with 4 notes, 4 books, USN=8) + checkState(t, env1.DB, user, env1.ServerDB, systemState{ + clientNoteCount: 4, + clientBookCount: 4, + clientLastMaxUSN: 8, + clientLastSyncAt: serverTime.Unix(), + serverNoteCount: 4, + serverBookCount: 4, + serverUserMaxUSN: 8, + }) + + // Step 2: Create client2 by copying client1's database (simulating same DB on two devices) + env2 := setupTestEnv(t) + // Copy the database file from client1 to client2 + dbPath1 := env1.DB.Filepath + dbPath2 := env2.DB.Filepath + // Close both DBs before copying + env1.DB.Close() + env2.DB.Close() + + // Copy the database file + input, err := os.ReadFile(dbPath1) + if err != nil { + t.Fatal(errors.Wrap(err, "reading client1 database")) + } + if err := os.WriteFile(dbPath2, input, 0644); err != nil { + t.Fatal(errors.Wrap(err, "writing client2 database")) + } + + // Reopen databases + env1.DB, err = cliDatabase.Open(dbPath1) + if err != nil { + t.Fatal(errors.Wrap(err, "reopening client1 database")) + } + env2.DB, err = cliDatabase.Open(dbPath2) + if err != nil { + t.Fatal(errors.Wrap(err, "reopening client2 database")) + } + + // Verify client2 has identical data and USN=8 (stale) - same as client1 + // Note: at this point there's no server to compare against, we just check counts + var client2MaxUSN, client2NoteCount, client2BookCount int + cliDatabase.MustScan(t, "getting client2 maxUSN", + env2.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), + &client2MaxUSN) + cliDatabase.MustScan(t, "counting client2 notes", + env2.DB.QueryRow("SELECT count(*) FROM notes WHERE deleted = 0"), + &client2NoteCount) + cliDatabase.MustScan(t, "counting client2 books", + env2.DB.QueryRow("SELECT count(*) FROM books WHERE deleted = 0"), + &client2BookCount) + + assert.Equal(t, client2MaxUSN, 8, "client2 should have same maxUSN=8 as client1") + assert.Equal(t, client2NoteCount, 4, "client2 should have 4 notes") + assert.Equal(t, client2BookCount, 4, "client2 should have 4 books") + + // Step 3: Switch client1 to new empty server + switchToEmptyServer(t, &env1) + + // Point client2 to the same new server + env2.Server = env1.Server + env2.ServerDB = env1.ServerDB + + // Update client2's API endpoint config to point to env1's server + apiEndpoint := fmt.Sprintf("%s/api", env1.Server.URL) + updateConfigAPIEndpoint(t, env2.TmpDir, apiEndpoint) + + // Create same user on new server + user = setupUserAndLogin(t, env1) + + // Setup session for client2 (same user, same server) + login(t, env2.DB, env2.ServerDB, user) + + // Step 4: Client1 syncs ONLY FIRST 2 BOOKS to empty server (simulates partial upload) + // This creates the stale USN scenario: client2 has maxUSN=8, but server will only have maxUSN=4 + clitest.MustWaitDnoteCmd(t, env1.CmdOpts, clitest.UserConfirmEmptyServerSync, + cliBinaryName, "sync") + + // Delete the last 2 books from client1 to prevent them being on server + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "remove", "go", "-y") + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "remove", "rust", "-y") + + // Sync deletions to server + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "sync") + + // Verify server has 2 active books/notes (go/rust deleted) + var serverNoteCount, serverBookCount int64 + apitest.MustExec(t, env1.ServerDB.Model(&database.Note{}).Where("deleted = ?", false).Count(&serverNoteCount), "counting active server notes") + apitest.MustExec(t, env1.ServerDB.Model(&database.Book{}).Where("deleted = ?", false).Count(&serverBookCount), "counting active server books") + assert.Equal(t, int(serverNoteCount), 2, "server should have 2 active notes (go/rust deleted)") + assert.Equal(t, int(serverBookCount), 2, "server should have 2 active books (go/rust deleted)") + + // Step 5: Client2 syncs + // CRITICAL: Client2 has lastMaxUSN=8 (from copied DB), but server's max_usn is now ~8 but only has 2 books + // Client2 will ask for changes after USN=8, get nothing, then try to upload its 4 books + // This should trigger the orphaned notes scenario or require full sync + clitest.RunDnoteCmd(t, env2.CmdOpts, cliBinaryName, "sync") + + // Step 6: Verify client2 has all data and NO orphaned notes + var orphanedCount int + cliDatabase.MustScan(t, "checking for orphaned notes", + env2.DB.QueryRow(` + SELECT COUNT(*) FROM notes + WHERE deleted = 0 + AND book_uuid NOT IN (SELECT uuid FROM books WHERE deleted = 0) + `), &orphanedCount) + + assert.Equal(t, orphanedCount, 0, "client2 should have no orphaned notes") + + // Verify client2 converged with server state + // Note: checkState counts ALL records (including deleted ones) + // During full sync, cleanLocalBooks/cleanLocalNotes DELETE local records not on server + // So client2 ends up with only the 2 active books/notes + // Server has 4 total (2 active + 2 deleted) + var client2LastMaxUSN, client2LastSyncAt int + var serverUserMaxUSN int + cliDatabase.MustScan(t, "getting client2 lastMaxUSN", + env2.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastMaxUSN), + &client2LastMaxUSN) + var lastSyncAtStr string + cliDatabase.MustScan(t, "getting client2 lastSyncAt", + env2.DB.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastSyncAt), + &lastSyncAtStr) + lastSyncAtInt, _ := strconv.ParseInt(lastSyncAtStr, 10, 64) + client2LastSyncAt = int(lastSyncAtInt) + + apitest.MustExec(t, env2.ServerDB.Table("users").Select("max_usn").Where("id = ?", user.ID).Scan(&serverUserMaxUSN), "getting server user max_usn") + + checkState(t, env2.DB, user, env2.ServerDB, systemState{ + clientNoteCount: 2, // Only active notes (deleted ones removed by cleanLocalNotes) + clientBookCount: 2, // Only active books (deleted ones removed by cleanLocalBooks) + clientLastMaxUSN: client2LastMaxUSN, + clientLastSyncAt: int64(client2LastSyncAt), + serverNoteCount: 4, // 2 active + 2 deleted + serverBookCount: 4, // 2 active + 2 deleted + serverUserMaxUSN: serverUserMaxUSN, + }) + + // Verify both clients have the expected books (css, js only - go/rust deleted) + var client1BookCSS, client1BookJS, client2BookCSS, client2BookJS cliDatabase.Book + cliDatabase.MustScan(t, "finding client1 book 'css'", + env1.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ? AND deleted = 0", "css"), + &client1BookCSS.UUID, &client1BookCSS.Label) + cliDatabase.MustScan(t, "finding client1 book 'js'", + env1.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ? AND deleted = 0", "js"), + &client1BookJS.UUID, &client1BookJS.Label) + cliDatabase.MustScan(t, "finding client2 book 'css'", + env2.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ? AND deleted = 0", "css"), + &client2BookCSS.UUID, &client2BookCSS.Label) + cliDatabase.MustScan(t, "finding client2 book 'js'", + env2.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ? AND deleted = 0", "js"), + &client2BookJS.UUID, &client2BookJS.Label) + + assert.Equal(t, client1BookCSS.Label, "css", "client1 should have css book") + assert.Equal(t, client1BookJS.Label, "js", "client1 should have js book") + assert.Equal(t, client2BookCSS.Label, "css", "client2 should have css book") + assert.Equal(t, client2BookJS.Label, "js", "client2 should have js book") + + // Verify go and rust books are deleted/absent on both clients + var client2BookGo, client2BookRust cliDatabase.Book + errGo := env2.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ? AND deleted = 0", "go").Scan(&client2BookGo.UUID, &client2BookGo.Label) + assert.Equal(t, errGo, sql.ErrNoRows, "client2 should not have non-deleted 'go' book") + errRust := env2.DB.QueryRow("SELECT uuid, label FROM books WHERE label = ? AND deleted = 0", "rust").Scan(&client2BookRust.UUID, &client2BookRust.Label) + assert.Equal(t, errRust, sql.ErrNoRows, "client2 should not have non-deleted 'rust' book") + }) + + t.Run("client with local data syncs after another client uploads to empty server - should not orphan notes", func(t *testing.T) { + // This test reproduces the scenario where: + // 1. Client1 has local data and syncs to original server + // 2. Client2 has DIFFERENT local data and syncs to SAME original server + // 3. Both clients switch to NEW empty server + // 4. Client1 uploads to the new empty server (sets FullSyncBefore) + // 5. Client2 syncs - should trigger full sync AND upload its local data + // WITHOUT orphaning notes due to cleanLocalBooks deleting them first + + // Step 1: Create client1 with local data on original server + env1 := setupTestEnv(t) + user := setupUserAndLogin(t, env1) + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "add", "client1-book", "-c", "client1-note") + clitest.RunDnoteCmd(t, env1.CmdOpts, cliBinaryName, "sync") + + // Step 2: Create client2 with DIFFERENT local data on SAME original server + env2 := setupTestEnv(t) + // Point env2 to env1's server (the original server) + env2.Server = env1.Server + env2.ServerDB = env1.ServerDB + apiEndpoint := fmt.Sprintf("%s/api", env1.Server.URL) + updateConfigAPIEndpoint(t, env2.TmpDir, apiEndpoint) + + // Login client2 to the same server + login(t, env2.DB, env2.ServerDB, user) + clitest.RunDnoteCmd(t, env2.CmdOpts, cliBinaryName, "add", "client2-book", "-c", "client2-note") + clitest.RunDnoteCmd(t, env2.CmdOpts, cliBinaryName, "sync") + + // Step 3: Both clients switch to NEW empty server + switchToEmptyServer(t, &env1) + env2.Server = env1.Server + env2.ServerDB = env1.ServerDB + apiEndpoint = fmt.Sprintf("%s/api", env1.Server.URL) + updateConfigAPIEndpoint(t, env2.TmpDir, apiEndpoint) + + // Create same user on new server + user = setupUserAndLogin(t, env1) + login(t, env2.DB, env2.ServerDB, user) + + // Step 4: Client1 uploads to empty server + clitest.MustWaitDnoteCmd(t, env1.CmdOpts, clitest.UserConfirmEmptyServerSync, cliBinaryName, "sync") + + // Verify server has client1's data and FullSyncBefore is set + var serverUser database.User + apitest.MustExec(t, env1.ServerDB.Where("id = ?", user.ID).First(&serverUser), "getting server user state") + assert.Equal(t, serverUser.MaxUSN > 0, true, "server should have data after client1 upload") + assert.Equal(t, serverUser.FullSyncBefore > 0, true, "server should have FullSyncBefore set") + + // Step 5: Client2 syncs - should trigger full sync due to FullSyncBefore + // CRITICAL: Client2 has local data (client2-book, client2-note) that should be uploaded + // Without the fix, cleanLocalBooks will delete client2-book before upload, orphaning client2-note + clitest.RunDnoteCmd(t, env2.CmdOpts, cliBinaryName, "sync") + + // Step 6: Verify NO orphaned notes on client2 + var orphanedCount int + cliDatabase.MustScan(t, "checking for orphaned notes on client2", + env2.DB.QueryRow(` + SELECT COUNT(*) FROM notes + WHERE deleted = 0 + AND book_uuid NOT IN (SELECT uuid FROM books WHERE deleted = 0) + `), &orphanedCount) + + assert.Equal(t, orphanedCount, 0, "client2 should have no orphaned notes after sync") + + // Step 7: Verify client2's data was uploaded to server + var client2BookOnServer database.Book + err := env2.ServerDB.Where("label = ? AND deleted = ?", "client2-book", false).First(&client2BookOnServer).Error + assert.Equal(t, err, nil, "client2-book should exist on server") + + var client2NoteOnServer database.Note + err = env2.ServerDB.Where("body = ? AND deleted = ?", "client2-note", false).First(&client2NoteOnServer).Error + assert.Equal(t, err, nil, "client2-note should exist on server") + + // Step 8: Verify server has data from BOTH clients + // Note: Both clients had synced to original server, so they each have 2 books + 2 notes locally. + // When switching to new empty server, client1 uploads 2 books + 2 notes (USN 1-4). + // Client2 then does full sync, downloads client1's uploads, marks its local data as dirty, + // and uploads its version of the same 2 books + 2 notes with potentially different UUIDs. + // The exact count depends on UUID conflict resolution, but we verify both original books exist. + var serverBookCount, serverNoteCount int64 + apitest.MustExec(t, env2.ServerDB.Model(&database.Book{}).Where("deleted = ?", false).Count(&serverBookCount), "counting active server books") + apitest.MustExec(t, env2.ServerDB.Model(&database.Note{}).Where("deleted = ?", false).Count(&serverNoteCount), "counting active server notes") + + // The main assertion: both original client books should exist + var client1BookExists, client2BookExists bool + err = env2.ServerDB.Model(&database.Book{}).Where("label = ? AND deleted = ?", "client1-book", false).First(&database.Book{}).Error + client1BookExists = (err == nil) + err = env2.ServerDB.Model(&database.Book{}).Where("label = ? AND deleted = ?", "client2-book", false).First(&database.Book{}).Error + client2BookExists = (err == nil) + + assert.Equal(t, client1BookExists, true, "server should have client1-book") + assert.Equal(t, client2BookExists, true, "server should have client2-book") + assert.Equal(t, serverBookCount >= 2, true, "server should have at least 2 books") + assert.Equal(t, serverNoteCount >= 2, true, "server should have at least 2 notes") + }) } diff --git a/pkg/server/app/helpers.go b/pkg/server/app/helpers.go index 3941b2cb..361db6cb 100644 --- a/pkg/server/app/helpers.go +++ b/pkg/server/app/helpers.go @@ -19,19 +19,35 @@ package app import ( + "time" + "github.com/dnote/dnote/pkg/server/database" - "gorm.io/gorm" "github.com/pkg/errors" + "gorm.io/gorm" ) // incrementUserUSN increment the given user's max_usn by 1 // and returns the new, incremented max_usn func incrementUserUSN(tx *gorm.DB, userID int) (int, error) { + // First, get the current max_usn to detect transition from empty server + var user database.User + if err := tx.Select("max_usn, full_sync_before").Where("id = ?", userID).First(&user).Error; err != nil { + return 0, errors.Wrap(err, "getting current user state") + } + + // If transitioning from empty server (MaxUSN=0) to non-empty (MaxUSN=1), + // set full_sync_before to current timestamp to force all other clients to full sync + if user.MaxUSN == 0 && user.FullSyncBefore == 0 { + currentTime := time.Now().Unix() + if err := tx.Table("users").Where("id = ?", userID).Update("full_sync_before", currentTime).Error; err != nil { + return 0, errors.Wrap(err, "setting full_sync_before on empty server transition") + } + } + if err := tx.Table("users").Where("id = ?", userID).Update("max_usn", gorm.Expr("max_usn + 1")).Error; err != nil { return 0, errors.Wrap(err, "incrementing user max_usn") } - var user database.User if err := tx.Select("max_usn").Where("id = ?", userID).First(&user).Error; err != nil { return 0, errors.Wrap(err, "getting the updated user max_usn") } diff --git a/pkg/server/controllers/sync.go b/pkg/server/controllers/sync.go index e93be7cd..3d7d2608 100644 --- a/pkg/server/controllers/sync.go +++ b/pkg/server/controllers/sync.go @@ -301,7 +301,7 @@ func (s *Sync) GetSyncState(w http.ResponseWriter, r *http.Request) { } response := GetSyncStateResp{ - FullSyncBefore: fullSyncBefore, + FullSyncBefore: int(user.FullSyncBefore), MaxUSN: user.MaxUSN, // TODO: exposing server time means we probably shouldn't seed random generator with time? CurrentTime: s.app.Clock.Now().Unix(), diff --git a/pkg/server/database/models.go b/pkg/server/database/models.go index 576dee7f..f21e8636 100644 --- a/pkg/server/database/models.go +++ b/pkg/server/database/models.go @@ -61,11 +61,12 @@ type Note struct { // User is a model for a user type User struct { Model - UUID string `json:"uuid" gorm:"type:text;index"` - Email NullString `gorm:"index"` - Password NullString `json:"-"` - LastLoginAt *time.Time `json:"-"` - MaxUSN int `json:"-" gorm:"default:0"` + UUID string `json:"uuid" gorm:"type:text;index"` + Email NullString `gorm:"index"` + Password NullString `json:"-"` + LastLoginAt *time.Time `json:"-"` + MaxUSN int `json:"-" gorm:"default:0"` + FullSyncBefore int64 `json:"-" gorm:"default:0"` } // Token is a model for a token From e0c4cb1545307978a3d6a8b362196553e05a3558 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:41:21 -0700 Subject: [PATCH 25/33] Use Apache 2.0 license (#708) --- LICENSE | 209 +++++- licenses/AGPLv3.txt | 661 ----------------- licenses/GPLv3.txt | 674 ------------------ pkg/assert/assert.go | 23 +- pkg/assert/prompt.go | 23 +- pkg/cli/client/client.go | 23 +- pkg/cli/client/client_test.go | 23 +- pkg/cli/cmd/add/add.go | 23 +- pkg/cli/cmd/cat/cat.go | 23 +- pkg/cli/cmd/edit/book.go | 23 +- pkg/cli/cmd/edit/edit.go | 23 +- pkg/cli/cmd/edit/note.go | 23 +- pkg/cli/cmd/find/find.go | 23 +- pkg/cli/cmd/find/lexer.go | 23 +- pkg/cli/cmd/find/lexer_test.go | 23 +- pkg/cli/cmd/login/login.go | 23 +- pkg/cli/cmd/login/login_test.go | 23 +- pkg/cli/cmd/logout/logout.go | 23 +- pkg/cli/cmd/ls/ls.go | 23 +- pkg/cli/cmd/remove/remove.go | 23 +- pkg/cli/cmd/root/root.go | 23 +- pkg/cli/cmd/sync/merge.go | 23 +- pkg/cli/cmd/sync/merge_test.go | 23 +- pkg/cli/cmd/sync/sync.go | 23 +- pkg/cli/cmd/sync/sync_test.go | 23 +- pkg/cli/cmd/version/version.go | 23 +- pkg/cli/cmd/view/view.go | 23 +- pkg/cli/config/config.go | 23 +- pkg/cli/consts/consts.go | 23 +- pkg/cli/context/ctx.go | 23 +- pkg/cli/context/files.go | 23 +- pkg/cli/context/files_test.go | 23 +- pkg/cli/context/testutils.go | 23 +- pkg/cli/database/models.go | 23 +- pkg/cli/database/models_test.go | 23 +- pkg/cli/database/queries.go | 23 +- pkg/cli/database/queries_test.go | 23 +- pkg/cli/database/schema/main.go | 23 +- pkg/cli/database/schema/main_test.go | 23 +- pkg/cli/database/sql.go | 23 +- pkg/cli/database/testutils.go | 23 +- pkg/cli/infra/init.go | 23 +- pkg/cli/infra/init_test.go | 23 +- pkg/cli/log/log.go | 23 +- pkg/cli/main.go | 23 +- pkg/cli/main_test.go | 23 +- pkg/cli/migrate/legacy.go | 23 +- pkg/cli/migrate/legacy_test.go | 23 +- pkg/cli/migrate/migrate.go | 23 +- pkg/cli/migrate/migrate_test.go | 23 +- pkg/cli/migrate/migrations.go | 23 +- pkg/cli/output/output.go | 23 +- pkg/cli/testutils/main.go | 23 +- pkg/cli/testutils/setup.go | 23 +- pkg/cli/ui/editor.go | 23 +- pkg/cli/ui/editor_test.go | 23 +- pkg/cli/ui/terminal.go | 23 +- pkg/cli/upgrade/upgrade.go | 23 +- pkg/cli/upgrade/upgrade_test.go | 23 +- pkg/cli/utils/diff/diff.go | 23 +- pkg/cli/utils/diff/diff_test.go | 23 +- pkg/cli/utils/files.go | 23 +- pkg/cli/utils/files_test.go | 23 +- pkg/cli/utils/utils.go | 23 +- pkg/cli/validate/book_test.go | 23 +- pkg/cli/validate/books.go | 23 +- pkg/clock/clock.go | 23 +- pkg/dirs/dirs.go | 23 +- pkg/dirs/dirs_test.go | 23 +- pkg/dirs/dirs_unix.go | 23 +- pkg/dirs/dirs_unix_test.go | 23 +- pkg/dirs/dirs_windows.go | 23 +- pkg/dirs/dirs_windows_test.go | 23 +- pkg/e2e/server_test.go | 23 +- pkg/e2e/sync/basic_test.go | 23 +- pkg/e2e/sync/edge_cases_test.go | 23 +- pkg/e2e/sync/empty_server_test.go | 23 +- pkg/e2e/sync/main_test.go | 25 +- pkg/e2e/sync/testutils.go | 23 +- pkg/prompt/prompt.go | 23 +- pkg/prompt/prompt_test.go | 23 +- pkg/server/app/app.go | 23 +- pkg/server/app/books.go | 23 +- pkg/server/app/books_test.go | 23 +- pkg/server/app/doc.go | 23 +- pkg/server/app/email.go | 23 +- pkg/server/app/email_test.go | 23 +- pkg/server/app/errors.go | 23 +- pkg/server/app/helpers.go | 23 +- pkg/server/app/helpers_test.go | 23 +- pkg/server/app/notes.go | 23 +- pkg/server/app/notes_test.go | 23 +- pkg/server/app/sessions.go | 23 +- pkg/server/app/testutils.go | 23 +- pkg/server/app/users.go | 23 +- pkg/server/app/users_test.go | 23 +- pkg/server/assets/embed.go | 23 +- pkg/server/assets/js/src/main.js | 23 +- pkg/server/assets/package-lock.json | 2 +- pkg/server/assets/package.json | 2 +- pkg/server/assets/styles/src/_books.scss | 31 +- pkg/server/assets/styles/src/_bootstrap.scss | 23 +- pkg/server/assets/styles/src/_buttons.scss | 23 +- pkg/server/assets/styles/src/_font.scss | 23 +- pkg/server/assets/styles/src/_global.scss | 31 +- pkg/server/assets/styles/src/_grid.scss | 23 +- pkg/server/assets/styles/src/_header.scss | 23 +- pkg/server/assets/styles/src/_hljs.scss | 23 +- pkg/server/assets/styles/src/_home.scss | 23 +- pkg/server/assets/styles/src/_login.scss | 23 +- pkg/server/assets/styles/src/_markdown.scss | 23 +- pkg/server/assets/styles/src/_marker.scss | 23 +- pkg/server/assets/styles/src/_note.scss | 31 +- pkg/server/assets/styles/src/_reboot.scss | 23 +- pkg/server/assets/styles/src/_rem.scss | 31 +- pkg/server/assets/styles/src/_responsive.scss | 23 +- pkg/server/assets/styles/src/_select.scss | 23 +- pkg/server/assets/styles/src/_settings.scss | 23 +- pkg/server/assets/styles/src/_shared.scss | 23 +- pkg/server/assets/styles/src/_theme.scss | 25 +- pkg/server/assets/styles/src/_variables.scss | 23 +- pkg/server/assets/styles/src/main.scss | 23 +- pkg/server/buildinfo/info.go | 23 +- pkg/server/cmd/helpers.go | 23 +- pkg/server/cmd/root.go | 23 +- pkg/server/cmd/start.go | 23 +- pkg/server/cmd/user.go | 23 +- pkg/server/cmd/user_test.go | 23 +- pkg/server/cmd/version.go | 23 +- pkg/server/config/config.go | 23 +- pkg/server/config/config_test.go | 23 +- pkg/server/consts/consts.go | 23 +- pkg/server/context/user.go | 23 +- pkg/server/controllers/books.go | 23 +- pkg/server/controllers/books_test.go | 23 +- pkg/server/controllers/controllers.go | 23 +- pkg/server/controllers/health.go | 23 +- pkg/server/controllers/health_test.go | 23 +- pkg/server/controllers/helpers.go | 23 +- pkg/server/controllers/main_test.go | 23 +- pkg/server/controllers/notes.go | 23 +- pkg/server/controllers/notes_test.go | 23 +- pkg/server/controllers/routes.go | 23 +- pkg/server/controllers/routes_test.go | 23 +- pkg/server/controllers/static.go | 23 +- pkg/server/controllers/sync.go | 23 +- pkg/server/controllers/sync_test.go | 23 +- pkg/server/controllers/testutils.go | 23 +- pkg/server/controllers/users.go | 23 +- pkg/server/controllers/users_test.go | 23 +- pkg/server/crypt/crypt.go | 23 +- pkg/server/database/consts.go | 23 +- pkg/server/database/database.go | 23 +- pkg/server/database/errors.go | 23 +- pkg/server/database/migrate.go | 23 +- pkg/server/database/migrate_test.go | 23 +- pkg/server/database/migrations/embed.go | 23 +- pkg/server/database/models.go | 23 +- pkg/server/database/notes.go | 23 +- pkg/server/database/types.go | 23 +- pkg/server/helpers/const.go | 23 +- pkg/server/helpers/url.go | 23 +- pkg/server/helpers/url_test.go | 23 +- pkg/server/helpers/uuid.go | 23 +- pkg/server/log/log.go | 23 +- pkg/server/log/log_test.go | 23 +- pkg/server/mailer/backend.go | 23 +- pkg/server/mailer/backend_test.go | 23 +- pkg/server/mailer/mailer.go | 23 +- pkg/server/mailer/mailer_test.go | 23 +- pkg/server/mailer/templates/templates.go | 23 +- pkg/server/mailer/tokens.go | 23 +- pkg/server/mailer/tokens_test.go | 23 +- pkg/server/mailer/types.go | 23 +- pkg/server/main.go | 23 +- pkg/server/middleware/auth.go | 23 +- pkg/server/middleware/auth_test.go | 23 +- pkg/server/middleware/helpers.go | 23 +- pkg/server/middleware/helpers_test.go | 23 +- pkg/server/middleware/limit.go | 23 +- pkg/server/middleware/limit_test.go | 23 +- pkg/server/middleware/logging.go | 23 +- pkg/server/middleware/middleware.go | 23 +- pkg/server/operations/doc.go | 23 +- pkg/server/operations/notes.go | 23 +- pkg/server/operations/notes_test.go | 23 +- pkg/server/permissions/permissions.go | 23 +- pkg/server/permissions/permissions_test.go | 23 +- pkg/server/presenters/book.go | 23 +- pkg/server/presenters/book_test.go | 23 +- pkg/server/presenters/helpers.go | 23 +- pkg/server/presenters/helpers_test.go | 23 +- pkg/server/presenters/note.go | 23 +- pkg/server/presenters/note_test.go | 23 +- pkg/server/session/session.go | 23 +- pkg/server/session/session_test.go | 23 +- pkg/server/testutils/main.go | 23 +- pkg/server/token/token.go | 23 +- pkg/server/token/token_test.go | 23 +- pkg/server/views/data.go | 23 +- pkg/server/views/embed.go | 23 +- pkg/server/views/engine.go | 23 +- pkg/server/views/helpers.go | 23 +- pkg/server/views/helpers_test.go | 23 +- pkg/server/views/time.go | 23 +- pkg/server/views/view.go | 23 +- pkg/watcher/main.go | 23 +- scripts/cli/build.sh | 2 +- scripts/license.sh | 65 +- scripts/server/build.sh | 2 +- 210 files changed, 2261 insertions(+), 4038 deletions(-) delete mode 100644 licenses/AGPLv3.txt delete mode 100644 licenses/GPLv3.txt diff --git a/LICENSE b/LICENSE index fb388417..6b0b1270 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,203 @@ -Source code in this repository is variously licensed under the GNU Affero General Public -License v3.0 (GNU AGPLv3), and GNU General Public License v3.0 (GNU GPLv3). A copy of each -license can be found in the licenses directory. The Source code for the cli is licensed under -GNU GPLv3. The source code for the server and the web is licensed under GNU AGPLv3. Unless -otherwise noted, source code in a given file is licensed under the GNU AGPLv3. -Unless otherwise noted at the beginning of the file, the copyright belongs to -Dnote contributors + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/licenses/AGPLv3.txt b/licenses/AGPLv3.txt deleted file mode 100644 index 0ad25db4..00000000 --- a/licenses/AGPLv3.txt +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. diff --git a/licenses/GPLv3.txt b/licenses/GPLv3.txt deleted file mode 100644 index f288702d..00000000 --- a/licenses/GPLv3.txt +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/pkg/assert/assert.go b/pkg/assert/assert.go index 000d7b48..bb98fce0 100644 --- a/pkg/assert/assert.go +++ b/pkg/assert/assert.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package assert provides functions to assert a condition in tests diff --git a/pkg/assert/prompt.go b/pkg/assert/prompt.go index d4ec5d25..c21e6a42 100644 --- a/pkg/assert/prompt.go +++ b/pkg/assert/prompt.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package assert diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index 083b9392..2be0006d 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package client provides interfaces for interacting with the Dnote server diff --git a/pkg/cli/client/client_test.go b/pkg/cli/client/client_test.go index 3bb99e93..f83a0e6f 100644 --- a/pkg/cli/client/client_test.go +++ b/pkg/cli/client/client_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package client diff --git a/pkg/cli/cmd/add/add.go b/pkg/cli/cmd/add/add.go index 2d6591a2..be89b829 100644 --- a/pkg/cli/cmd/add/add.go +++ b/pkg/cli/cmd/add/add.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package add diff --git a/pkg/cli/cmd/cat/cat.go b/pkg/cli/cmd/cat/cat.go index 4961ce33..c32eb687 100644 --- a/pkg/cli/cmd/cat/cat.go +++ b/pkg/cli/cmd/cat/cat.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package cat diff --git a/pkg/cli/cmd/edit/book.go b/pkg/cli/cmd/edit/book.go index 5b85f98b..ab326e7f 100644 --- a/pkg/cli/cmd/edit/book.go +++ b/pkg/cli/cmd/edit/book.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package edit diff --git a/pkg/cli/cmd/edit/edit.go b/pkg/cli/cmd/edit/edit.go index 12a80dce..16a7c413 100644 --- a/pkg/cli/cmd/edit/edit.go +++ b/pkg/cli/cmd/edit/edit.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package edit diff --git a/pkg/cli/cmd/edit/note.go b/pkg/cli/cmd/edit/note.go index f6019778..84a631f4 100644 --- a/pkg/cli/cmd/edit/note.go +++ b/pkg/cli/cmd/edit/note.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package edit diff --git a/pkg/cli/cmd/find/find.go b/pkg/cli/cmd/find/find.go index e3007c9b..4723bcb4 100644 --- a/pkg/cli/cmd/find/find.go +++ b/pkg/cli/cmd/find/find.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package find diff --git a/pkg/cli/cmd/find/lexer.go b/pkg/cli/cmd/find/lexer.go index b5bc8ce8..6115becc 100644 --- a/pkg/cli/cmd/find/lexer.go +++ b/pkg/cli/cmd/find/lexer.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package find diff --git a/pkg/cli/cmd/find/lexer_test.go b/pkg/cli/cmd/find/lexer_test.go index 288d71fc..3a74ad5a 100644 --- a/pkg/cli/cmd/find/lexer_test.go +++ b/pkg/cli/cmd/find/lexer_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package find diff --git a/pkg/cli/cmd/login/login.go b/pkg/cli/cmd/login/login.go index 4d8ee392..c9b1dfd5 100644 --- a/pkg/cli/cmd/login/login.go +++ b/pkg/cli/cmd/login/login.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package login diff --git a/pkg/cli/cmd/login/login_test.go b/pkg/cli/cmd/login/login_test.go index c208fa5d..6d5917cc 100644 --- a/pkg/cli/cmd/login/login_test.go +++ b/pkg/cli/cmd/login/login_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package login diff --git a/pkg/cli/cmd/logout/logout.go b/pkg/cli/cmd/logout/logout.go index 008c9652..98cd69eb 100644 --- a/pkg/cli/cmd/logout/logout.go +++ b/pkg/cli/cmd/logout/logout.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package logout diff --git a/pkg/cli/cmd/ls/ls.go b/pkg/cli/cmd/ls/ls.go index dbf4deb4..f0ddd047 100644 --- a/pkg/cli/cmd/ls/ls.go +++ b/pkg/cli/cmd/ls/ls.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package ls diff --git a/pkg/cli/cmd/remove/remove.go b/pkg/cli/cmd/remove/remove.go index 443e4867..89d44b78 100644 --- a/pkg/cli/cmd/remove/remove.go +++ b/pkg/cli/cmd/remove/remove.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package remove diff --git a/pkg/cli/cmd/root/root.go b/pkg/cli/cmd/root/root.go index 604f7682..6da096bf 100644 --- a/pkg/cli/cmd/root/root.go +++ b/pkg/cli/cmd/root/root.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package root diff --git a/pkg/cli/cmd/sync/merge.go b/pkg/cli/cmd/sync/merge.go index 2b70d095..0e4d15be 100644 --- a/pkg/cli/cmd/sync/merge.go +++ b/pkg/cli/cmd/sync/merge.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/cli/cmd/sync/merge_test.go b/pkg/cli/cmd/sync/merge_test.go index 3134e13c..e6f4839e 100644 --- a/pkg/cli/cmd/sync/merge_test.go +++ b/pkg/cli/cmd/sync/merge_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/cli/cmd/sync/sync.go b/pkg/cli/cmd/sync/sync.go index f8f2aec0..6cb506ae 100644 --- a/pkg/cli/cmd/sync/sync.go +++ b/pkg/cli/cmd/sync/sync.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/cli/cmd/sync/sync_test.go b/pkg/cli/cmd/sync/sync_test.go index 6c22e926..ae3b94ff 100644 --- a/pkg/cli/cmd/sync/sync_test.go +++ b/pkg/cli/cmd/sync/sync_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/cli/cmd/version/version.go b/pkg/cli/cmd/version/version.go index f508ee6e..79892204 100644 --- a/pkg/cli/cmd/version/version.go +++ b/pkg/cli/cmd/version/version.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package version diff --git a/pkg/cli/cmd/view/view.go b/pkg/cli/cmd/view/view.go index dde41fa5..62f50a53 100644 --- a/pkg/cli/cmd/view/view.go +++ b/pkg/cli/cmd/view/view.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package view diff --git a/pkg/cli/config/config.go b/pkg/cli/config/config.go index b0faa9cf..065100c0 100644 --- a/pkg/cli/config/config.go +++ b/pkg/cli/config/config.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package config diff --git a/pkg/cli/consts/consts.go b/pkg/cli/consts/consts.go index dec8d456..0f49c152 100644 --- a/pkg/cli/consts/consts.go +++ b/pkg/cli/consts/consts.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package consts provides definitions of constants diff --git a/pkg/cli/context/ctx.go b/pkg/cli/context/ctx.go index 61cd5be8..971d9145 100644 --- a/pkg/cli/context/ctx.go +++ b/pkg/cli/context/ctx.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package context defines dnote context diff --git a/pkg/cli/context/files.go b/pkg/cli/context/files.go index 098b2cd5..1abbcd47 100644 --- a/pkg/cli/context/files.go +++ b/pkg/cli/context/files.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package context diff --git a/pkg/cli/context/files_test.go b/pkg/cli/context/files_test.go index 2422a795..49d62dc9 100644 --- a/pkg/cli/context/files_test.go +++ b/pkg/cli/context/files_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package context diff --git a/pkg/cli/context/testutils.go b/pkg/cli/context/testutils.go index 62fed833..cb477475 100644 --- a/pkg/cli/context/testutils.go +++ b/pkg/cli/context/testutils.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package context diff --git a/pkg/cli/database/models.go b/pkg/cli/database/models.go index b26a6b5a..e8e463bb 100644 --- a/pkg/cli/database/models.go +++ b/pkg/cli/database/models.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/cli/database/models_test.go b/pkg/cli/database/models_test.go index 53565d7b..6d0a45f0 100644 --- a/pkg/cli/database/models_test.go +++ b/pkg/cli/database/models_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/cli/database/queries.go b/pkg/cli/database/queries.go index e8ec5ce5..2209c8f3 100644 --- a/pkg/cli/database/queries.go +++ b/pkg/cli/database/queries.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/cli/database/queries_test.go b/pkg/cli/database/queries_test.go index cccc697f..e394fe95 100644 --- a/pkg/cli/database/queries_test.go +++ b/pkg/cli/database/queries_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/cli/database/schema/main.go b/pkg/cli/database/schema/main.go index 2596c84a..6c75e4d0 100644 --- a/pkg/cli/database/schema/main.go +++ b/pkg/cli/database/schema/main.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Command schema generates the CLI database schema.sql file. diff --git a/pkg/cli/database/schema/main_test.go b/pkg/cli/database/schema/main_test.go index 24bd9fc0..26898ef3 100644 --- a/pkg/cli/database/schema/main_test.go +++ b/pkg/cli/database/schema/main_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package main diff --git a/pkg/cli/database/sql.go b/pkg/cli/database/sql.go index 19271606..0af3c7fd 100644 --- a/pkg/cli/database/sql.go +++ b/pkg/cli/database/sql.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/cli/database/testutils.go b/pkg/cli/database/testutils.go index 59824034..23633d53 100644 --- a/pkg/cli/database/testutils.go +++ b/pkg/cli/database/testutils.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/cli/infra/init.go b/pkg/cli/infra/init.go index b87cfdd4..a6cbd1aa 100644 --- a/pkg/cli/infra/init.go +++ b/pkg/cli/infra/init.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package infra provides operations and definitions for the diff --git a/pkg/cli/infra/init_test.go b/pkg/cli/infra/init_test.go index 6ac0d5cf..8c698624 100644 --- a/pkg/cli/infra/init_test.go +++ b/pkg/cli/infra/init_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package infra diff --git a/pkg/cli/log/log.go b/pkg/cli/log/log.go index dc78e2b4..0bc569b6 100644 --- a/pkg/cli/log/log.go +++ b/pkg/cli/log/log.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package log diff --git a/pkg/cli/main.go b/pkg/cli/main.go index dfdac5a7..2afbaf36 100644 --- a/pkg/cli/main.go +++ b/pkg/cli/main.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package main diff --git a/pkg/cli/main_test.go b/pkg/cli/main_test.go index 0d9ad71a..5da1915e 100644 --- a/pkg/cli/main_test.go +++ b/pkg/cli/main_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package main diff --git a/pkg/cli/migrate/legacy.go b/pkg/cli/migrate/legacy.go index dc5441c7..4399f7fb 100644 --- a/pkg/cli/migrate/legacy.go +++ b/pkg/cli/migrate/legacy.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package migrate provides migration logic for both sqlite and diff --git a/pkg/cli/migrate/legacy_test.go b/pkg/cli/migrate/legacy_test.go index 4d1a1dc6..73d8b063 100644 --- a/pkg/cli/migrate/legacy_test.go +++ b/pkg/cli/migrate/legacy_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package migrate diff --git a/pkg/cli/migrate/migrate.go b/pkg/cli/migrate/migrate.go index d579ffb7..9b4b0f50 100644 --- a/pkg/cli/migrate/migrate.go +++ b/pkg/cli/migrate/migrate.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package migrate diff --git a/pkg/cli/migrate/migrate_test.go b/pkg/cli/migrate/migrate_test.go index 591f1800..7b31a91e 100644 --- a/pkg/cli/migrate/migrate_test.go +++ b/pkg/cli/migrate/migrate_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package migrate diff --git a/pkg/cli/migrate/migrations.go b/pkg/cli/migrate/migrations.go index 09b86afc..197a2b03 100644 --- a/pkg/cli/migrate/migrations.go +++ b/pkg/cli/migrate/migrations.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package migrate diff --git a/pkg/cli/output/output.go b/pkg/cli/output/output.go index ef35b4fb..fe6e3c87 100644 --- a/pkg/cli/output/output.go +++ b/pkg/cli/output/output.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package output provides functions to print informations on the terminal diff --git a/pkg/cli/testutils/main.go b/pkg/cli/testutils/main.go index cefa6323..581cbd7f 100644 --- a/pkg/cli/testutils/main.go +++ b/pkg/cli/testutils/main.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package testutils provides utilities used in tests diff --git a/pkg/cli/testutils/setup.go b/pkg/cli/testutils/setup.go index 12c8b8ae..d88afd2d 100644 --- a/pkg/cli/testutils/setup.go +++ b/pkg/cli/testutils/setup.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package testutils diff --git a/pkg/cli/ui/editor.go b/pkg/cli/ui/editor.go index 3501e7ae..a6c165f4 100644 --- a/pkg/cli/ui/editor.go +++ b/pkg/cli/ui/editor.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package ui provides the user interface for the program diff --git a/pkg/cli/ui/editor_test.go b/pkg/cli/ui/editor_test.go index 718c5337..54538c49 100644 --- a/pkg/cli/ui/editor_test.go +++ b/pkg/cli/ui/editor_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package ui diff --git a/pkg/cli/ui/terminal.go b/pkg/cli/ui/terminal.go index 899060c7..6a255766 100644 --- a/pkg/cli/ui/terminal.go +++ b/pkg/cli/ui/terminal.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package ui diff --git a/pkg/cli/upgrade/upgrade.go b/pkg/cli/upgrade/upgrade.go index aabfb916..7c24a86d 100644 --- a/pkg/cli/upgrade/upgrade.go +++ b/pkg/cli/upgrade/upgrade.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package upgrade diff --git a/pkg/cli/upgrade/upgrade_test.go b/pkg/cli/upgrade/upgrade_test.go index 6b8e089c..917e6754 100644 --- a/pkg/cli/upgrade/upgrade_test.go +++ b/pkg/cli/upgrade/upgrade_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package upgrade diff --git a/pkg/cli/utils/diff/diff.go b/pkg/cli/utils/diff/diff.go index 68dd5eb1..ff7e3384 100644 --- a/pkg/cli/utils/diff/diff.go +++ b/pkg/cli/utils/diff/diff.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package diff provides line-by-line diff feature by wrapping diff --git a/pkg/cli/utils/diff/diff_test.go b/pkg/cli/utils/diff/diff_test.go index 84794d0c..f777f26c 100644 --- a/pkg/cli/utils/diff/diff_test.go +++ b/pkg/cli/utils/diff/diff_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package diff diff --git a/pkg/cli/utils/files.go b/pkg/cli/utils/files.go index 00e898ec..60f57de6 100644 --- a/pkg/cli/utils/files.go +++ b/pkg/cli/utils/files.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package utils diff --git a/pkg/cli/utils/files_test.go b/pkg/cli/utils/files_test.go index 3c7c92bd..7f26e19c 100644 --- a/pkg/cli/utils/files_test.go +++ b/pkg/cli/utils/files_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package utils diff --git a/pkg/cli/utils/utils.go b/pkg/cli/utils/utils.go index 5eed196f..417963ce 100644 --- a/pkg/cli/utils/utils.go +++ b/pkg/cli/utils/utils.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package utils diff --git a/pkg/cli/validate/book_test.go b/pkg/cli/validate/book_test.go index 29c410a4..97a384fc 100644 --- a/pkg/cli/validate/book_test.go +++ b/pkg/cli/validate/book_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package validate diff --git a/pkg/cli/validate/books.go b/pkg/cli/validate/books.go index 55b03675..b0e4c0ed 100644 --- a/pkg/cli/validate/books.go +++ b/pkg/cli/validate/books.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package validate diff --git a/pkg/clock/clock.go b/pkg/clock/clock.go index dda84b74..061bb1a3 100644 --- a/pkg/clock/clock.go +++ b/pkg/clock/clock.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package clock provides an abstract layer over the standard time package diff --git a/pkg/dirs/dirs.go b/pkg/dirs/dirs.go index 439cfde8..3eb57a7f 100644 --- a/pkg/dirs/dirs.go +++ b/pkg/dirs/dirs.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package dirs provides base directory definitions for the system diff --git a/pkg/dirs/dirs_test.go b/pkg/dirs/dirs_test.go index 6fe3d1e0..0c1ecb1f 100644 --- a/pkg/dirs/dirs_test.go +++ b/pkg/dirs/dirs_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package dirs diff --git a/pkg/dirs/dirs_unix.go b/pkg/dirs/dirs_unix.go index 59420c0e..6c7696c6 100644 --- a/pkg/dirs/dirs_unix.go +++ b/pkg/dirs/dirs_unix.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ //go:build linux || darwin || freebsd diff --git a/pkg/dirs/dirs_unix_test.go b/pkg/dirs/dirs_unix_test.go index 0ab63ad8..9ea5805a 100644 --- a/pkg/dirs/dirs_unix_test.go +++ b/pkg/dirs/dirs_unix_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ //go:build linux || darwin || freebsd diff --git a/pkg/dirs/dirs_windows.go b/pkg/dirs/dirs_windows.go index fb7bccf6..7159ae8d 100644 --- a/pkg/dirs/dirs_windows.go +++ b/pkg/dirs/dirs_windows.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ //go:build windows diff --git a/pkg/dirs/dirs_windows_test.go b/pkg/dirs/dirs_windows_test.go index 85be4a3f..101071f5 100644 --- a/pkg/dirs/dirs_windows_test.go +++ b/pkg/dirs/dirs_windows_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ //go:build windows diff --git a/pkg/e2e/server_test.go b/pkg/e2e/server_test.go index 39da46de..f94347ac 100644 --- a/pkg/e2e/server_test.go +++ b/pkg/e2e/server_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package main diff --git a/pkg/e2e/sync/basic_test.go b/pkg/e2e/sync/basic_test.go index 4986229a..d49b0cd9 100644 --- a/pkg/e2e/sync/basic_test.go +++ b/pkg/e2e/sync/basic_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/e2e/sync/edge_cases_test.go b/pkg/e2e/sync/edge_cases_test.go index ef1e0923..f833cadc 100644 --- a/pkg/e2e/sync/edge_cases_test.go +++ b/pkg/e2e/sync/edge_cases_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/e2e/sync/empty_server_test.go b/pkg/e2e/sync/empty_server_test.go index ad7308e9..31756ed2 100644 --- a/pkg/e2e/sync/empty_server_test.go +++ b/pkg/e2e/sync/empty_server_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/e2e/sync/main_test.go b/pkg/e2e/sync/main_test.go index b5d517f5..188e3a99 100644 --- a/pkg/e2e/sync/main_test.go +++ b/pkg/e2e/sync/main_test.go @@ -1,21 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This file is part of Dnote. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/e2e/sync/testutils.go b/pkg/e2e/sync/testutils.go index def7bc47..0a09d963 100644 --- a/pkg/e2e/sync/testutils.go +++ b/pkg/e2e/sync/testutils.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sync diff --git a/pkg/prompt/prompt.go b/pkg/prompt/prompt.go index 1d413a27..262685e9 100644 --- a/pkg/prompt/prompt.go +++ b/pkg/prompt/prompt.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package prompt provides utilities for interactive yes/no prompts diff --git a/pkg/prompt/prompt_test.go b/pkg/prompt/prompt_test.go index f0df9480..6d5eb597 100644 --- a/pkg/prompt/prompt_test.go +++ b/pkg/prompt/prompt_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package prompt diff --git a/pkg/server/app/app.go b/pkg/server/app/app.go index 96717eea..80754fbe 100644 --- a/pkg/server/app/app.go +++ b/pkg/server/app/app.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/books.go b/pkg/server/app/books.go index ae7b355f..f222b816 100644 --- a/pkg/server/app/books.go +++ b/pkg/server/app/books.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/books_test.go b/pkg/server/app/books_test.go index 66a27077..8953c613 100644 --- a/pkg/server/app/books_test.go +++ b/pkg/server/app/books_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/doc.go b/pkg/server/app/doc.go index 502939ff..2a3f3695 100644 --- a/pkg/server/app/doc.go +++ b/pkg/server/app/doc.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* diff --git a/pkg/server/app/email.go b/pkg/server/app/email.go index 2f721a6f..14d3ec38 100644 --- a/pkg/server/app/email.go +++ b/pkg/server/app/email.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/email_test.go b/pkg/server/app/email_test.go index 56270604..31d284e7 100644 --- a/pkg/server/app/email_test.go +++ b/pkg/server/app/email_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/errors.go b/pkg/server/app/errors.go index 48f193b9..9d41ca38 100644 --- a/pkg/server/app/errors.go +++ b/pkg/server/app/errors.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/helpers.go b/pkg/server/app/helpers.go index 361db6cb..437ca9ae 100644 --- a/pkg/server/app/helpers.go +++ b/pkg/server/app/helpers.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/helpers_test.go b/pkg/server/app/helpers_test.go index ad309514..93486ecd 100644 --- a/pkg/server/app/helpers_test.go +++ b/pkg/server/app/helpers_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/notes.go b/pkg/server/app/notes.go index 7f25123a..4bdeaaf6 100644 --- a/pkg/server/app/notes.go +++ b/pkg/server/app/notes.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/notes_test.go b/pkg/server/app/notes_test.go index 6ee55b8f..a165312d 100644 --- a/pkg/server/app/notes_test.go +++ b/pkg/server/app/notes_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/sessions.go b/pkg/server/app/sessions.go index a240e036..e3a574b7 100644 --- a/pkg/server/app/sessions.go +++ b/pkg/server/app/sessions.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/testutils.go b/pkg/server/app/testutils.go index 45dbd5bb..8ea6980d 100644 --- a/pkg/server/app/testutils.go +++ b/pkg/server/app/testutils.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/users.go b/pkg/server/app/users.go index eb53c5a4..760b3354 100644 --- a/pkg/server/app/users.go +++ b/pkg/server/app/users.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/app/users_test.go b/pkg/server/app/users_test.go index 90184fec..f345b217 100644 --- a/pkg/server/app/users_test.go +++ b/pkg/server/app/users_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package app diff --git a/pkg/server/assets/embed.go b/pkg/server/assets/embed.go index abe8c04f..e0272d95 100644 --- a/pkg/server/assets/embed.go +++ b/pkg/server/assets/embed.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package assets diff --git a/pkg/server/assets/js/src/main.js b/pkg/server/assets/js/src/main.js index e63a8fb3..9e58d92a 100644 --- a/pkg/server/assets/js/src/main.js +++ b/pkg/server/assets/js/src/main.js @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ var getNextSibling = function (el, selector) { diff --git a/pkg/server/assets/package-lock.json b/pkg/server/assets/package-lock.json index ec63082c..610d8eb4 100644 --- a/pkg/server/assets/package-lock.json +++ b/pkg/server/assets/package-lock.json @@ -7,7 +7,7 @@ "": { "name": "assets", "version": "1.0.0", - "license": "AGPL-3.0-or-later", + "license": "Apache-2.0", "devDependencies": { "sass": "^1.50.1" } diff --git a/pkg/server/assets/package.json b/pkg/server/assets/package.json index 0edcd180..1561f6da 100644 --- a/pkg/server/assets/package.json +++ b/pkg/server/assets/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": {}, "author": "Dnote", - "license": "AGPL-3.0-or-later", + "license": "Apache-2.0", "devDependencies": { "sass": "^1.50.1" } diff --git a/pkg/server/assets/styles/src/_books.scss b/pkg/server/assets/styles/src/_books.scss index c94c4347..10f9a8aa 100644 --- a/pkg/server/assets/styles/src/_books.scss +++ b/pkg/server/assets/styles/src/_books.scss @@ -1,23 +1,20 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ @use "rem"; @use "theme"; -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ .books-page { .books-content { diff --git a/pkg/server/assets/styles/src/_bootstrap.scss b/pkg/server/assets/styles/src/_bootstrap.scss index e306a4b0..9ccc9a78 100644 --- a/pkg/server/assets/styles/src/_bootstrap.scss +++ b/pkg/server/assets/styles/src/_bootstrap.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // From Bootstrap <4.3.1 diff --git a/pkg/server/assets/styles/src/_buttons.scss b/pkg/server/assets/styles/src/_buttons.scss index 16059864..e734b003 100644 --- a/pkg/server/assets/styles/src/_buttons.scss +++ b/pkg/server/assets/styles/src/_buttons.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use "sass:color"; diff --git a/pkg/server/assets/styles/src/_font.scss b/pkg/server/assets/styles/src/_font.scss index 37bc3163..4818014a 100644 --- a/pkg/server/assets/styles/src/_font.scss +++ b/pkg/server/assets/styles/src/_font.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use 'responsive'; diff --git a/pkg/server/assets/styles/src/_global.scss b/pkg/server/assets/styles/src/_global.scss index 8c497658..7bad7d58 100644 --- a/pkg/server/assets/styles/src/_global.scss +++ b/pkg/server/assets/styles/src/_global.scss @@ -1,26 +1,23 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ @use "font"; @use "rem"; @use "responsive"; @use "theme"; @use "variables"; -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ .main { position: relative; diff --git a/pkg/server/assets/styles/src/_grid.scss b/pkg/server/assets/styles/src/_grid.scss index 362946be..9e527582 100644 --- a/pkg/server/assets/styles/src/_grid.scss +++ b/pkg/server/assets/styles/src/_grid.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /*! diff --git a/pkg/server/assets/styles/src/_header.scss b/pkg/server/assets/styles/src/_header.scss index c952599e..28374fb7 100644 --- a/pkg/server/assets/styles/src/_header.scss +++ b/pkg/server/assets/styles/src/_header.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use "sass:color"; diff --git a/pkg/server/assets/styles/src/_hljs.scss b/pkg/server/assets/styles/src/_hljs.scss index 3f05190d..4decc572 100644 --- a/pkg/server/assets/styles/src/_hljs.scss +++ b/pkg/server/assets/styles/src/_hljs.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* diff --git a/pkg/server/assets/styles/src/_home.scss b/pkg/server/assets/styles/src/_home.scss index ce72a9f3..6ec13eaa 100644 --- a/pkg/server/assets/styles/src/_home.scss +++ b/pkg/server/assets/styles/src/_home.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use 'theme'; diff --git a/pkg/server/assets/styles/src/_login.scss b/pkg/server/assets/styles/src/_login.scss index 9200a911..1b8bfa97 100644 --- a/pkg/server/assets/styles/src/_login.scss +++ b/pkg/server/assets/styles/src/_login.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use 'theme'; diff --git a/pkg/server/assets/styles/src/_markdown.scss b/pkg/server/assets/styles/src/_markdown.scss index 949ee46a..e1621ffa 100644 --- a/pkg/server/assets/styles/src/_markdown.scss +++ b/pkg/server/assets/styles/src/_markdown.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* diff --git a/pkg/server/assets/styles/src/_marker.scss b/pkg/server/assets/styles/src/_marker.scss index 6de64210..db583dd2 100644 --- a/pkg/server/assets/styles/src/_marker.scss +++ b/pkg/server/assets/styles/src/_marker.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ .marker { diff --git a/pkg/server/assets/styles/src/_note.scss b/pkg/server/assets/styles/src/_note.scss index edc83a34..87f6e790 100644 --- a/pkg/server/assets/styles/src/_note.scss +++ b/pkg/server/assets/styles/src/_note.scss @@ -1,25 +1,22 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ @use "font"; @use "rem"; @use "responsive"; @use "theme"; -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ .note-page { // min-height: calc(100vh - 57px); diff --git a/pkg/server/assets/styles/src/_reboot.scss b/pkg/server/assets/styles/src/_reboot.scss index 04587120..369cf5de 100644 --- a/pkg/server/assets/styles/src/_reboot.scss +++ b/pkg/server/assets/styles/src/_reboot.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /*! diff --git a/pkg/server/assets/styles/src/_rem.scss b/pkg/server/assets/styles/src/_rem.scss index cd736925..c2b914ff 100644 --- a/pkg/server/assets/styles/src/_rem.scss +++ b/pkg/server/assets/styles/src/_rem.scss @@ -1,23 +1,20 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ @use "sass:list"; @use "sass:map"; @use "sass:meta"; -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . - */ /* MIT License diff --git a/pkg/server/assets/styles/src/_responsive.scss b/pkg/server/assets/styles/src/_responsive.scss index 9aaf9a7f..2ebbf0ab 100644 --- a/pkg/server/assets/styles/src/_responsive.scss +++ b/pkg/server/assets/styles/src/_responsive.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use 'variables'; diff --git a/pkg/server/assets/styles/src/_select.scss b/pkg/server/assets/styles/src/_select.scss index 9a0abb60..a0dc5d8c 100644 --- a/pkg/server/assets/styles/src/_select.scss +++ b/pkg/server/assets/styles/src/_select.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /** diff --git a/pkg/server/assets/styles/src/_settings.scss b/pkg/server/assets/styles/src/_settings.scss index 2f5d439d..a965ecbb 100644 --- a/pkg/server/assets/styles/src/_settings.scss +++ b/pkg/server/assets/styles/src/_settings.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use 'theme'; diff --git a/pkg/server/assets/styles/src/_shared.scss b/pkg/server/assets/styles/src/_shared.scss index 1b7697c1..3dcbcbe4 100644 --- a/pkg/server/assets/styles/src/_shared.scss +++ b/pkg/server/assets/styles/src/_shared.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use 'font'; diff --git a/pkg/server/assets/styles/src/_theme.scss b/pkg/server/assets/styles/src/_theme.scss index f37d81a5..5654cb7a 100644 --- a/pkg/server/assets/styles/src/_theme.scss +++ b/pkg/server/assets/styles/src/_theme.scss @@ -1,21 +1,18 @@ -@use "sass:color"; -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +@use "sass:color"; // basic colors $black: #2a2a2a; diff --git a/pkg/server/assets/styles/src/_variables.scss b/pkg/server/assets/styles/src/_variables.scss index c54cd062..490d9dbb 100644 --- a/pkg/server/assets/styles/src/_variables.scss +++ b/pkg/server/assets/styles/src/_variables.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ $header-height: 60px; diff --git a/pkg/server/assets/styles/src/main.scss b/pkg/server/assets/styles/src/main.scss index 4a5a7379..9afa9f6d 100644 --- a/pkg/server/assets/styles/src/main.scss +++ b/pkg/server/assets/styles/src/main.scss @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @use 'reboot'; diff --git a/pkg/server/buildinfo/info.go b/pkg/server/buildinfo/info.go index 09bcdb9d..4e6661f8 100644 --- a/pkg/server/buildinfo/info.go +++ b/pkg/server/buildinfo/info.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package buildinfo diff --git a/pkg/server/cmd/helpers.go b/pkg/server/cmd/helpers.go index eb58c318..3b981dc5 100644 --- a/pkg/server/cmd/helpers.go +++ b/pkg/server/cmd/helpers.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package cmd diff --git a/pkg/server/cmd/root.go b/pkg/server/cmd/root.go index 1ed2129f..106ab2d9 100644 --- a/pkg/server/cmd/root.go +++ b/pkg/server/cmd/root.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package cmd diff --git a/pkg/server/cmd/start.go b/pkg/server/cmd/start.go index dee5913c..c65ac398 100644 --- a/pkg/server/cmd/start.go +++ b/pkg/server/cmd/start.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package cmd diff --git a/pkg/server/cmd/user.go b/pkg/server/cmd/user.go index ec5b4ea2..01b753b1 100644 --- a/pkg/server/cmd/user.go +++ b/pkg/server/cmd/user.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package cmd diff --git a/pkg/server/cmd/user_test.go b/pkg/server/cmd/user_test.go index ea81832a..834ae3bd 100644 --- a/pkg/server/cmd/user_test.go +++ b/pkg/server/cmd/user_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package cmd diff --git a/pkg/server/cmd/version.go b/pkg/server/cmd/version.go index 99c68429..c36405d4 100644 --- a/pkg/server/cmd/version.go +++ b/pkg/server/cmd/version.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package cmd diff --git a/pkg/server/config/config.go b/pkg/server/config/config.go index e941a9a5..0fbb3617 100644 --- a/pkg/server/config/config.go +++ b/pkg/server/config/config.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package config diff --git a/pkg/server/config/config_test.go b/pkg/server/config/config_test.go index 802a3add..8b76c07b 100644 --- a/pkg/server/config/config_test.go +++ b/pkg/server/config/config_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package config diff --git a/pkg/server/consts/consts.go b/pkg/server/consts/consts.go index 948d7631..1f464951 100644 --- a/pkg/server/consts/consts.go +++ b/pkg/server/consts/consts.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package consts diff --git a/pkg/server/context/user.go b/pkg/server/context/user.go index 64171df7..b58d40e9 100644 --- a/pkg/server/context/user.go +++ b/pkg/server/context/user.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package context diff --git a/pkg/server/controllers/books.go b/pkg/server/controllers/books.go index c721b594..c20ea679 100644 --- a/pkg/server/controllers/books.go +++ b/pkg/server/controllers/books.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/books_test.go b/pkg/server/controllers/books_test.go index e2302f22..af6ba42d 100644 --- a/pkg/server/controllers/books_test.go +++ b/pkg/server/controllers/books_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/controllers.go b/pkg/server/controllers/controllers.go index b0cbe550..4ab9980d 100644 --- a/pkg/server/controllers/controllers.go +++ b/pkg/server/controllers/controllers.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/health.go b/pkg/server/controllers/health.go index fb12033d..85d8e048 100644 --- a/pkg/server/controllers/health.go +++ b/pkg/server/controllers/health.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/health_test.go b/pkg/server/controllers/health_test.go index cec8d35a..56fe9778 100644 --- a/pkg/server/controllers/health_test.go +++ b/pkg/server/controllers/health_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/helpers.go b/pkg/server/controllers/helpers.go index 72100c8b..c17e83a1 100644 --- a/pkg/server/controllers/helpers.go +++ b/pkg/server/controllers/helpers.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/main_test.go b/pkg/server/controllers/main_test.go index 35eef6da..cc0383b3 100644 --- a/pkg/server/controllers/main_test.go +++ b/pkg/server/controllers/main_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/notes.go b/pkg/server/controllers/notes.go index 4db709da..964a608f 100644 --- a/pkg/server/controllers/notes.go +++ b/pkg/server/controllers/notes.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/notes_test.go b/pkg/server/controllers/notes_test.go index b69f7c1e..afbca59b 100644 --- a/pkg/server/controllers/notes_test.go +++ b/pkg/server/controllers/notes_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/routes.go b/pkg/server/controllers/routes.go index ff7be403..3552d081 100644 --- a/pkg/server/controllers/routes.go +++ b/pkg/server/controllers/routes.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/routes_test.go b/pkg/server/controllers/routes_test.go index d3084aa3..0d146fe6 100644 --- a/pkg/server/controllers/routes_test.go +++ b/pkg/server/controllers/routes_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/static.go b/pkg/server/controllers/static.go index 5590daec..42872438 100644 --- a/pkg/server/controllers/static.go +++ b/pkg/server/controllers/static.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/sync.go b/pkg/server/controllers/sync.go index 3d7d2608..7cda4316 100644 --- a/pkg/server/controllers/sync.go +++ b/pkg/server/controllers/sync.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/sync_test.go b/pkg/server/controllers/sync_test.go index ab33956a..e97ecb50 100644 --- a/pkg/server/controllers/sync_test.go +++ b/pkg/server/controllers/sync_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/testutils.go b/pkg/server/controllers/testutils.go index 03a097c8..5da11a41 100644 --- a/pkg/server/controllers/testutils.go +++ b/pkg/server/controllers/testutils.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/users.go b/pkg/server/controllers/users.go index bf1e6384..26881668 100644 --- a/pkg/server/controllers/users.go +++ b/pkg/server/controllers/users.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/controllers/users_test.go b/pkg/server/controllers/users_test.go index 03f6c53e..f5ddf5b5 100644 --- a/pkg/server/controllers/users_test.go +++ b/pkg/server/controllers/users_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package controllers diff --git a/pkg/server/crypt/crypt.go b/pkg/server/crypt/crypt.go index 1be220dd..fb0edd26 100644 --- a/pkg/server/crypt/crypt.go +++ b/pkg/server/crypt/crypt.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package crypt diff --git a/pkg/server/database/consts.go b/pkg/server/database/consts.go index 6a9abc0c..4406ee5c 100644 --- a/pkg/server/database/consts.go +++ b/pkg/server/database/consts.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/database/database.go b/pkg/server/database/database.go index 2c5241b4..c5804880 100644 --- a/pkg/server/database/database.go +++ b/pkg/server/database/database.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/database/errors.go b/pkg/server/database/errors.go index 6e0faeb6..ada00a6d 100644 --- a/pkg/server/database/errors.go +++ b/pkg/server/database/errors.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/database/migrate.go b/pkg/server/database/migrate.go index 4250fd80..59e4c820 100644 --- a/pkg/server/database/migrate.go +++ b/pkg/server/database/migrate.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/database/migrate_test.go b/pkg/server/database/migrate_test.go index 31853730..4ee93627 100644 --- a/pkg/server/database/migrate_test.go +++ b/pkg/server/database/migrate_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/database/migrations/embed.go b/pkg/server/database/migrations/embed.go index 152d9e14..1c644d57 100644 --- a/pkg/server/database/migrations/embed.go +++ b/pkg/server/database/migrations/embed.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package migrations diff --git a/pkg/server/database/models.go b/pkg/server/database/models.go index f21e8636..6ee4d3a7 100644 --- a/pkg/server/database/models.go +++ b/pkg/server/database/models.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/database/notes.go b/pkg/server/database/notes.go index 680c53db..b8cb8450 100644 --- a/pkg/server/database/notes.go +++ b/pkg/server/database/notes.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/database/types.go b/pkg/server/database/types.go index da3b4d6f..60544c29 100644 --- a/pkg/server/database/types.go +++ b/pkg/server/database/types.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package database diff --git a/pkg/server/helpers/const.go b/pkg/server/helpers/const.go index e0967cc7..3a634d09 100644 --- a/pkg/server/helpers/const.go +++ b/pkg/server/helpers/const.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package helpers diff --git a/pkg/server/helpers/url.go b/pkg/server/helpers/url.go index 73c489fe..0d935754 100644 --- a/pkg/server/helpers/url.go +++ b/pkg/server/helpers/url.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package helpers diff --git a/pkg/server/helpers/url_test.go b/pkg/server/helpers/url_test.go index 55bb2fcc..78142b29 100644 --- a/pkg/server/helpers/url_test.go +++ b/pkg/server/helpers/url_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package helpers diff --git a/pkg/server/helpers/uuid.go b/pkg/server/helpers/uuid.go index 572ea6be..ed1090d4 100644 --- a/pkg/server/helpers/uuid.go +++ b/pkg/server/helpers/uuid.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package helpers diff --git a/pkg/server/log/log.go b/pkg/server/log/log.go index 89eeb719..60543acf 100644 --- a/pkg/server/log/log.go +++ b/pkg/server/log/log.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package log provides interfaces to write structured logs diff --git a/pkg/server/log/log_test.go b/pkg/server/log/log_test.go index 3df63b3a..488e3725 100644 --- a/pkg/server/log/log_test.go +++ b/pkg/server/log/log_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package log diff --git a/pkg/server/mailer/backend.go b/pkg/server/mailer/backend.go index 0abe51d8..e282e03c 100644 --- a/pkg/server/mailer/backend.go +++ b/pkg/server/mailer/backend.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package mailer diff --git a/pkg/server/mailer/backend_test.go b/pkg/server/mailer/backend_test.go index 5ef0a355..2838a19d 100644 --- a/pkg/server/mailer/backend_test.go +++ b/pkg/server/mailer/backend_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package mailer diff --git a/pkg/server/mailer/mailer.go b/pkg/server/mailer/mailer.go index 1cf786a7..10457252 100644 --- a/pkg/server/mailer/mailer.go +++ b/pkg/server/mailer/mailer.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package mailer provides a functionality to send emails diff --git a/pkg/server/mailer/mailer_test.go b/pkg/server/mailer/mailer_test.go index 5837192a..e08c9c55 100644 --- a/pkg/server/mailer/mailer_test.go +++ b/pkg/server/mailer/mailer_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package mailer diff --git a/pkg/server/mailer/templates/templates.go b/pkg/server/mailer/templates/templates.go index c59d3a14..78fedd07 100644 --- a/pkg/server/mailer/templates/templates.go +++ b/pkg/server/mailer/templates/templates.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package mailer provides a functionality to send emails diff --git a/pkg/server/mailer/tokens.go b/pkg/server/mailer/tokens.go index 0f751a4e..669c4820 100644 --- a/pkg/server/mailer/tokens.go +++ b/pkg/server/mailer/tokens.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package mailer diff --git a/pkg/server/mailer/tokens_test.go b/pkg/server/mailer/tokens_test.go index 72a85fc6..4f4fa73d 100644 --- a/pkg/server/mailer/tokens_test.go +++ b/pkg/server/mailer/tokens_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package mailer diff --git a/pkg/server/mailer/types.go b/pkg/server/mailer/types.go index 6ad862de..17363398 100644 --- a/pkg/server/mailer/types.go +++ b/pkg/server/mailer/types.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package mailer diff --git a/pkg/server/main.go b/pkg/server/main.go index 701912ea..737cc7a6 100644 --- a/pkg/server/main.go +++ b/pkg/server/main.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package main diff --git a/pkg/server/middleware/auth.go b/pkg/server/middleware/auth.go index daf92dc3..9383d33d 100644 --- a/pkg/server/middleware/auth.go +++ b/pkg/server/middleware/auth.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/middleware/auth_test.go b/pkg/server/middleware/auth_test.go index 95c935a2..c6d0ead4 100644 --- a/pkg/server/middleware/auth_test.go +++ b/pkg/server/middleware/auth_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/middleware/helpers.go b/pkg/server/middleware/helpers.go index f43d0abb..580efa7f 100644 --- a/pkg/server/middleware/helpers.go +++ b/pkg/server/middleware/helpers.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/middleware/helpers_test.go b/pkg/server/middleware/helpers_test.go index 623ec818..3142326f 100644 --- a/pkg/server/middleware/helpers_test.go +++ b/pkg/server/middleware/helpers_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/middleware/limit.go b/pkg/server/middleware/limit.go index 2f737613..6985809e 100644 --- a/pkg/server/middleware/limit.go +++ b/pkg/server/middleware/limit.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/middleware/limit_test.go b/pkg/server/middleware/limit_test.go index 1d5743ee..594d0a94 100644 --- a/pkg/server/middleware/limit_test.go +++ b/pkg/server/middleware/limit_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/middleware/logging.go b/pkg/server/middleware/logging.go index 05cdd2cb..13c9a9c9 100644 --- a/pkg/server/middleware/logging.go +++ b/pkg/server/middleware/logging.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/middleware/middleware.go b/pkg/server/middleware/middleware.go index 582e8046..e509c169 100644 --- a/pkg/server/middleware/middleware.go +++ b/pkg/server/middleware/middleware.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package middleware diff --git a/pkg/server/operations/doc.go b/pkg/server/operations/doc.go index 981c9f5c..7a4fe7c8 100644 --- a/pkg/server/operations/doc.go +++ b/pkg/server/operations/doc.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* diff --git a/pkg/server/operations/notes.go b/pkg/server/operations/notes.go index ee6dd9af..74b279e4 100644 --- a/pkg/server/operations/notes.go +++ b/pkg/server/operations/notes.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package operations diff --git a/pkg/server/operations/notes_test.go b/pkg/server/operations/notes_test.go index a2ccb023..a09c1c28 100644 --- a/pkg/server/operations/notes_test.go +++ b/pkg/server/operations/notes_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package operations diff --git a/pkg/server/permissions/permissions.go b/pkg/server/permissions/permissions.go index d9d017d9..54427acf 100644 --- a/pkg/server/permissions/permissions.go +++ b/pkg/server/permissions/permissions.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package permissions diff --git a/pkg/server/permissions/permissions_test.go b/pkg/server/permissions/permissions_test.go index 13f13f97..2a5daca1 100644 --- a/pkg/server/permissions/permissions_test.go +++ b/pkg/server/permissions/permissions_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package permissions diff --git a/pkg/server/presenters/book.go b/pkg/server/presenters/book.go index 85242b26..9c117726 100644 --- a/pkg/server/presenters/book.go +++ b/pkg/server/presenters/book.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package presenters diff --git a/pkg/server/presenters/book_test.go b/pkg/server/presenters/book_test.go index 98155769..bf8a1b48 100644 --- a/pkg/server/presenters/book_test.go +++ b/pkg/server/presenters/book_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package presenters diff --git a/pkg/server/presenters/helpers.go b/pkg/server/presenters/helpers.go index 491e575e..3cce728c 100644 --- a/pkg/server/presenters/helpers.go +++ b/pkg/server/presenters/helpers.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package presenters diff --git a/pkg/server/presenters/helpers_test.go b/pkg/server/presenters/helpers_test.go index c48c90ea..33b0ed2e 100644 --- a/pkg/server/presenters/helpers_test.go +++ b/pkg/server/presenters/helpers_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package presenters diff --git a/pkg/server/presenters/note.go b/pkg/server/presenters/note.go index a20bb879..267717da 100644 --- a/pkg/server/presenters/note.go +++ b/pkg/server/presenters/note.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package presenters diff --git a/pkg/server/presenters/note_test.go b/pkg/server/presenters/note_test.go index 878acf67..ee2fe78d 100644 --- a/pkg/server/presenters/note_test.go +++ b/pkg/server/presenters/note_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package presenters diff --git a/pkg/server/session/session.go b/pkg/server/session/session.go index d7c3d0d8..b9ae62d4 100644 --- a/pkg/server/session/session.go +++ b/pkg/server/session/session.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package session diff --git a/pkg/server/session/session_test.go b/pkg/server/session/session_test.go index dddfa18b..081a82de 100644 --- a/pkg/server/session/session_test.go +++ b/pkg/server/session/session_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package session diff --git a/pkg/server/testutils/main.go b/pkg/server/testutils/main.go index 6b7c21b6..dd10941e 100644 --- a/pkg/server/testutils/main.go +++ b/pkg/server/testutils/main.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Package testutils provides utilities used in tests diff --git a/pkg/server/token/token.go b/pkg/server/token/token.go index f482d2aa..af1feda5 100644 --- a/pkg/server/token/token.go +++ b/pkg/server/token/token.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package token diff --git a/pkg/server/token/token_test.go b/pkg/server/token/token_test.go index c7469d4f..5daed181 100644 --- a/pkg/server/token/token_test.go +++ b/pkg/server/token/token_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package token diff --git a/pkg/server/views/data.go b/pkg/server/views/data.go index 98444364..87fd2a90 100644 --- a/pkg/server/views/data.go +++ b/pkg/server/views/data.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package views diff --git a/pkg/server/views/embed.go b/pkg/server/views/embed.go index b3a070a0..1fcb7d19 100644 --- a/pkg/server/views/embed.go +++ b/pkg/server/views/embed.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package views diff --git a/pkg/server/views/engine.go b/pkg/server/views/engine.go index b8127b03..fbad7979 100644 --- a/pkg/server/views/engine.go +++ b/pkg/server/views/engine.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package views diff --git a/pkg/server/views/helpers.go b/pkg/server/views/helpers.go index ac4546f7..3e8f1d56 100644 --- a/pkg/server/views/helpers.go +++ b/pkg/server/views/helpers.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package views diff --git a/pkg/server/views/helpers_test.go b/pkg/server/views/helpers_test.go index 56bb7912..af39b48c 100644 --- a/pkg/server/views/helpers_test.go +++ b/pkg/server/views/helpers_test.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package views diff --git a/pkg/server/views/time.go b/pkg/server/views/time.go index e99d36c9..88c71169 100644 --- a/pkg/server/views/time.go +++ b/pkg/server/views/time.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package views diff --git a/pkg/server/views/view.go b/pkg/server/views/view.go index 438735a1..53315334 100644 --- a/pkg/server/views/view.go +++ b/pkg/server/views/view.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package views diff --git a/pkg/watcher/main.go b/pkg/watcher/main.go index a548aafe..7509fb90 100644 --- a/pkg/watcher/main.go +++ b/pkg/watcher/main.go @@ -1,19 +1,16 @@ -/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors +/* Copyright 2025 Dnote Authors * - * This file is part of Dnote. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Dnote is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Dnote 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package main diff --git a/scripts/cli/build.sh b/scripts/cli/build.sh index c5c6043c..d17cb477 100755 --- a/scripts/cli/build.sh +++ b/scripts/cli/build.sh @@ -98,7 +98,7 @@ build() { tarballName="dnote_${version}_${platform}_${arch}.tar.gz" tarballPath="$outputDir/$tarballName" - cp "$projectDir/licenses/GPLv3.txt" "$destDir" + cp "$projectDir/LICENSE" "$destDir" cp "$basedir/README.md" "$destDir" tar -C "$destDir" -zcvf "$tarballPath" "." rm -rf "$destDir" diff --git a/scripts/license.sh b/scripts/license.sh index d75b656b..4f96780c 100755 --- a/scripts/license.sh +++ b/scripts/license.sh @@ -2,74 +2,45 @@ set -eux function remove_notice { - sed -i -e '/\/\* Copyright/,/\*\//d' "$1" - - # remove leading newline - sed -i '/./,$!d' "$1" + # Remove old copyright notice - matches /* Copyright ... */ including the trailing newline + # The 's' flag makes . match newlines, allowing multi-line matching + # The \n? matches an optional newline after the closing */ + perl -i -0pe 's/\/\* Copyright.*?\*\/\n?//s' "$1" } function add_notice { ed "$1" <. - */" - -agpl="/* Copyright (C) 2019, 2020, 2021, 2022, 2023, 2024, 2025 Dnote contributors - * - * This file is part of Dnote. - * - * Dnote is free software: you can redistribute it and/or modify - * 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. - * - * Dnote 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 Dnote. If not, see . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an \"AS IS\" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */" dir=$(dirname "${BASH_SOURCE[0]}") basedir="$dir/.." pkgPath="$basedir/pkg" -serverPath="$basedir/pkg/server" -gplFiles=$(find "$pkgPath" -type f \( -name "*.go" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.scss" -o -name "*.css" \) ! -path "**/vendor/*" ! -path "**/node_modules/*" ! -path "$serverPath/*") +# Apply license to all source files +allFiles=$(find "$pkgPath" -type f \( -name "*.go" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.scss" -o -name "*.css" \) ! -path "**/vendor/*" ! -path "**/node_modules/*" ! -path "**/dist/*") -for file in $gplFiles; do +for file in $allFiles; do remove_notice "$file" - add_notice "$file" "$gpl" -done - -agplFiles=$(find "$serverPath" -type f \( -name "*.go" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.scss" -o -name "*.css" \) ! -path "**/vendor/*" ! -path "**/node_modules/*" ! -path "**/dist/*") - -for file in $agplFiles; do - remove_notice "$file" - add_notice "$file" "$agpl" + add_notice "$file" "$license" done diff --git a/scripts/server/build.sh b/scripts/server/build.sh index f9c6428e..09bc16e3 100755 --- a/scripts/server/build.sh +++ b/scripts/server/build.sh @@ -57,7 +57,7 @@ build() { tarballName="dnote_server_${version}_${platform}_${arch}.tar.gz" tarballPath="$outputDir/$tarballName" - cp "$projectDir/licenses/AGPLv3.txt" "$destDir" + cp "$projectDir/LICENSE" "$destDir" cp "$basedir/README.md" "$destDir" tar -C "$destDir" -zcvf "$tarballPath" "." rm -rf "$destDir" From e72322f847d4d0dbd4dbba5a0db2975eeb7788c0 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 1 Nov 2025 00:54:27 -0700 Subject: [PATCH 26/33] Simplify email backend and remove --appEnv (#710) * Improve logging * Remove AppEnv * Simplify email backend --- pkg/e2e/server_test.go | 3 -- pkg/e2e/sync/testutils.go | 2 - pkg/server/.env.dev | 2 - pkg/server/app/app.go | 7 ---- pkg/server/app/email.go | 53 +++++++++++-------------- pkg/server/app/errors.go | 2 +- pkg/server/app/sessions.go | 2 +- pkg/server/app/testutils.go | 3 -- pkg/server/cmd/helpers.go | 21 +++++----- pkg/server/cmd/start.go | 2 - pkg/server/config/config.go | 10 ----- pkg/server/database/database.go | 32 +++++++++++---- pkg/server/log/log.go | 5 +++ pkg/server/mailer/backend.go | 66 +++++++++++++++++++++++-------- pkg/server/mailer/backend_test.go | 59 ++++++++++++++------------- pkg/server/mailer/mailer.go | 43 ++++++++++++-------- pkg/server/mailer/mailer_test.go | 15 +++++-- pkg/server/middleware/limit.go | 3 +- pkg/server/testutils/main.go | 20 +++++----- scripts/server/dev.sh | 7 +--- 20 files changed, 196 insertions(+), 161 deletions(-) delete mode 100644 pkg/server/.env.dev diff --git a/pkg/e2e/server_test.go b/pkg/e2e/server_test.go index f94347ac..b7a17b2d 100644 --- a/pkg/e2e/server_test.go +++ b/pkg/e2e/server_test.go @@ -50,8 +50,6 @@ func TestServerStart(t *testing.T) { cmd := exec.Command(testServerBinary, "start", "--port", port) cmd.Env = append(os.Environ(), "DBPath="+tmpDB, - "WebURL=http://localhost:"+port, - "APP_ENV=PRODUCTION", ) if err := cmd.Start(); err != nil { @@ -140,7 +138,6 @@ func TestServerStartHelp(t *testing.T) { outputStr := string(output) assert.Equal(t, strings.Contains(outputStr, "dnote-server start [flags]"), true, "output should contain usage") - assert.Equal(t, strings.Contains(outputStr, "--appEnv"), true, "output should contain appEnv flag") assert.Equal(t, strings.Contains(outputStr, "--port"), true, "output should contain port flag") assert.Equal(t, strings.Contains(outputStr, "--webUrl"), true, "output should contain webUrl flag") assert.Equal(t, strings.Contains(outputStr, "--dbPath"), true, "output should contain dbPath flag") diff --git a/pkg/e2e/sync/testutils.go b/pkg/e2e/sync/testutils.go index 0a09d963..a5dfdf87 100644 --- a/pkg/e2e/sync/testutils.go +++ b/pkg/e2e/sync/testutils.go @@ -35,7 +35,6 @@ import ( "github.com/dnote/dnote/pkg/server/app" "github.com/dnote/dnote/pkg/server/controllers" "github.com/dnote/dnote/pkg/server/database" - "github.com/dnote/dnote/pkg/server/mailer" apitest "github.com/dnote/dnote/pkg/server/testutils" "github.com/pkg/errors" "gorm.io/gorm" @@ -98,7 +97,6 @@ func setupTestServer(t *testing.T, serverTime time.Time) (*httptest.Server, *gor a := app.NewTest() a.Clock = mockClock - a.EmailTemplates = mailer.Templates{} a.EmailBackend = &apitest.MockEmailbackendImplementation{} a.DB = db diff --git a/pkg/server/.env.dev b/pkg/server/.env.dev deleted file mode 100644 index c78a6704..00000000 --- a/pkg/server/.env.dev +++ /dev/null @@ -1,2 +0,0 @@ -APP_ENV=DEVELOPMENT -DBPath=../../dev-server.db diff --git a/pkg/server/app/app.go b/pkg/server/app/app.go index 80754fbe..6a8c5d14 100644 --- a/pkg/server/app/app.go +++ b/pkg/server/app/app.go @@ -29,8 +29,6 @@ var ( ErrEmptyClock = errors.New("No clock was provided") // ErrEmptyWebURL is an error for missing WebURL content in the app configuration ErrEmptyWebURL = errors.New("No WebURL was provided") - // ErrEmptyEmailTemplates is an error for missing EmailTemplates content in the app configuration - ErrEmptyEmailTemplates = errors.New("No EmailTemplate store was provided") // ErrEmptyEmailBackend is an error for missing EmailBackend content in the app configuration ErrEmptyEmailBackend = errors.New("No EmailBackend was provided") // ErrEmptyHTTP500Page is an error for missing HTTP 500 page content @@ -41,11 +39,9 @@ var ( type App struct { DB *gorm.DB Clock clock.Clock - EmailTemplates mailer.Templates EmailBackend mailer.Backend Files map[string][]byte HTTP500Page []byte - AppEnv string WebURL string DisableRegistration bool Port string @@ -61,9 +57,6 @@ func (a *App) Validate() error { if a.Clock == nil { return ErrEmptyClock } - if a.EmailTemplates == nil { - return ErrEmptyEmailTemplates - } if a.EmailBackend == nil { return ErrEmptyEmailBackend } diff --git a/pkg/server/app/email.go b/pkg/server/app/email.go index 14d3ec38..1b78f722 100644 --- a/pkg/server/app/email.go +++ b/pkg/server/app/email.go @@ -64,21 +64,18 @@ func getNoreplySender(webURL string) (string, error) { // SendWelcomeEmail sends welcome email func (a *App) SendWelcomeEmail(email string) error { - body, err := a.EmailTemplates.Execute(mailer.EmailTypeWelcome, mailer.EmailKindText, mailer.WelcomeTmplData{ - AccountEmail: email, - WebURL: a.WebURL, - }) - if err != nil { - return errors.Wrapf(err, "executing reset verification template for %s", email) - } - from, err := GetSenderEmail(a.WebURL, defaultSender) if err != nil { return errors.Wrap(err, "getting the sender email") } - if err := a.EmailBackend.Queue("Welcome to Dnote!", from, []string{email}, mailer.EmailKindText, body); err != nil { - return errors.Wrapf(err, "queueing email for %s", email) + data := mailer.WelcomeTmplData{ + AccountEmail: email, + WebURL: a.WebURL, + } + + if err := a.EmailBackend.SendEmail(mailer.EmailTypeWelcome, from, []string{email}, data); err != nil { + return errors.Wrapf(err, "sending welcome email for %s", email) } return nil @@ -90,26 +87,23 @@ func (a *App) SendPasswordResetEmail(email, tokenValue string) error { return ErrEmailRequired } - body, err := a.EmailTemplates.Execute(mailer.EmailTypeResetPassword, mailer.EmailKindText, mailer.EmailResetPasswordTmplData{ - AccountEmail: email, - Token: tokenValue, - WebURL: a.WebURL, - }) - if err != nil { - return errors.Wrapf(err, "executing reset password template for %s", email) - } - from, err := GetSenderEmail(a.WebURL, defaultSender) if err != nil { return errors.Wrap(err, "getting the sender email") } - if err := a.EmailBackend.Queue("Reset your password", from, []string{email}, mailer.EmailKindText, body); err != nil { + data := mailer.EmailResetPasswordTmplData{ + AccountEmail: email, + Token: tokenValue, + WebURL: a.WebURL, + } + + if err := a.EmailBackend.SendEmail(mailer.EmailTypeResetPassword, from, []string{email}, data); err != nil { if errors.Cause(err) == mailer.ErrSMTPNotConfigured { return ErrInvalidSMTPConfig } - return errors.Wrapf(err, "queueing email for %s", email) + return errors.Wrapf(err, "sending password reset email for %s", email) } return nil @@ -117,21 +111,18 @@ func (a *App) SendPasswordResetEmail(email, tokenValue string) error { // SendPasswordResetAlertEmail sends email that notifies users of a password change func (a *App) SendPasswordResetAlertEmail(email string) error { - body, err := a.EmailTemplates.Execute(mailer.EmailTypeResetPasswordAlert, mailer.EmailKindText, mailer.EmailResetPasswordAlertTmplData{ - AccountEmail: email, - WebURL: a.WebURL, - }) - if err != nil { - return errors.Wrapf(err, "executing reset password alert template for %s", email) - } - from, err := GetSenderEmail(a.WebURL, defaultSender) if err != nil { return errors.Wrap(err, "getting the sender email") } - if err := a.EmailBackend.Queue("Dnote password changed", from, []string{email}, mailer.EmailKindText, body); err != nil { - return errors.Wrapf(err, "queueing email for %s", email) + data := mailer.EmailResetPasswordAlertTmplData{ + AccountEmail: email, + WebURL: a.WebURL, + } + + if err := a.EmailBackend.SendEmail(mailer.EmailTypeResetPasswordAlert, from, []string{email}, data); err != nil { + return errors.Wrapf(err, "sending password reset alert email for %s", email) } return nil diff --git a/pkg/server/app/errors.go b/pkg/server/app/errors.go index 9d41ca38..67635b23 100644 --- a/pkg/server/app/errors.go +++ b/pkg/server/app/errors.go @@ -73,7 +73,7 @@ var ( // ErrInvalidPasswordChangeInput is an error for changing password ErrInvalidPasswordChangeInput appError = "Both current and new passwords are required to change the password." - ErrInvalidPassword appError = "Invalid currnet password." + ErrInvalidPassword appError = "Invalid current password." // ErrEmailTooLong is an error for email length exceeding the limit ErrEmailTooLong appError = "Email is too long." diff --git a/pkg/server/app/sessions.go b/pkg/server/app/sessions.go index e3a574b7..6c230d76 100644 --- a/pkg/server/app/sessions.go +++ b/pkg/server/app/sessions.go @@ -48,7 +48,7 @@ func (a *App) CreateSession(userID int) (database.Session, error) { // DeleteUserSessions deletes all existing sessions for the given user. It effectively // invalidates all existing sessions. func (a *App) DeleteUserSessions(db *gorm.DB, userID int) error { - if err := db.Debug().Where("user_id = ?", userID).Delete(&database.Session{}).Error; err != nil { + if err := db.Where("user_id = ?", userID).Delete(&database.Session{}).Error; err != nil { return errors.Wrap(err, "deleting sessions") } diff --git a/pkg/server/app/testutils.go b/pkg/server/app/testutils.go index 8ea6980d..48896cdc 100644 --- a/pkg/server/app/testutils.go +++ b/pkg/server/app/testutils.go @@ -18,7 +18,6 @@ package app import ( "github.com/dnote/dnote/pkg/clock" "github.com/dnote/dnote/pkg/server/assets" - "github.com/dnote/dnote/pkg/server/mailer" "github.com/dnote/dnote/pkg/server/testutils" ) @@ -26,10 +25,8 @@ import ( func NewTest() App { return App{ Clock: clock.NewMock(), - EmailTemplates: mailer.NewTemplates(), EmailBackend: &testutils.MockEmailbackendImplementation{}, HTTP500Page: assets.MustGetHTTP500ErrorPage(), - AppEnv: "TEST", WebURL: "http://127.0.0.0.1", Port: "3000", DisableRegistration: false, diff --git a/pkg/server/cmd/helpers.go b/pkg/server/cmd/helpers.go index 3b981dc5..3c135372 100644 --- a/pkg/server/cmd/helpers.go +++ b/pkg/server/cmd/helpers.go @@ -37,23 +37,26 @@ func initDB(dbPath string) *gorm.DB { return db } +func getEmailBackend() mailer.Backend { + defaultBackend, err := mailer.NewDefaultBackend() + if err != nil { + log.Debug("SMTP not configured, using StdoutBackend for emails") + return mailer.NewStdoutBackend() + } + + log.Debug("Email backend configured") + return defaultBackend +} + func initApp(cfg config.Config) app.App { db := initDB(cfg.DBPath) - - emailBackend, err := mailer.NewDefaultBackend(cfg.IsProd()) - if err != nil { - emailBackend = &mailer.DefaultBackend{Enabled: false} - } else { - log.Info("Email backend configured") - } + emailBackend := getEmailBackend() return app.App{ DB: db, Clock: clock.New(), - EmailTemplates: mailer.NewTemplates(), EmailBackend: emailBackend, HTTP500Page: cfg.HTTP500Page, - AppEnv: cfg.AppEnv, WebURL: cfg.WebURL, DisableRegistration: cfg.DisableRegistration, Port: cfg.Port, diff --git a/pkg/server/cmd/start.go b/pkg/server/cmd/start.go index c65ac398..465f41ce 100644 --- a/pkg/server/cmd/start.go +++ b/pkg/server/cmd/start.go @@ -32,7 +32,6 @@ import ( func startCmd(args []string) { fs := setupFlagSet("start", "dnote-server start") - appEnv := fs.String("appEnv", "", "Application environment (env: APP_ENV, default: PRODUCTION)") port := fs.String("port", "", "Server port (env: PORT, default: 3001)") webURL := fs.String("webUrl", "", "Full URL to server without trailing slash (env: WebURL, default: http://localhost:3001)") dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") @@ -42,7 +41,6 @@ func startCmd(args []string) { fs.Parse(args) cfg, err := config.New(config.Params{ - AppEnv: *appEnv, Port: *port, WebURL: *webURL, DBPath: *dbPath, diff --git a/pkg/server/config/config.go b/pkg/server/config/config.go index 0fbb3617..88b604bc 100644 --- a/pkg/server/config/config.go +++ b/pkg/server/config/config.go @@ -26,8 +26,6 @@ import ( ) const ( - // AppEnvProduction represents an app environment for production. - AppEnvProduction string = "PRODUCTION" // DefaultDBDir is the default directory name for Dnote data DefaultDBDir = "dnote" // DefaultDBFilename is the default database filename @@ -65,7 +63,6 @@ func getOrEnv(value, envKey, defaultVal string) string { // Config is an application configuration type Config struct { - AppEnv string WebURL string DisableRegistration bool Port string @@ -77,7 +74,6 @@ type Config struct { // Params are the configuration parameters for creating a new Config type Params struct { - AppEnv string Port string WebURL string DBPath string @@ -89,7 +85,6 @@ type Params struct { // Empty string params will fall back to environment variables and defaults. func New(p Params) (Config, error) { c := Config{ - AppEnv: getOrEnv(p.AppEnv, "APP_ENV", AppEnvProduction), Port: getOrEnv(p.Port, "PORT", "3001"), WebURL: getOrEnv(p.WebURL, "WebURL", "http://localhost:3001"), DBPath: getOrEnv(p.DBPath, "DBPath", DefaultDBPath), @@ -106,11 +101,6 @@ func New(p Params) (Config, error) { return c, nil } -// IsProd checks if the app environment is configured to be production. -func (c Config) IsProd() bool { - return c.AppEnv == AppEnvProduction -} - func validate(c Config) error { if _, err := url.ParseRequestURI(c.WebURL); err != nil { return errors.Wrapf(ErrWebURLInvalid, "'%s'", c.WebURL) diff --git a/pkg/server/database/database.go b/pkg/server/database/database.go index c5804880..cfb18ab7 100644 --- a/pkg/server/database/database.go +++ b/pkg/server/database/database.go @@ -20,9 +20,11 @@ import ( "path/filepath" "time" + "github.com/dnote/dnote/pkg/server/log" "github.com/pkg/errors" "gorm.io/driver/sqlite" "gorm.io/gorm" + "gorm.io/gorm/logger" ) var ( @@ -30,6 +32,22 @@ var ( MigrationTableName = "migrations" ) +// getDBLogLevel converts application log level to GORM log level +func getDBLogLevel(level string) logger.LogLevel { + switch level { + case log.LevelDebug: + return logger.Info + case log.LevelInfo: + return logger.Info + case log.LevelWarn: + return logger.Warn + case log.LevelError: + return logger.Error + default: + return logger.Error + } +} + // InitSchema migrates database schema to reflect the latest model definition func InitSchema(db *gorm.DB) { if err := db.AutoMigrate( @@ -51,7 +69,9 @@ func Open(dbPath string) *gorm.DB { panic(errors.Wrapf(err, "creating database directory at %s", dir)) } - db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{}) + db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{ + Logger: logger.Default.LogMode(getDBLogLevel(log.GetLevel())), + }) if err != nil { panic(errors.Wrap(err, "opening database conection")) } @@ -96,16 +116,14 @@ func StartWALCheckpointing(db *gorm.DB, interval time.Duration) { for range ticker.C { // TRUNCATE mode removes the WAL file after checkpointing if err := db.Exec("PRAGMA wal_checkpoint(TRUNCATE)").Error; err != nil { - // Log error but don't panic - this is a background maintenance task - // TODO: Use proper logging once available - _ = err + log.ErrorWrap(err, "WAL checkpoint failed") } } }() } // StartPeriodicVacuum runs full VACUUM on a schedule to reclaim space and defragment. -// WARNING: VACUUM acquires an exclusive lock and blocks all database operations briefly. +// VACUUM acquires an exclusive lock and blocks all database operations briefly. func StartPeriodicVacuum(db *gorm.DB, interval time.Duration) { go func() { ticker := time.NewTicker(interval) @@ -113,9 +131,7 @@ func StartPeriodicVacuum(db *gorm.DB, interval time.Duration) { for range ticker.C { if err := db.Exec("VACUUM").Error; err != nil { - // Log error but don't panic - this is a background maintenance task - // TODO: Use proper logging once available - _ = err + log.ErrorWrap(err, "VACUUM failed") } } }() diff --git a/pkg/server/log/log.go b/pkg/server/log/log.go index 60543acf..d8b43c8b 100644 --- a/pkg/server/log/log.go +++ b/pkg/server/log/log.go @@ -70,6 +70,11 @@ func SetLevel(level string) { currentLevel = level } +// GetLevel returns the current global log level +func GetLevel() string { + return currentLevel +} + // levelPriority returns a numeric priority for comparison func levelPriority(level string) int { switch level { diff --git a/pkg/server/mailer/backend.go b/pkg/server/mailer/backend.go index e282e03c..a09cf2e6 100644 --- a/pkg/server/mailer/backend.go +++ b/pkg/server/mailer/backend.go @@ -29,7 +29,7 @@ var ErrSMTPNotConfigured = errors.New("SMTP is not configured") // Backend is an interface for sending emails. type Backend interface { - Queue(subject, from string, to []string, contentType, body string) error + SendEmail(templateType, from string, to []string, data interface{}) error } // EmailDialer is an interface for sending email messages @@ -44,9 +44,10 @@ type gomailDialer struct { // DefaultBackend is an implementation of the Backend // that sends an email without queueing. +// This backend is always enabled and will send emails via SMTP. type DefaultBackend struct { - Dialer EmailDialer - Enabled bool + Dialer EmailDialer + Templates Templates } type dialerParams struct { @@ -82,7 +83,7 @@ func getSMTPParams() (*dialerParams, error) { } // NewDefaultBackend creates a default backend -func NewDefaultBackend(enabled bool) (*DefaultBackend, error) { +func NewDefaultBackend() (*DefaultBackend, error) { p, err := getSMTPParams() if err != nil { return nil, err @@ -91,24 +92,24 @@ func NewDefaultBackend(enabled bool) (*DefaultBackend, error) { d := gomail.NewDialer(p.Host, p.Port, p.Username, p.Password) return &DefaultBackend{ - Dialer: &gomailDialer{Dialer: d}, - Enabled: enabled, + Dialer: &gomailDialer{Dialer: d}, + Templates: NewTemplates(), }, nil } -// Queue is an implementation of Backend.Queue. -func (b *DefaultBackend) Queue(subject, from string, to []string, contentType, body string) error { - // If not enabled, just log the email - if !b.Enabled { - log.WithFields(log.Fields{ - "subject": subject, - "to": to, - "from": from, - "body": body, - }).Info("Not sending email because email backend is not configured.") - return nil +// SendEmail is an implementation of Backend.SendEmail. +// It renders the template and sends the email immediately via SMTP. +func (b *DefaultBackend) SendEmail(templateType, from string, to []string, data interface{}) error { + subject, body, err := b.Templates.Execute(templateType, EmailKindText, data) + if err != nil { + return errors.Wrap(err, "executing template") } + return b.queue(subject, from, to, EmailKindText, body) +} + +// queue sends the email immediately via SMTP. +func (b *DefaultBackend) queue(subject, from string, to []string, contentType, body string) error { m := gomail.NewMessage() m.SetHeader("From", from) m.SetHeader("To", to...) @@ -121,3 +122,34 @@ func (b *DefaultBackend) Queue(subject, from string, to []string, contentType, b return nil } + +// StdoutBackend is an implementation of the Backend +// that prints emails to stdout instead of sending them. +// This is useful for development and testing. +type StdoutBackend struct { + Templates Templates +} + +// NewStdoutBackend creates a stdout backend +func NewStdoutBackend() *StdoutBackend { + return &StdoutBackend{ + Templates: NewTemplates(), + } +} + +// SendEmail is an implementation of Backend.SendEmail. +// It renders the template and logs the email to stdout instead of sending it. +func (b *StdoutBackend) SendEmail(templateType, from string, to []string, data interface{}) error { + subject, body, err := b.Templates.Execute(templateType, EmailKindText, data) + if err != nil { + return errors.Wrap(err, "executing template") + } + + log.WithFields(log.Fields{ + "subject": subject, + "to": to, + "from": from, + "body": body, + }).Info("Email (not sent, using StdoutBackend)") + return nil +} diff --git a/pkg/server/mailer/backend_test.go b/pkg/server/mailer/backend_test.go index 2838a19d..2e4e27a7 100644 --- a/pkg/server/mailer/backend_test.go +++ b/pkg/server/mailer/backend_test.go @@ -31,40 +31,28 @@ func (m *mockDialer) DialAndSend(msgs ...*gomail.Message) error { return m.err } -func TestDefaultBackendQueue(t *testing.T) { - t.Run("enabled sends email", func(t *testing.T) { +func TestDefaultBackendSendEmail(t *testing.T) { + t.Run("sends email", func(t *testing.T) { mock := &mockDialer{} backend := &DefaultBackend{ - Dialer: mock, - Enabled: true, + Dialer: mock, + Templates: NewTemplates(), } - err := backend.Queue("Test Subject", "alice@example.com", []string{"bob@example.com"}, "text/plain", "Test body") + data := WelcomeTmplData{ + AccountEmail: "bob@example.com", + WebURL: "https://example.com", + } + + err := backend.SendEmail(EmailTypeWelcome, "alice@example.com", []string{"bob@example.com"}, data) if err != nil { - t.Fatalf("Queue failed: %v", err) + t.Fatalf("SendEmail failed: %v", err) } if len(mock.sentMessages) != 1 { t.Errorf("expected 1 message sent, got %d", len(mock.sentMessages)) } }) - - t.Run("disabled does not send email", func(t *testing.T) { - mock := &mockDialer{} - backend := &DefaultBackend{ - Dialer: mock, - Enabled: false, - } - - err := backend.Queue("Test Subject", "alice@example.com", []string{"bob@example.com"}, "text/plain", "Test body") - if err != nil { - t.Fatalf("Queue failed: %v", err) - } - - if len(mock.sentMessages) != 0 { - t.Errorf("expected 0 messages sent when disabled, got %d", len(mock.sentMessages)) - } - }) } func TestNewDefaultBackend(t *testing.T) { @@ -74,14 +62,11 @@ func TestNewDefaultBackend(t *testing.T) { t.Setenv("SmtpUsername", "user@example.com") t.Setenv("SmtpPassword", "secret") - backend, err := NewDefaultBackend(true) + backend, err := NewDefaultBackend() if err != nil { t.Fatalf("NewDefaultBackend failed: %v", err) } - if backend.Enabled != true { - t.Errorf("expected Enabled to be true, got %v", backend.Enabled) - } if backend.Dialer == nil { t.Error("expected Dialer to be set") } @@ -93,7 +78,7 @@ func TestNewDefaultBackend(t *testing.T) { t.Setenv("SmtpUsername", "") t.Setenv("SmtpPassword", "") - _, err := NewDefaultBackend(true) + _, err := NewDefaultBackend() if err == nil { t.Error("expected error when SMTP not configured") } @@ -102,3 +87,21 @@ func TestNewDefaultBackend(t *testing.T) { } }) } + +func TestStdoutBackendSendEmail(t *testing.T) { + t.Run("logs email without sending", func(t *testing.T) { + backend := NewStdoutBackend() + + data := WelcomeTmplData{ + AccountEmail: "bob@example.com", + WebURL: "https://example.com", + } + + err := backend.SendEmail(EmailTypeWelcome, "alice@example.com", []string{"bob@example.com"}, data) + if err != nil { + t.Fatalf("SendEmail failed: %v", err) + } + + // StdoutBackend should never return an error, just log + }) +} diff --git a/pkg/server/mailer/mailer.go b/pkg/server/mailer/mailer.go index 10457252..18887cf5 100644 --- a/pkg/server/mailer/mailer.go +++ b/pkg/server/mailer/mailer.go @@ -40,13 +40,19 @@ var ( EmailKindText = "text/plain" ) -// template is the common interface shared between Template from +// tmpl is the common interface shared between Template from // html/template and text/template -type template interface { +type tmpl interface { Execute(wr io.Writer, data interface{}) error } -// Templates holds the parsed email templates +// template wraps a template with its subject line +type template struct { + tmpl tmpl + subject string +} + +// Templates holds the parsed email templates with their subjects type Templates map[string]template func getTemplateKey(name, kind string) string { @@ -56,16 +62,19 @@ func getTemplateKey(name, kind string) string { func (tmpl Templates) get(name, kind string) (template, error) { key := getTemplateKey(name, kind) t := tmpl[key] - if t == nil { - return nil, errors.Errorf("unsupported template '%s' with type '%s'", name, kind) + if t.tmpl == nil { + return template{}, errors.Errorf("unsupported template '%s' with type '%s'", name, kind) } return t, nil } -func (tmpl Templates) set(name, kind string, t template) { +func (tmpl Templates) set(name, kind string, t tmpl, subject string) { key := getTemplateKey(name, kind) - tmpl[key] = t + tmpl[key] = template{ + tmpl: t, + subject: subject, + } } // NewTemplates initializes templates @@ -84,15 +93,15 @@ func NewTemplates() Templates { } T := Templates{} - T.set(EmailTypeResetPassword, EmailKindText, passwordResetText) - T.set(EmailTypeResetPasswordAlert, EmailKindText, passwordResetAlertText) - T.set(EmailTypeWelcome, EmailKindText, welcomeText) + T.set(EmailTypeResetPassword, EmailKindText, passwordResetText, "Reset your Dnote password") + T.set(EmailTypeResetPasswordAlert, EmailKindText, passwordResetAlertText, "Your Dnote password was changed") + T.set(EmailTypeWelcome, EmailKindText, welcomeText, "Welcome to Dnote!") return T } // initTextTmpl returns a template instance by parsing the template with the given name -func initTextTmpl(templateName string) (template, error) { +func initTextTmpl(templateName string) (tmpl, error) { filename := fmt.Sprintf("%s.txt", templateName) content, err := templates.Files.ReadFile(filename) @@ -108,17 +117,17 @@ func initTextTmpl(templateName string) (template, error) { return t, nil } -// Execute executes the template with the given name with the givn data -func (tmpl Templates) Execute(name, kind string, data any) (string, error) { +// Execute executes the template and returns the subject, body, and any error +func (tmpl Templates) Execute(name, kind string, data any) (subject, body string, err error) { t, err := tmpl.get(name, kind) if err != nil { - return "", errors.Wrap(err, "getting template") + return "", "", errors.Wrap(err, "getting template") } buf := new(bytes.Buffer) - if err := t.Execute(buf, data); err != nil { - return "", errors.Wrap(err, "executing the template") + if err := t.tmpl.Execute(buf, data); err != nil { + return "", "", errors.Wrap(err, "executing the template") } - return buf.String(), nil + return t.subject, buf.String(), nil } diff --git a/pkg/server/mailer/mailer_test.go b/pkg/server/mailer/mailer_test.go index e08c9c55..7f8ab383 100644 --- a/pkg/server/mailer/mailer_test.go +++ b/pkg/server/mailer/mailer_test.go @@ -65,11 +65,14 @@ func TestResetPasswordEmail(t *testing.T) { Token: tc.token, WebURL: tc.webURL, } - body, err := tmpl.Execute(EmailTypeResetPassword, EmailKindText, dat) + subject, body, err := tmpl.Execute(EmailTypeResetPassword, EmailKindText, dat) if err != nil { t.Fatal(errors.Wrap(err, "executing")) } + if subject != "Reset your Dnote password" { + t.Errorf("expected subject 'Reset your Dnote password', got '%s'", subject) + } if ok := strings.Contains(body, tc.webURL); !ok { t.Errorf("email body did not contain %s", tc.webURL) } @@ -103,11 +106,14 @@ func TestWelcomeEmail(t *testing.T) { AccountEmail: tc.accountEmail, WebURL: tc.webURL, } - body, err := tmpl.Execute(EmailTypeWelcome, EmailKindText, dat) + subject, body, err := tmpl.Execute(EmailTypeWelcome, EmailKindText, dat) if err != nil { t.Fatal(errors.Wrap(err, "executing")) } + if subject != "Welcome to Dnote!" { + t.Errorf("expected subject 'Welcome to Dnote!', got '%s'", subject) + } if ok := strings.Contains(body, tc.webURL); !ok { t.Errorf("email body did not contain %s", tc.webURL) } @@ -141,11 +147,14 @@ func TestResetPasswordAlertEmail(t *testing.T) { AccountEmail: tc.accountEmail, WebURL: tc.webURL, } - body, err := tmpl.Execute(EmailTypeResetPasswordAlert, EmailKindText, dat) + subject, body, err := tmpl.Execute(EmailTypeResetPasswordAlert, EmailKindText, dat) if err != nil { t.Fatal(errors.Wrap(err, "executing")) } + if subject != "Your Dnote password was changed" { + t.Errorf("expected subject 'Your Dnote password was changed', got '%s'", subject) + } if ok := strings.Contains(body, tc.webURL); !ok { t.Errorf("email body did not contain %s", tc.webURL) } diff --git a/pkg/server/middleware/limit.go b/pkg/server/middleware/limit.go index 6985809e..bc26664f 100644 --- a/pkg/server/middleware/limit.go +++ b/pkg/server/middleware/limit.go @@ -17,7 +17,6 @@ package middleware import ( "net/http" - "os" "strings" "sync" "time" @@ -143,7 +142,7 @@ func (rl *RateLimiter) Limit(next http.Handler) http.HandlerFunc { func ApplyLimit(h http.HandlerFunc, rateLimit bool) http.Handler { ret := h - if rateLimit && os.Getenv("APP_ENV") != "TEST" { + if rateLimit { ret = defaultLimiter.Limit(ret) } diff --git a/pkg/server/testutils/main.go b/pkg/server/testutils/main.go index dd10941e..8fce9ebf 100644 --- a/pkg/server/testutils/main.go +++ b/pkg/server/testutils/main.go @@ -210,10 +210,10 @@ func MustRespondJSON(t *testing.T, w http.ResponseWriter, i interface{}, message // MockEmail is a mock email data type MockEmail struct { - Subject string - From string - To []string - Body string + TemplateType string + From string + To []string + Data interface{} } // MockEmailbackendImplementation is an email backend that simply discards the emails @@ -230,16 +230,16 @@ func (b *MockEmailbackendImplementation) Clear() { b.Emails = []MockEmail{} } -// Queue is an implementation of Backend.Queue. -func (b *MockEmailbackendImplementation) Queue(subject, from string, to []string, contentType, body string) error { +// SendEmail is an implementation of Backend.SendEmail. +func (b *MockEmailbackendImplementation) SendEmail(templateType, from string, to []string, data interface{}) error { b.mu.Lock() defer b.mu.Unlock() b.Emails = append(b.Emails, MockEmail{ - Subject: subject, - From: from, - To: to, - Body: body, + TemplateType: templateType, + From: from, + To: to, + Data: data, }) return nil diff --git a/scripts/server/dev.sh b/scripts/server/dev.sh index 7e1fe80e..3786f270 100755 --- a/scripts/server/dev.sh +++ b/scripts/server/dev.sh @@ -7,11 +7,8 @@ dir=$(dirname "${BASH_SOURCE[0]}") basePath="$dir/../.." serverPath="$basePath/pkg/server" -# load env -set -a -dotenvPath="$serverPath/.env.dev" -source "$dotenvPath" -set +a +# Set env +DBPath=../../dev-server.db # copy assets mkdir -p "$basePath/pkg/server/static" From ce5c9b242aae1428d5cec579ad70e04afa376d5c Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 1 Nov 2025 00:57:37 -0700 Subject: [PATCH 27/33] Rename webUrl to baseUrl (#711) --- pkg/e2e/server_test.go | 10 ++-- pkg/server/app/app.go | 10 ++-- pkg/server/app/email.go | 22 ++++---- pkg/server/app/email_test.go | 12 ++--- pkg/server/app/testutils.go | 2 +- pkg/server/cmd/helpers.go | 2 +- pkg/server/cmd/start.go | 4 +- pkg/server/config/config.go | 14 +++--- pkg/server/config/config_test.go | 18 +++---- pkg/server/mailer/backend_test.go | 4 +- pkg/server/mailer/mailer_test.go | 50 +++++++++---------- .../mailer/templates/reset_password.txt | 2 +- .../mailer/templates/reset_password_alert.txt | 2 +- pkg/server/mailer/templates/welcome.txt | 4 +- pkg/server/mailer/types.go | 6 +-- 15 files changed, 81 insertions(+), 81 deletions(-) diff --git a/pkg/e2e/server_test.go b/pkg/e2e/server_test.go index b7a17b2d..7c646e8d 100644 --- a/pkg/e2e/server_test.go +++ b/pkg/e2e/server_test.go @@ -139,15 +139,15 @@ func TestServerStartHelp(t *testing.T) { outputStr := string(output) assert.Equal(t, strings.Contains(outputStr, "dnote-server start [flags]"), true, "output should contain usage") assert.Equal(t, strings.Contains(outputStr, "--port"), true, "output should contain port flag") - assert.Equal(t, strings.Contains(outputStr, "--webUrl"), true, "output should contain webUrl flag") + assert.Equal(t, strings.Contains(outputStr, "--baseUrl"), true, "output should contain baseUrl flag") assert.Equal(t, strings.Contains(outputStr, "--dbPath"), true, "output should contain dbPath flag") assert.Equal(t, strings.Contains(outputStr, "--disableRegistration"), true, "output should contain disableRegistration flag") } func TestServerStartInvalidConfig(t *testing.T) { cmd := exec.Command(testServerBinary, "start") - // Set invalid WebURL to trigger validation failure - cmd.Env = []string{"WebURL=not-a-valid-url"} + // Set invalid BaseURL to trigger validation failure + cmd.Env = []string{"BaseURL=not-a-valid-url"} output, err := cmd.CombinedOutput() @@ -158,9 +158,9 @@ func TestServerStartInvalidConfig(t *testing.T) { outputStr := string(output) assert.Equal(t, strings.Contains(outputStr, "Error:"), true, "output should contain error message") - assert.Equal(t, strings.Contains(outputStr, "Invalid WebURL"), true, "output should mention invalid WebURL") + assert.Equal(t, strings.Contains(outputStr, "Invalid BaseURL"), true, "output should mention invalid BaseURL") assert.Equal(t, strings.Contains(outputStr, "dnote-server start [flags]"), true, "output should show usage") - assert.Equal(t, strings.Contains(outputStr, "--webUrl"), true, "output should show flags") + assert.Equal(t, strings.Contains(outputStr, "--baseUrl"), true, "output should show flags") } func TestServerUnknownCommand(t *testing.T) { diff --git a/pkg/server/app/app.go b/pkg/server/app/app.go index 6a8c5d14..cfaaf319 100644 --- a/pkg/server/app/app.go +++ b/pkg/server/app/app.go @@ -27,8 +27,8 @@ var ( ErrEmptyDB = errors.New("No database connection was provided") // ErrEmptyClock is an error for missing clock in the app configuration ErrEmptyClock = errors.New("No clock was provided") - // ErrEmptyWebURL is an error for missing WebURL content in the app configuration - ErrEmptyWebURL = errors.New("No WebURL was provided") + // ErrEmptyBaseURL is an error for missing BaseURL content in the app configuration + ErrEmptyBaseURL = errors.New("No BaseURL was provided") // ErrEmptyEmailBackend is an error for missing EmailBackend content in the app configuration ErrEmptyEmailBackend = errors.New("No EmailBackend was provided") // ErrEmptyHTTP500Page is an error for missing HTTP 500 page content @@ -42,7 +42,7 @@ type App struct { EmailBackend mailer.Backend Files map[string][]byte HTTP500Page []byte - WebURL string + BaseURL string DisableRegistration bool Port string DBPath string @@ -51,8 +51,8 @@ type App struct { // Validate validates the app configuration func (a *App) Validate() error { - if a.WebURL == "" { - return ErrEmptyWebURL + if a.BaseURL == "" { + return ErrEmptyBaseURL } if a.Clock == nil { return ErrEmptyClock diff --git a/pkg/server/app/email.go b/pkg/server/app/email.go index 1b78f722..fc86cda9 100644 --- a/pkg/server/app/email.go +++ b/pkg/server/app/email.go @@ -27,8 +27,8 @@ import ( var defaultSender = "admin@getdnote.com" // GetSenderEmail returns the sender email -func GetSenderEmail(webURL, want string) (string, error) { - addr, err := getNoreplySender(webURL) +func GetSenderEmail(baseURL, want string) (string, error) { + addr, err := getNoreplySender(baseURL) if err != nil { return "", errors.Wrap(err, "getting sender email address") } @@ -52,10 +52,10 @@ func getDomainFromURL(rawURL string) (string, error) { return domain, nil } -func getNoreplySender(webURL string) (string, error) { - domain, err := getDomainFromURL(webURL) +func getNoreplySender(baseURL string) (string, error) { + domain, err := getDomainFromURL(baseURL) if err != nil { - return "", errors.Wrap(err, "parsing web url") + return "", errors.Wrap(err, "parsing base url") } addr := fmt.Sprintf("noreply@%s", domain) @@ -64,14 +64,14 @@ func getNoreplySender(webURL string) (string, error) { // SendWelcomeEmail sends welcome email func (a *App) SendWelcomeEmail(email string) error { - from, err := GetSenderEmail(a.WebURL, defaultSender) + from, err := GetSenderEmail(a.BaseURL, defaultSender) if err != nil { return errors.Wrap(err, "getting the sender email") } data := mailer.WelcomeTmplData{ AccountEmail: email, - WebURL: a.WebURL, + BaseURL: a.BaseURL, } if err := a.EmailBackend.SendEmail(mailer.EmailTypeWelcome, from, []string{email}, data); err != nil { @@ -87,7 +87,7 @@ func (a *App) SendPasswordResetEmail(email, tokenValue string) error { return ErrEmailRequired } - from, err := GetSenderEmail(a.WebURL, defaultSender) + from, err := GetSenderEmail(a.BaseURL, defaultSender) if err != nil { return errors.Wrap(err, "getting the sender email") } @@ -95,7 +95,7 @@ func (a *App) SendPasswordResetEmail(email, tokenValue string) error { data := mailer.EmailResetPasswordTmplData{ AccountEmail: email, Token: tokenValue, - WebURL: a.WebURL, + BaseURL: a.BaseURL, } if err := a.EmailBackend.SendEmail(mailer.EmailTypeResetPassword, from, []string{email}, data); err != nil { @@ -111,14 +111,14 @@ func (a *App) SendPasswordResetEmail(email, tokenValue string) error { // SendPasswordResetAlertEmail sends email that notifies users of a password change func (a *App) SendPasswordResetAlertEmail(email string) error { - from, err := GetSenderEmail(a.WebURL, defaultSender) + from, err := GetSenderEmail(a.BaseURL, defaultSender) if err != nil { return errors.Wrap(err, "getting the sender email") } data := mailer.EmailResetPasswordAlertTmplData{ AccountEmail: email, - WebURL: a.WebURL, + BaseURL: a.BaseURL, } if err := a.EmailBackend.SendEmail(mailer.EmailTypeResetPasswordAlert, from, []string{email}, data); err != nil { diff --git a/pkg/server/app/email_test.go b/pkg/server/app/email_test.go index 31d284e7..e0a73aef 100644 --- a/pkg/server/app/email_test.go +++ b/pkg/server/app/email_test.go @@ -27,7 +27,7 @@ func TestSendWelcomeEmail(t *testing.T) { emailBackend := testutils.MockEmailbackendImplementation{} a := NewTest() a.EmailBackend = &emailBackend - a.WebURL = "http://example.com" + a.BaseURL = "http://example.com" if err := a.SendWelcomeEmail("alice@example.com"); err != nil { t.Fatal(err, "failed to perform") @@ -43,7 +43,7 @@ func TestSendPasswordResetEmail(t *testing.T) { emailBackend := testutils.MockEmailbackendImplementation{} a := NewTest() a.EmailBackend = &emailBackend - a.WebURL = "http://example.com" + a.BaseURL = "http://example.com" if err := a.SendPasswordResetEmail("alice@example.com", "mockTokenValue"); err != nil { t.Fatal(err, "failed to perform") @@ -57,21 +57,21 @@ func TestSendPasswordResetEmail(t *testing.T) { func TestGetSenderEmail(t *testing.T) { testCases := []struct { - webURL string + baseURL string expectedSender string }{ { - webURL: "https://www.example.com", + baseURL: "https://www.example.com", expectedSender: "noreply@example.com", }, { - webURL: "https://www.example2.com", + baseURL: "https://www.example2.com", expectedSender: "alice@example2.com", }, } for _, tc := range testCases { - t.Run(fmt.Sprintf("web url %s", tc.webURL), func(t *testing.T) { + t.Run(fmt.Sprintf("base url %s", tc.baseURL), func(t *testing.T) { }) } } diff --git a/pkg/server/app/testutils.go b/pkg/server/app/testutils.go index 48896cdc..248f4784 100644 --- a/pkg/server/app/testutils.go +++ b/pkg/server/app/testutils.go @@ -27,7 +27,7 @@ func NewTest() App { Clock: clock.NewMock(), EmailBackend: &testutils.MockEmailbackendImplementation{}, HTTP500Page: assets.MustGetHTTP500ErrorPage(), - WebURL: "http://127.0.0.0.1", + BaseURL: "http://127.0.0.0.1", Port: "3000", DisableRegistration: false, DBPath: "", diff --git a/pkg/server/cmd/helpers.go b/pkg/server/cmd/helpers.go index 3c135372..2a322476 100644 --- a/pkg/server/cmd/helpers.go +++ b/pkg/server/cmd/helpers.go @@ -57,7 +57,7 @@ func initApp(cfg config.Config) app.App { Clock: clock.New(), EmailBackend: emailBackend, HTTP500Page: cfg.HTTP500Page, - WebURL: cfg.WebURL, + BaseURL: cfg.BaseURL, DisableRegistration: cfg.DisableRegistration, Port: cfg.Port, DBPath: cfg.DBPath, diff --git a/pkg/server/cmd/start.go b/pkg/server/cmd/start.go index 465f41ce..0a4e5292 100644 --- a/pkg/server/cmd/start.go +++ b/pkg/server/cmd/start.go @@ -33,7 +33,7 @@ func startCmd(args []string) { fs := setupFlagSet("start", "dnote-server start") port := fs.String("port", "", "Server port (env: PORT, default: 3001)") - webURL := fs.String("webUrl", "", "Full URL to server without trailing slash (env: WebURL, default: http://localhost:3001)") + baseURL := fs.String("baseUrl", "", "Full URL to server without trailing slash (env: BaseURL, default: http://localhost:3001)") dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") disableRegistration := fs.Bool("disableRegistration", false, "Disable user registration (env: DisableRegistration, default: false)") logLevel := fs.String("logLevel", "", "Log level: debug, info, warn, or error (env: LOG_LEVEL, default: info)") @@ -42,7 +42,7 @@ func startCmd(args []string) { cfg, err := config.New(config.Params{ Port: *port, - WebURL: *webURL, + BaseURL: *baseURL, DBPath: *dbPath, DisableRegistration: *disableRegistration, LogLevel: *logLevel, diff --git a/pkg/server/config/config.go b/pkg/server/config/config.go index 88b604bc..19ee45f2 100644 --- a/pkg/server/config/config.go +++ b/pkg/server/config/config.go @@ -40,8 +40,8 @@ var ( var ( // ErrDBMissingPath is an error for an incomplete configuration missing the database path ErrDBMissingPath = errors.New("DB Path is empty") - // ErrWebURLInvalid is an error for an incomplete configuration with invalid web url - ErrWebURLInvalid = errors.New("Invalid WebURL") + // ErrBaseURLInvalid is an error for an incomplete configuration with invalid base url + ErrBaseURLInvalid = errors.New("Invalid BaseURL") // ErrPortInvalid is an error for an incomplete configuration with invalid port ErrPortInvalid = errors.New("Invalid Port") ) @@ -63,7 +63,7 @@ func getOrEnv(value, envKey, defaultVal string) string { // Config is an application configuration type Config struct { - WebURL string + BaseURL string DisableRegistration bool Port string DBPath string @@ -75,7 +75,7 @@ type Config struct { // Params are the configuration parameters for creating a new Config type Params struct { Port string - WebURL string + BaseURL string DBPath string DisableRegistration bool LogLevel string @@ -86,7 +86,7 @@ type Params struct { func New(p Params) (Config, error) { c := Config{ Port: getOrEnv(p.Port, "PORT", "3001"), - WebURL: getOrEnv(p.WebURL, "WebURL", "http://localhost:3001"), + BaseURL: getOrEnv(p.BaseURL, "BaseURL", "http://localhost:3001"), DBPath: getOrEnv(p.DBPath, "DBPath", DefaultDBPath), DisableRegistration: p.DisableRegistration || readBoolEnv("DisableRegistration"), LogLevel: getOrEnv(p.LogLevel, "LOG_LEVEL", "info"), @@ -102,8 +102,8 @@ func New(p Params) (Config, error) { } func validate(c Config) error { - if _, err := url.ParseRequestURI(c.WebURL); err != nil { - return errors.Wrapf(ErrWebURLInvalid, "'%s'", c.WebURL) + if _, err := url.ParseRequestURI(c.BaseURL); err != nil { + return errors.Wrapf(ErrBaseURLInvalid, "'%s'", c.BaseURL) } if c.Port == "" { return ErrPortInvalid diff --git a/pkg/server/config/config_test.go b/pkg/server/config/config_test.go index 8b76c07b..9c3c1baa 100644 --- a/pkg/server/config/config_test.go +++ b/pkg/server/config/config_test.go @@ -30,17 +30,17 @@ func TestValidate(t *testing.T) { }{ { config: Config{ - DBPath: "test.db", - WebURL: "http://mock.url", - Port: "3000", + DBPath: "test.db", + BaseURL: "http://mock.url", + Port: "3000", }, expectedErr: nil, }, { config: Config{ - DBPath: "", - WebURL: "http://mock.url", - Port: "3000", + DBPath: "", + BaseURL: "http://mock.url", + Port: "3000", }, expectedErr: ErrDBMissingPath, }, @@ -48,12 +48,12 @@ func TestValidate(t *testing.T) { config: Config{ DBPath: "test.db", }, - expectedErr: ErrWebURLInvalid, + expectedErr: ErrBaseURLInvalid, }, { config: Config{ - DBPath: "test.db", - WebURL: "http://mock.url", + DBPath: "test.db", + BaseURL: "http://mock.url", }, expectedErr: ErrPortInvalid, }, diff --git a/pkg/server/mailer/backend_test.go b/pkg/server/mailer/backend_test.go index 2e4e27a7..2388c16b 100644 --- a/pkg/server/mailer/backend_test.go +++ b/pkg/server/mailer/backend_test.go @@ -41,7 +41,7 @@ func TestDefaultBackendSendEmail(t *testing.T) { data := WelcomeTmplData{ AccountEmail: "bob@example.com", - WebURL: "https://example.com", + BaseURL: "https://example.com", } err := backend.SendEmail(EmailTypeWelcome, "alice@example.com", []string{"bob@example.com"}, data) @@ -94,7 +94,7 @@ func TestStdoutBackendSendEmail(t *testing.T) { data := WelcomeTmplData{ AccountEmail: "bob@example.com", - WebURL: "https://example.com", + BaseURL: "https://example.com", } err := backend.SendEmail(EmailTypeWelcome, "alice@example.com", []string{"bob@example.com"}, data) diff --git a/pkg/server/mailer/mailer_test.go b/pkg/server/mailer/mailer_test.go index 7f8ab383..71b48209 100644 --- a/pkg/server/mailer/mailer_test.go +++ b/pkg/server/mailer/mailer_test.go @@ -44,26 +44,26 @@ func TestAllTemplatesInitialized(t *testing.T) { func TestResetPasswordEmail(t *testing.T) { testCases := []struct { - token string - webURL string + token string + baseURL string }{ { - token: "someRandomToken1", - webURL: "http://localhost:3000", + token: "someRandomToken1", + baseURL: "http://localhost:3000", }, { - token: "someRandomToken2", - webURL: "http://localhost:3001", + token: "someRandomToken2", + baseURL: "http://localhost:3001", }, } tmpl := NewTemplates() for _, tc := range testCases { - t.Run(fmt.Sprintf("with WebURL %s", tc.webURL), func(t *testing.T) { + t.Run(fmt.Sprintf("with BaseURL %s", tc.baseURL), func(t *testing.T) { dat := EmailResetPasswordTmplData{ - Token: tc.token, - WebURL: tc.webURL, + Token: tc.token, + BaseURL: tc.baseURL, } subject, body, err := tmpl.Execute(EmailTypeResetPassword, EmailKindText, dat) if err != nil { @@ -73,8 +73,8 @@ func TestResetPasswordEmail(t *testing.T) { if subject != "Reset your Dnote password" { t.Errorf("expected subject 'Reset your Dnote password', got '%s'", subject) } - if ok := strings.Contains(body, tc.webURL); !ok { - t.Errorf("email body did not contain %s", tc.webURL) + if ok := strings.Contains(body, tc.baseURL); !ok { + t.Errorf("email body did not contain %s", tc.baseURL) } if ok := strings.Contains(body, tc.token); !ok { t.Errorf("email body did not contain %s", tc.token) @@ -86,25 +86,25 @@ func TestResetPasswordEmail(t *testing.T) { func TestWelcomeEmail(t *testing.T) { testCases := []struct { accountEmail string - webURL string + baseURL string }{ { accountEmail: "test@example.com", - webURL: "http://localhost:3000", + baseURL: "http://localhost:3000", }, { accountEmail: "user@example.org", - webURL: "http://localhost:3001", + baseURL: "http://localhost:3001", }, } tmpl := NewTemplates() for _, tc := range testCases { - t.Run(fmt.Sprintf("with WebURL %s and email %s", tc.webURL, tc.accountEmail), func(t *testing.T) { + t.Run(fmt.Sprintf("with BaseURL %s and email %s", tc.baseURL, tc.accountEmail), func(t *testing.T) { dat := WelcomeTmplData{ AccountEmail: tc.accountEmail, - WebURL: tc.webURL, + BaseURL: tc.baseURL, } subject, body, err := tmpl.Execute(EmailTypeWelcome, EmailKindText, dat) if err != nil { @@ -114,8 +114,8 @@ func TestWelcomeEmail(t *testing.T) { if subject != "Welcome to Dnote!" { t.Errorf("expected subject 'Welcome to Dnote!', got '%s'", subject) } - if ok := strings.Contains(body, tc.webURL); !ok { - t.Errorf("email body did not contain %s", tc.webURL) + if ok := strings.Contains(body, tc.baseURL); !ok { + t.Errorf("email body did not contain %s", tc.baseURL) } if ok := strings.Contains(body, tc.accountEmail); !ok { t.Errorf("email body did not contain %s", tc.accountEmail) @@ -127,25 +127,25 @@ func TestWelcomeEmail(t *testing.T) { func TestResetPasswordAlertEmail(t *testing.T) { testCases := []struct { accountEmail string - webURL string + baseURL string }{ { accountEmail: "test@example.com", - webURL: "http://localhost:3000", + baseURL: "http://localhost:3000", }, { accountEmail: "user@example.org", - webURL: "http://localhost:3001", + baseURL: "http://localhost:3001", }, } tmpl := NewTemplates() for _, tc := range testCases { - t.Run(fmt.Sprintf("with WebURL %s and email %s", tc.webURL, tc.accountEmail), func(t *testing.T) { + t.Run(fmt.Sprintf("with BaseURL %s and email %s", tc.baseURL, tc.accountEmail), func(t *testing.T) { dat := EmailResetPasswordAlertTmplData{ AccountEmail: tc.accountEmail, - WebURL: tc.webURL, + BaseURL: tc.baseURL, } subject, body, err := tmpl.Execute(EmailTypeResetPasswordAlert, EmailKindText, dat) if err != nil { @@ -155,8 +155,8 @@ func TestResetPasswordAlertEmail(t *testing.T) { if subject != "Your Dnote password was changed" { t.Errorf("expected subject 'Your Dnote password was changed', got '%s'", subject) } - if ok := strings.Contains(body, tc.webURL); !ok { - t.Errorf("email body did not contain %s", tc.webURL) + if ok := strings.Contains(body, tc.baseURL); !ok { + t.Errorf("email body did not contain %s", tc.baseURL) } if ok := strings.Contains(body, tc.accountEmail); !ok { t.Errorf("email body did not contain %s", tc.accountEmail) diff --git a/pkg/server/mailer/templates/reset_password.txt b/pkg/server/mailer/templates/reset_password.txt index 9053a493..9d31d605 100644 --- a/pkg/server/mailer/templates/reset_password.txt +++ b/pkg/server/mailer/templates/reset_password.txt @@ -2,4 +2,4 @@ You are receiving this because you requested to reset the password of the '{{ .A Please click on the following link, or paste this into your browser to complete the process: - {{ .WebURL }}/password-reset/{{ .Token }} + {{ .BaseURL }}/password-reset/{{ .Token }} diff --git a/pkg/server/mailer/templates/reset_password_alert.txt b/pkg/server/mailer/templates/reset_password_alert.txt index 16957375..ea67dce3 100644 --- a/pkg/server/mailer/templates/reset_password_alert.txt +++ b/pkg/server/mailer/templates/reset_password_alert.txt @@ -2,7 +2,7 @@ Hi, This email is to notify you that the password for your Dnote account "{{ .AccountEmail }}" has changed. -If you did not initiate this password change, reset your password at {{ .WebURL }}/password-reset. +If you did not initiate this password change, reset your password at {{ .BaseURL }}/password-reset. Thanks. diff --git a/pkg/server/mailer/templates/welcome.txt b/pkg/server/mailer/templates/welcome.txt index 72d0fdf0..cced536c 100644 --- a/pkg/server/mailer/templates/welcome.txt +++ b/pkg/server/mailer/templates/welcome.txt @@ -4,8 +4,8 @@ Dnote is a simple command-line notebook. YOUR ACCOUNT -Your {{ .WebURL }} account is "{{ .AccountEmail }}". Log in at {{ .WebURL }}/login -If you ever forget your password, you can reset it at {{ .WebURL }}/password-reset +Your {{ .BaseURL }} account is "{{ .AccountEmail }}". Log in at {{ .BaseURL }}/login +If you ever forget your password, you can reset it at {{ .BaseURL }}/password-reset SOURCE CODE diff --git a/pkg/server/mailer/types.go b/pkg/server/mailer/types.go index 17363398..40468b84 100644 --- a/pkg/server/mailer/types.go +++ b/pkg/server/mailer/types.go @@ -19,17 +19,17 @@ package mailer type EmailResetPasswordTmplData struct { AccountEmail string Token string - WebURL string + BaseURL string } // EmailResetPasswordAlertTmplData is a template data for reset password emails type EmailResetPasswordAlertTmplData struct { AccountEmail string - WebURL string + BaseURL string } // WelcomeTmplData is a template data for welcome emails type WelcomeTmplData struct { AccountEmail string - WebURL string + BaseURL string } From f1d7123596f0b3f67643c01db742adaa3e8dd265 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 1 Nov 2025 14:06:33 -0700 Subject: [PATCH 28/33] Fix log level (#712) --- README.md | 10 +++- pkg/server/database/database.go | 4 +- pkg/server/database/database_test.go | 70 ++++++++++++++++++++++++++++ pkg/server/log/log.go | 46 +++++++++++------- pkg/server/log/log_test.go | 44 +++++++++++++++++ scripts/license.sh | 16 +++---- 6 files changed, 160 insertions(+), 30 deletions(-) create mode 100644 pkg/server/database/database_test.go diff --git a/README.md b/README.md index fbe46e26..7ab0063f 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ Or [download binary](https://github.com/dnote/dnote/releases). ## Server (Optional) -Just run a binary. No database setup required. +Server is a binary with SQLite embedded. No database setup is required. -Run with Docker Compose using [compose.yml](./host/docker/compose.yml): +If using docker, create a compose.yml: ```yaml services: @@ -51,6 +51,12 @@ services: restart: unless-stopped ``` +Then run: + +```bash +docker-compose up -d +``` + Or see the [guide](https://www.getdnote.com/docs/server/manual) for binary installation. ## Documentation diff --git a/pkg/server/database/database.go b/pkg/server/database/database.go index cfb18ab7..bd7869bc 100644 --- a/pkg/server/database/database.go +++ b/pkg/server/database/database.go @@ -38,13 +38,13 @@ func getDBLogLevel(level string) logger.LogLevel { case log.LevelDebug: return logger.Info case log.LevelInfo: - return logger.Info + return logger.Silent case log.LevelWarn: return logger.Warn case log.LevelError: return logger.Error default: - return logger.Error + return logger.Silent } } diff --git a/pkg/server/database/database_test.go b/pkg/server/database/database_test.go new file mode 100644 index 00000000..3d3f5b92 --- /dev/null +++ b/pkg/server/database/database_test.go @@ -0,0 +1,70 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package database + +import ( + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/server/log" + "gorm.io/gorm/logger" +) + +func TestGetDBLogLevel(t *testing.T) { + testCases := []struct { + name string + level string + expected logger.LogLevel + }{ + { + name: "debug level maps to Info", + level: log.LevelDebug, + expected: logger.Info, + }, + { + name: "info level maps to Silent", + level: log.LevelInfo, + expected: logger.Silent, + }, + { + name: "warn level maps to Warn", + level: log.LevelWarn, + expected: logger.Warn, + }, + { + name: "error level maps to Error", + level: log.LevelError, + expected: logger.Error, + }, + { + name: "unknown level maps to Silent", + level: "unknown", + expected: logger.Silent, + }, + { + name: "empty string maps to Silent", + level: "", + expected: logger.Silent, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result := getDBLogLevel(tc.level) + assert.Equal(t, result, tc.expected, "log level mismatch") + }) + } +} diff --git a/pkg/server/log/log.go b/pkg/server/log/log.go index d8b43c8b..172255ba 100644 --- a/pkg/server/log/log.go +++ b/pkg/server/log/log.go @@ -75,25 +75,35 @@ func GetLevel() string { return currentLevel } -// levelPriority returns a numeric priority for comparison -func levelPriority(level string) int { - switch level { - case LevelDebug: - return 0 - case LevelInfo: - return 1 - case LevelWarn: - return 2 - case LevelError: - return 3 - default: - return 1 - } -} - -// shouldLog returns true if the given level should be logged based on currentLevel +// shouldLog returns true if the given level should be logged based on currentLevel. +// +// Log level behavior (hierarchical): +// - LevelDebug: shows all messages (debug, info, warn, error) +// - LevelInfo: shows info, warn, and error messages +// - LevelWarn: shows warn and error messages +// - LevelError: shows only error messages func shouldLog(level string) bool { - return levelPriority(level) >= levelPriority(currentLevel) + // Debug level shows everything + if currentLevel == LevelDebug { + return true + } + + // Info level shows info + warn + error + if currentLevel == LevelInfo { + return level == LevelInfo || level == LevelWarn || level == LevelError + } + + // Warn level shows warn + error + if currentLevel == LevelWarn { + return level == LevelWarn || level == LevelError + } + + // Error level shows only error + if currentLevel == LevelError { + return level == LevelError + } + + return false } // Debug logs the given entry at a debug level diff --git a/pkg/server/log/log_test.go b/pkg/server/log/log_test.go index 488e3725..dd98c685 100644 --- a/pkg/server/log/log_test.go +++ b/pkg/server/log/log_test.go @@ -33,3 +33,47 @@ func TestSetLevel(t *testing.T) { t.Errorf("Expected level %s, got %s", LevelError, currentLevel) } } + +func TestShouldLog(t *testing.T) { + // Reset to default after test + defer SetLevel(LevelInfo) + + testCases := []struct { + currentLevel string + logLevel string + expected bool + description string + }{ + // Debug level shows everything + {LevelDebug, LevelDebug, true, "debug level should show debug"}, + {LevelDebug, LevelInfo, true, "debug level should show info"}, + {LevelDebug, LevelWarn, true, "debug level should show warn"}, + {LevelDebug, LevelError, true, "debug level should show error"}, + + // Info level shows info + warn + error + {LevelInfo, LevelDebug, false, "info level should not show debug"}, + {LevelInfo, LevelInfo, true, "info level should show info"}, + {LevelInfo, LevelWarn, true, "info level should show warn"}, + {LevelInfo, LevelError, true, "info level should show error"}, + + // Warn level shows warn + error + {LevelWarn, LevelDebug, false, "warn level should not show debug"}, + {LevelWarn, LevelInfo, false, "warn level should not show info"}, + {LevelWarn, LevelWarn, true, "warn level should show warn"}, + {LevelWarn, LevelError, true, "warn level should show error"}, + + // Error level shows only error + {LevelError, LevelDebug, false, "error level should not show debug"}, + {LevelError, LevelInfo, false, "error level should not show info"}, + {LevelError, LevelWarn, false, "error level should not show warn"}, + {LevelError, LevelError, true, "error level should show error"}, + } + + for _, tc := range testCases { + SetLevel(tc.currentLevel) + result := shouldLog(tc.logLevel) + if result != tc.expected { + t.Errorf("%s: expected %v, got %v", tc.description, tc.expected, result) + } + } +} diff --git a/scripts/license.sh b/scripts/license.sh index 4f96780c..4f7788e4 100755 --- a/scripts/license.sh +++ b/scripts/license.sh @@ -1,11 +1,9 @@ #!/usr/bin/env bash set -eux -function remove_notice { - # Remove old copyright notice - matches /* Copyright ... */ including the trailing newline - # The 's' flag makes . match newlines, allowing multi-line matching - # The \n? matches an optional newline after the closing */ - perl -i -0pe 's/\/\* Copyright.*?\*\/\n?//s' "$1" +function has_license { + # Check if file already has a copyright notice + grep -q "Copyright.*Dnote Authors" "$1" } function add_notice { @@ -18,7 +16,8 @@ q END } -license="/* Copyright 2025 Dnote Authors +year=$(date +%Y) +license="/* Copyright $year Dnote Authors * * Licensed under the Apache License, Version 2.0 (the \"License\"); * you may not use this file except in compliance with the License. @@ -41,6 +40,7 @@ pkgPath="$basedir/pkg" allFiles=$(find "$pkgPath" -type f \( -name "*.go" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.scss" -o -name "*.css" \) ! -path "**/vendor/*" ! -path "**/node_modules/*" ! -path "**/dist/*") for file in $allFiles; do - remove_notice "$file" - add_notice "$file" "$license" + if ! has_license "$file"; then + add_notice "$file" "$license" + fi done From d5e11c23f6010708dde32d7774956fe31030a201 Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 1 Nov 2025 19:20:18 -0700 Subject: [PATCH 29/33] Update self-hosting doc (#713) --- SELF_HOSTING.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/SELF_HOSTING.md b/SELF_HOSTING.md index 3638cb01..e67df891 100644 --- a/SELF_HOSTING.md +++ b/SELF_HOSTING.md @@ -6,27 +6,28 @@ Please see the [doc](https://www.getdnote.com/docs/server) for more. 1. Install [Docker](https://docs.docker.com/install/). 2. Install Docker [Compose plugin](https://docs.docker.com/compose/install/linux/). -3. Download the [compose.yml](https://raw.githubusercontent.com/dnote/dnote/master/host/docker/compose.yml) file by running: +3. Create a `compose.yml` file with the following content: -``` -curl https://raw.githubusercontent.com/dnote/dnote/master/host/docker/compose.yml > compose.yml +```yaml +services: + dnote: + image: dnote/dnote:latest + container_name: dnote + ports: + - 3001:3001 + volumes: + - ./dnote_data:/data + restart: unless-stopped ``` -4. Run the following to download the images and run the containers +4. Run the following to download the image and start the container ``` -docker compose pull docker compose up -d ``` Visit http://localhost:3001 in your browser to see Dnote running. -### Supported platform - -Currently, the official Docker image for Dnote supports Linux running AMD64 CPU architecture. - -If you run ARM64, please install Dnote server by downloading a binary distribution (see below). - ## Manual Installation Download from [releases](https://github.com/dnote/dnote/releases), extract, and run: @@ -34,7 +35,7 @@ Download from [releases](https://github.com/dnote/dnote/releases), extract, and ```bash tar -xzf dnote-server-$version-$os.tar.gz mv ./dnote-server /usr/local/bin -dnote-server start --webUrl=https://your.server +dnote-server start --baseUrl=https://your.server ``` You're up and running. Database: `~/.local/share/dnote/server.db` (customize with `--dbPath`). Run `dnote-server start --help` for options. From 5c416e3a327e55d9b20b987611e6cd032243008b Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Sat, 1 Nov 2025 19:59:51 -0700 Subject: [PATCH 30/33] Add user list command (#714) --- pkg/e2e/server_test.go | 20 +++++++++++ pkg/server/app/users.go | 11 ++++++ pkg/server/app/users_test.go | 66 ++++++++++++++++++++++++++++++++++++ pkg/server/cmd/helpers.go | 4 +-- pkg/server/cmd/user.go | 31 +++++++++++++++-- pkg/server/cmd/user_test.go | 49 ++++++++++++++++++++++++++ 6 files changed, 176 insertions(+), 5 deletions(-) diff --git a/pkg/e2e/server_test.go b/pkg/e2e/server_test.go index 7c646e8d..e8ca3da6 100644 --- a/pkg/e2e/server_test.go +++ b/pkg/e2e/server_test.go @@ -331,3 +331,23 @@ func TestServerUserCreateHelp(t *testing.T) { assert.Equal(t, strings.Contains(outputStr, "--password"), true, "help should show --password (double dash)") assert.Equal(t, strings.Contains(outputStr, "--dbPath"), true, "help should show --dbPath (double dash)") } + +func TestServerUserList(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Create two users + exec.Command(testServerBinary, "user", "create", "--dbPath", tmpDB, "--email", "alice@example.com", "--password", "password123").CombinedOutput() + exec.Command(testServerBinary, "user", "create", "--dbPath", tmpDB, "--email", "bob@example.com", "--password", "password123").CombinedOutput() + + // List users + listCmd := exec.Command(testServerBinary, "user", "list", "--dbPath", tmpDB) + output, err := listCmd.CombinedOutput() + + if err != nil { + t.Fatalf("user list failed: %v\nOutput: %s", err, output) + } + + outputStr := string(output) + assert.Equal(t, strings.Contains(outputStr, "alice@example.com"), true, "output should have alice") + assert.Equal(t, strings.Contains(outputStr, "bob@example.com"), true, "output should have bob") +} diff --git a/pkg/server/app/users.go b/pkg/server/app/users.go index 760b3354..9c167b69 100644 --- a/pkg/server/app/users.go +++ b/pkg/server/app/users.go @@ -116,6 +116,17 @@ func (a *App) GetUserByEmail(email string) (*database.User, error) { return &user, nil } +// GetAllUsers retrieves all users from the database +func (a *App) GetAllUsers() ([]database.User, error) { + var users []database.User + err := a.DB.Find(&users).Error + if err != nil { + return nil, pkgErrors.Wrap(err, "finding users") + } + + return users, nil +} + // Authenticate authenticates a user func (a *App) Authenticate(email, password string) (*database.User, error) { user, err := a.GetUserByEmail(email) diff --git a/pkg/server/app/users_test.go b/pkg/server/app/users_test.go index f345b217..52183520 100644 --- a/pkg/server/app/users_test.go +++ b/pkg/server/app/users_test.go @@ -108,6 +108,72 @@ func TestGetUserByEmail(t *testing.T) { }) } +func TestGetAllUsers(t *testing.T) { + t.Run("success with multiple users", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user1 := testutils.SetupUserData(db, "alice@example.com", "password123") + user2 := testutils.SetupUserData(db, "bob@example.com", "password123") + user3 := testutils.SetupUserData(db, "charlie@example.com", "password123") + + a := NewTest() + a.DB = db + + users, err := a.GetAllUsers() + + assert.Equal(t, err, nil, "should not error") + assert.Equal(t, len(users), 3, "should return 3 users") + + // Verify all users are returned + emails := make(map[string]bool) + for _, user := range users { + emails[user.Email.String] = true + } + assert.Equal(t, emails["alice@example.com"], true, "alice should be in results") + assert.Equal(t, emails["bob@example.com"], true, "bob should be in results") + assert.Equal(t, emails["charlie@example.com"], true, "charlie should be in results") + + // Verify user details match + for _, user := range users { + if user.Email.String == "alice@example.com" { + assert.Equal(t, user.ID, user1.ID, "alice ID mismatch") + } else if user.Email.String == "bob@example.com" { + assert.Equal(t, user.ID, user2.ID, "bob ID mismatch") + } else if user.Email.String == "charlie@example.com" { + assert.Equal(t, user.ID, user3.ID, "charlie ID mismatch") + } + } + }) + + t.Run("empty database", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + a := NewTest() + a.DB = db + + users, err := a.GetAllUsers() + + assert.Equal(t, err, nil, "should not error") + assert.Equal(t, len(users), 0, "should return 0 users") + }) + + t.Run("single user", func(t *testing.T) { + db := testutils.InitMemoryDB(t) + + user := testutils.SetupUserData(db, "alice@example.com", "password123") + + a := NewTest() + a.DB = db + + users, err := a.GetAllUsers() + + assert.Equal(t, err, nil, "should not error") + assert.Equal(t, len(users), 1, "should return 1 user") + assert.Equal(t, users[0].Email.String, "alice@example.com", "email mismatch") + assert.Equal(t, users[0].ID, user.ID, "user ID mismatch") + }) +} + func TestCreateUser(t *testing.T) { t.Run("success", func(t *testing.T) { db := testutils.InitMemoryDB(t) diff --git a/pkg/server/cmd/helpers.go b/pkg/server/cmd/helpers.go index 2a322476..ba90a7ce 100644 --- a/pkg/server/cmd/helpers.go +++ b/pkg/server/cmd/helpers.go @@ -111,8 +111,8 @@ func requireString(fs *flag.FlagSet, value, fieldName string) { } } -// setupAppWithDB creates config, initializes app, and returns cleanup function -func setupAppWithDB(fs *flag.FlagSet, dbPath string) (*app.App, func()) { +// createApp creates config, initializes app, and returns cleanup function +func createApp(fs *flag.FlagSet, dbPath string) (*app.App, func()) { cfg, err := config.New(config.Params{ DBPath: dbPath, }) diff --git a/pkg/server/cmd/user.go b/pkg/server/cmd/user.go index 01b753b1..7a98344d 100644 --- a/pkg/server/cmd/user.go +++ b/pkg/server/cmd/user.go @@ -51,7 +51,7 @@ func userCreateCmd(args []string) { requireString(fs, *email, "email") requireString(fs, *password, "password") - a, cleanup := setupAppWithDB(fs, *dbPath) + a, cleanup := createApp(fs, *dbPath) defer cleanup() _, err := a.CreateUser(*email, *password, *password) @@ -74,7 +74,7 @@ func userRemoveCmd(args []string, stdin io.Reader) { requireString(fs, *email, "email") - a, cleanup := setupAppWithDB(fs, *dbPath) + a, cleanup := createApp(fs, *dbPath) defer cleanup() // Check if user exists first @@ -127,7 +127,7 @@ func userResetPasswordCmd(args []string) { requireString(fs, *email, "email") requireString(fs, *password, "password") - a, cleanup := setupAppWithDB(fs, *dbPath) + a, cleanup := createApp(fs, *dbPath) defer cleanup() // Find the user @@ -151,6 +151,27 @@ func userResetPasswordCmd(args []string) { fmt.Printf("Email: %s\n", *email) } +func userListCmd(args []string, output io.Writer) { + fs := setupFlagSet("list", "dnote-server user list") + + dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") + + fs.Parse(args) + + a, cleanup := createApp(fs, *dbPath) + defer cleanup() + + users, err := a.GetAllUsers() + if err != nil { + log.ErrorWrap(err, "listing users") + os.Exit(1) + } + + for _, user := range users { + fmt.Fprintf(output, "%s,%s,%s\n", user.UUID, user.Email.String, user.CreatedAt.UTC().Format("2006-01-02T15:04:05Z")) + } +} + func userCmd(args []string) { if len(args) < 1 { fmt.Println(`Usage: @@ -158,6 +179,7 @@ func userCmd(args []string) { Available commands: create: Create a new user + list: List all users remove: Remove a user reset-password: Reset a user's password`) os.Exit(1) @@ -172,6 +194,8 @@ Available commands: switch subcommand { case "create": userCreateCmd(subArgs) + case "list": + userListCmd(subArgs, os.Stdout) case "remove": userRemoveCmd(subArgs, os.Stdin) case "reset-password": @@ -180,6 +204,7 @@ Available commands: fmt.Printf("Unknown subcommand: %s\n\n", subcommand) fmt.Println(`Available commands: create: Create a new user + list: List all users remove: Remove a user (only if they have no notes or books) reset-password: Reset a user's password`) os.Exit(1) diff --git a/pkg/server/cmd/user_test.go b/pkg/server/cmd/user_test.go index 834ae3bd..84e5f4de 100644 --- a/pkg/server/cmd/user_test.go +++ b/pkg/server/cmd/user_test.go @@ -16,6 +16,8 @@ package cmd import ( + "bytes" + "fmt" "strings" "testing" @@ -107,3 +109,50 @@ func TestUserResetPasswordCmd(t *testing.T) { err = bcrypt.CompareHashAndPassword([]byte(updatedUser.Password.String), []byte("oldpassword123")) assert.Equal(t, err != nil, true, "old password should not match") } + +func TestUserListCmd(t *testing.T) { + t.Run("multiple users", func(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Create multiple users + db := testutils.InitDB(tmpDB) + user1 := testutils.SetupUserData(db, "alice@example.com", "password123") + user2 := testutils.SetupUserData(db, "bob@example.com", "password123") + user3 := testutils.SetupUserData(db, "charlie@example.com", "password123") + sqlDB, _ := db.DB() + sqlDB.Close() + + // Capture output + var buf bytes.Buffer + userListCmd([]string{"--dbPath", tmpDB}, &buf) + + // Verify output matches expected format + output := strings.TrimSpace(buf.String()) + lines := strings.Split(output, "\n") + + expectedLine1 := fmt.Sprintf("%s,alice@example.com,%s", user1.UUID, user1.CreatedAt.UTC().Format("2006-01-02T15:04:05Z")) + expectedLine2 := fmt.Sprintf("%s,bob@example.com,%s", user2.UUID, user2.CreatedAt.UTC().Format("2006-01-02T15:04:05Z")) + expectedLine3 := fmt.Sprintf("%s,charlie@example.com,%s", user3.UUID, user3.CreatedAt.UTC().Format("2006-01-02T15:04:05Z")) + + assert.Equal(t, lines[0], expectedLine1, "line 1 should match") + assert.Equal(t, lines[1], expectedLine2, "line 2 should match") + assert.Equal(t, lines[2], expectedLine3, "line 3 should match") + }) + + t.Run("empty database", func(t *testing.T) { + tmpDB := t.TempDir() + "/test.db" + + // Initialize empty database + db := testutils.InitDB(tmpDB) + sqlDB, _ := db.DB() + sqlDB.Close() + + // Capture output + var buf bytes.Buffer + userListCmd([]string{"--dbPath", tmpDB}, &buf) + + // Verify no output + output := buf.String() + assert.Equal(t, output, "", "should have no output for empty database") + }) +} From 8f37d34df6712295bd57f9711189abd143d4765b Mon Sep 17 00:00:00 2001 From: Sung <8265228+sungwoncho@users.noreply.github.com> Date: Fri, 7 Nov 2025 23:53:41 -0800 Subject: [PATCH 31/33] Remove ls and cat commands (#715) --- pkg/cli/cmd/add/add.go | 2 +- pkg/cli/cmd/cat/cat.go | 95 ------------- pkg/cli/cmd/edit/note.go | 2 +- pkg/cli/cmd/remove/remove.go | 3 +- pkg/cli/cmd/{ls/ls.go => view/book.go} | 89 ++---------- pkg/cli/cmd/view/book_test.go | 184 +++++++++++++++++++++++++ pkg/cli/cmd/view/note.go | 47 +++++++ pkg/cli/cmd/view/note_test.go | 90 ++++++++++++ pkg/cli/cmd/view/view.go | 26 ++-- pkg/cli/main.go | 4 - pkg/cli/main_test.go | 63 +++++++++ pkg/cli/output/output.go | 13 +- pkg/cli/testutils/main.go | 4 +- 13 files changed, 425 insertions(+), 197 deletions(-) delete mode 100644 pkg/cli/cmd/cat/cat.go rename pkg/cli/cmd/{ls/ls.go => view/book.go} (63%) create mode 100644 pkg/cli/cmd/view/book_test.go create mode 100644 pkg/cli/cmd/view/note.go create mode 100644 pkg/cli/cmd/view/note_test.go diff --git a/pkg/cli/cmd/add/add.go b/pkg/cli/cmd/add/add.go index be89b829..3e6d089d 100644 --- a/pkg/cli/cmd/add/add.go +++ b/pkg/cli/cmd/add/add.go @@ -131,7 +131,7 @@ func newRun(ctx context.DnoteCtx) infra.RunEFunc { return err } - output.NoteInfo(info) + output.NoteInfo(os.Stdout, info) if err := upgrade.Check(ctx); err != nil { log.Error(errors.Wrap(err, "automatically checking updates").Error()) diff --git a/pkg/cli/cmd/cat/cat.go b/pkg/cli/cmd/cat/cat.go deleted file mode 100644 index c32eb687..00000000 --- a/pkg/cli/cmd/cat/cat.go +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2025 Dnote Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cat - -import ( - "strconv" - - "github.com/dnote/dnote/pkg/cli/context" - "github.com/dnote/dnote/pkg/cli/database" - "github.com/dnote/dnote/pkg/cli/infra" - "github.com/dnote/dnote/pkg/cli/log" - "github.com/dnote/dnote/pkg/cli/output" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -var example = ` - * See the notes with index 2 from a book 'javascript' - dnote cat javascript 2 - ` - -var deprecationWarning = `and "view" will replace it in the future version. - - Run "dnote view --help" for more information. -` - -func preRun(cmd *cobra.Command, args []string) error { - if len(args) != 2 { - return errors.New("Incorrect number of arguments") - } - - return nil -} - -// NewCmd returns a new cat command -func NewCmd(ctx context.DnoteCtx) *cobra.Command { - cmd := &cobra.Command{ - Use: "cat ", - Aliases: []string{"c"}, - Short: "See a note", - Example: example, - RunE: NewRun(ctx, false), - PreRunE: preRun, - Deprecated: deprecationWarning, - } - - return cmd -} - -// NewRun returns a new run function -func NewRun(ctx context.DnoteCtx, contentOnly bool) infra.RunEFunc { - return func(cmd *cobra.Command, args []string) error { - var noteRowIDArg string - - if len(args) == 2 { - log.Plain(log.ColorYellow.Sprintf("DEPRECATED: you no longer need to pass book name to the view command. e.g. `dnote view 123`.\n\n")) - - noteRowIDArg = args[1] - } else { - noteRowIDArg = args[0] - } - - noteRowID, err := strconv.Atoi(noteRowIDArg) - if err != nil { - return errors.Wrap(err, "invalid rowid") - } - - db := ctx.DB - info, err := database.GetNoteInfo(db, noteRowID) - if err != nil { - return err - } - - if contentOnly { - output.NoteContent(info) - } else { - output.NoteInfo(info) - } - - return nil - } -} diff --git a/pkg/cli/cmd/edit/note.go b/pkg/cli/cmd/edit/note.go index 84a631f4..cb837e11 100644 --- a/pkg/cli/cmd/edit/note.go +++ b/pkg/cli/cmd/edit/note.go @@ -166,7 +166,7 @@ func runNote(ctx context.DnoteCtx, rowIDArg string) error { } log.Success("edited the note\n") - output.NoteInfo(noteInfo) + output.NoteInfo(os.Stdout, noteInfo) return nil } diff --git a/pkg/cli/cmd/remove/remove.go b/pkg/cli/cmd/remove/remove.go index 89d44b78..18224c0f 100644 --- a/pkg/cli/cmd/remove/remove.go +++ b/pkg/cli/cmd/remove/remove.go @@ -17,6 +17,7 @@ package remove import ( "fmt" + "os" "strconv" "github.com/dnote/dnote/pkg/cli/context" @@ -129,7 +130,7 @@ func runNote(ctx context.DnoteCtx, rowIDArg string) error { return err } - output.NoteInfo(noteInfo) + output.NoteInfo(os.Stdout, noteInfo) ok, err := maybeConfirm("remove this note?", false) if err != nil { diff --git a/pkg/cli/cmd/ls/ls.go b/pkg/cli/cmd/view/book.go similarity index 63% rename from pkg/cli/cmd/ls/ls.go rename to pkg/cli/cmd/view/book.go index f0ddd047..698a7de5 100644 --- a/pkg/cli/cmd/ls/ls.go +++ b/pkg/cli/cmd/view/book.go @@ -13,76 +13,19 @@ * limitations under the License. */ -package ls +package view import ( "database/sql" "fmt" + "io" "strings" "github.com/dnote/dnote/pkg/cli/context" - "github.com/dnote/dnote/pkg/cli/infra" "github.com/dnote/dnote/pkg/cli/log" "github.com/pkg/errors" - "github.com/spf13/cobra" ) -var example = ` - * List all books - dnote ls - - * List notes in a book - dnote ls javascript - ` - -var deprecationWarning = `and "view" will replace it in the future version. - -Run "dnote view --help" for more information. -` - -func preRun(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - return errors.New("Incorrect number of argument") - } - - return nil -} - -// NewCmd returns a new ls command -func NewCmd(ctx context.DnoteCtx) *cobra.Command { - cmd := &cobra.Command{ - Use: "ls ", - Aliases: []string{"l", "notes"}, - Short: "List all notes", - Example: example, - RunE: NewRun(ctx, false), - PreRunE: preRun, - Deprecated: deprecationWarning, - } - - return cmd -} - -// NewRun returns a new run function for ls -func NewRun(ctx context.DnoteCtx, nameOnly bool) infra.RunEFunc { - return func(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - if err := printBooks(ctx, nameOnly); err != nil { - return errors.Wrap(err, "viewing books") - } - - return nil - } - - bookName := args[0] - if err := printNotes(ctx, bookName); err != nil { - return errors.Wrapf(err, "viewing book '%s'", bookName) - } - - return nil - } -} - // bookInfo is an information about the book to be printed on screen type bookInfo struct { BookLabel string @@ -97,15 +40,13 @@ type noteInfo struct { // getNewlineIdx returns the index of newline character in a string func getNewlineIdx(str string) int { - var ret int - - ret = strings.Index(str, "\n") - - if ret == -1 { - ret = strings.Index(str, "\r\n") + // Check for \r\n first + if idx := strings.Index(str, "\r\n"); idx != -1 { + return idx } - return ret + // Then check for \n + return strings.Index(str, "\n") } // formatBody returns an excerpt of the given raw note content and a boolean @@ -123,15 +64,15 @@ func formatBody(noteBody string) (string, bool) { return strings.Trim(trimmed, " "), false } -func printBookLine(info bookInfo, nameOnly bool) { +func printBookLine(w io.Writer, info bookInfo, nameOnly bool) { if nameOnly { - fmt.Println(info.BookLabel) + fmt.Fprintln(w, info.BookLabel) } else { - log.Printf("%s %s\n", info.BookLabel, log.ColorYellow.Sprintf("(%d)", info.NoteCount)) + fmt.Fprintf(w, "%s %s\n", info.BookLabel, log.ColorYellow.Sprintf("(%d)", info.NoteCount)) } } -func printBooks(ctx context.DnoteCtx, nameOnly bool) error { +func listBooks(ctx context.DnoteCtx, w io.Writer, nameOnly bool) error { db := ctx.DB rows, err := db.Query(`SELECT books.label, count(notes.uuid) note_count @@ -157,13 +98,13 @@ func printBooks(ctx context.DnoteCtx, nameOnly bool) error { } for _, info := range infos { - printBookLine(info, nameOnly) + printBookLine(w, info, nameOnly) } return nil } -func printNotes(ctx context.DnoteCtx, bookName string) error { +func listNotes(ctx context.DnoteCtx, w io.Writer, bookName string) error { db := ctx.DB var bookUUID string @@ -191,7 +132,7 @@ func printNotes(ctx context.DnoteCtx, bookName string) error { infos = append(infos, info) } - log.Infof("on book %s\n", bookName) + fmt.Fprintf(w, "on book %s\n", bookName) for _, info := range infos { body, isExcerpt := formatBody(info.Body) @@ -201,7 +142,7 @@ func printNotes(ctx context.DnoteCtx, bookName string) error { body = fmt.Sprintf("%s %s", body, log.ColorYellow.Sprintf("[---More---]")) } - log.Plainf("%s %s\n", rowid, body) + fmt.Fprintf(w, "%s %s\n", rowid, body) } return nil diff --git a/pkg/cli/cmd/view/book_test.go b/pkg/cli/cmd/view/book_test.go new file mode 100644 index 00000000..226d5d04 --- /dev/null +++ b/pkg/cli/cmd/view/book_test.go @@ -0,0 +1,184 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package view + +import ( + "bytes" + "fmt" + "strings" + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/context" + "github.com/dnote/dnote/pkg/cli/database" +) + +func TestGetNewlineIdx(t *testing.T) { + testCases := []struct { + input string + expected int + }{ + { + input: "hello\nworld", + expected: 5, + }, + { + input: "hello\r\nworld", + expected: 5, + }, + { + input: "no newline here", + expected: -1, + }, + { + input: "", + expected: -1, + }, + { + input: "\n", + expected: 0, + }, + { + input: "\r\n", + expected: 0, + }, + } + + for _, tc := range testCases { + t.Run(fmt.Sprintf("input: %q", tc.input), func(t *testing.T) { + got := getNewlineIdx(tc.input) + assert.Equal(t, got, tc.expected, "newline index mismatch") + }) + } +} + +func TestFormatBody(t *testing.T) { + testCases := []struct { + input string + expectedBody string + expectedExcerpt bool + }{ + { + input: "single line", + expectedBody: "single line", + expectedExcerpt: false, + }, + { + input: "first line\nsecond line", + expectedBody: "first line", + expectedExcerpt: true, + }, + { + input: "first line\r\nsecond line", + expectedBody: "first line", + expectedExcerpt: true, + }, + { + input: " spaced line ", + expectedBody: "spaced line", + expectedExcerpt: false, + }, + { + input: " first line \nsecond line", + expectedBody: "first line", + expectedExcerpt: true, + }, + { + input: "", + expectedBody: "", + expectedExcerpt: false, + }, + { + input: "line with trailing newline\n", + expectedBody: "line with trailing newline", + expectedExcerpt: false, + }, + { + input: "line with trailing newlines\n\n", + expectedBody: "line with trailing newlines", + expectedExcerpt: false, + }, + } + + for _, tc := range testCases { + t.Run(fmt.Sprintf("input: %q", tc.input), func(t *testing.T) { + gotBody, gotExcerpt := formatBody(tc.input) + assert.Equal(t, gotBody, tc.expectedBody, "formatted body mismatch") + assert.Equal(t, gotExcerpt, tc.expectedExcerpt, "excerpt flag mismatch") + }) + } +} + +func TestListNotes(t *testing.T) { + // Setup + db := database.InitTestMemoryDB(t) + defer db.Close() + + bookUUID := "js-book-uuid" + database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "javascript") + database.MustExec(t, "inserting note 1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-1", bookUUID, "first note", 1515199943) + database.MustExec(t, "inserting note 2", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-2", bookUUID, "multiline note\nwith second line", 1515199945) + + ctx := context.DnoteCtx{DB: db} + var buf bytes.Buffer + + // Execute + err := listNotes(ctx, &buf, "javascript") + if err != nil { + t.Fatal(err) + } + + got := buf.String() + + // Verify output + assert.Equal(t, strings.Contains(got, "on book javascript"), true, "should show book name") + assert.Equal(t, strings.Contains(got, "first note"), true, "should contain first note") + assert.Equal(t, strings.Contains(got, "multiline note"), true, "should show first line of multiline note") + assert.Equal(t, strings.Contains(got, "[---More---]"), true, "should show more indicator for multiline note") + assert.Equal(t, strings.Contains(got, "with second line"), false, "should not show second line of multiline note") +} + +func TestListBooks(t *testing.T) { + // Setup + db := database.InitTestMemoryDB(t) + defer db.Close() + + b1UUID := "js-book-uuid" + b2UUID := "linux-book-uuid" + + database.MustExec(t, "inserting book 1", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b1UUID, "javascript") + database.MustExec(t, "inserting book 2", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", b2UUID, "linux") + + // Add notes to test count + database.MustExec(t, "inserting note 1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-1", b1UUID, "note body 1", 1515199943) + database.MustExec(t, "inserting note 2", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", "note-2", b1UUID, "note body 2", 1515199944) + + ctx := context.DnoteCtx{DB: db} + var buf bytes.Buffer + + // Execute + err := listBooks(ctx, &buf, false) + if err != nil { + t.Fatal(err) + } + + got := buf.String() + + // Verify output + assert.Equal(t, strings.Contains(got, "javascript"), true, "should contain javascript book") + assert.Equal(t, strings.Contains(got, "linux"), true, "should contain linux book") + assert.Equal(t, strings.Contains(got, "(2)"), true, "should show 2 notes for javascript") +} diff --git a/pkg/cli/cmd/view/note.go b/pkg/cli/cmd/view/note.go new file mode 100644 index 00000000..f853dd9a --- /dev/null +++ b/pkg/cli/cmd/view/note.go @@ -0,0 +1,47 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package view + +import ( + "io" + "strconv" + + "github.com/dnote/dnote/pkg/cli/context" + "github.com/dnote/dnote/pkg/cli/database" + "github.com/dnote/dnote/pkg/cli/output" + "github.com/pkg/errors" +) + +func viewNote(ctx context.DnoteCtx, w io.Writer, noteRowIDArg string, contentOnly bool) error { + noteRowID, err := strconv.Atoi(noteRowIDArg) + if err != nil { + return errors.Wrap(err, "invalid rowid") + } + + db := ctx.DB + info, err := database.GetNoteInfo(db, noteRowID) + if err != nil { + return err + } + + if contentOnly { + output.NoteContent(w, info) + } else { + output.NoteInfo(w, info) + } + + return nil +} diff --git a/pkg/cli/cmd/view/note_test.go b/pkg/cli/cmd/view/note_test.go new file mode 100644 index 00000000..36e9aa84 --- /dev/null +++ b/pkg/cli/cmd/view/note_test.go @@ -0,0 +1,90 @@ +/* Copyright 2025 Dnote Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package view + +import ( + "bytes" + "strings" + "testing" + + "github.com/dnote/dnote/pkg/assert" + "github.com/dnote/dnote/pkg/cli/context" + "github.com/dnote/dnote/pkg/cli/database" +) + +func TestViewNote(t *testing.T) { + db := database.InitTestMemoryDB(t) + defer db.Close() + + bookUUID := "test-book-uuid" + database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "golang") + database.MustExec(t, "inserting note", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", + "note-uuid", bookUUID, "test note content", 1515199943000000000) + + ctx := context.DnoteCtx{DB: db} + var buf bytes.Buffer + + err := viewNote(ctx, &buf, "1", false) + if err != nil { + t.Fatal(err) + } + + got := buf.String() + assert.Equal(t, strings.Contains(got, "test note content"), true, "should contain note content") +} + +func TestViewNoteContentOnly(t *testing.T) { + db := database.InitTestMemoryDB(t) + defer db.Close() + + bookUUID := "test-book-uuid" + database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "golang") + database.MustExec(t, "inserting note", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)", + "note-uuid", bookUUID, "test note content", 1515199943000000000) + + ctx := context.DnoteCtx{DB: db} + var buf bytes.Buffer + + err := viewNote(ctx, &buf, "1", true) + if err != nil { + t.Fatal(err) + } + + got := buf.String() + assert.Equal(t, got, "test note content", "should contain only note content") +} + +func TestViewNoteInvalidRowID(t *testing.T) { + db := database.InitTestMemoryDB(t) + defer db.Close() + + ctx := context.DnoteCtx{DB: db} + var buf bytes.Buffer + + err := viewNote(ctx, &buf, "not-a-number", false) + assert.NotEqual(t, err, nil, "should return error for invalid rowid") +} + +func TestViewNoteNotFound(t *testing.T) { + db := database.InitTestMemoryDB(t) + defer db.Close() + + ctx := context.DnoteCtx{DB: db} + var buf bytes.Buffer + + err := viewNote(ctx, &buf, "999", false) + assert.NotEqual(t, err, nil, "should return error for non-existent note") +} diff --git a/pkg/cli/cmd/view/view.go b/pkg/cli/cmd/view/view.go index 62f50a53..57b17dbd 100644 --- a/pkg/cli/cmd/view/view.go +++ b/pkg/cli/cmd/view/view.go @@ -16,14 +16,13 @@ package view import ( + "os" + "github.com/dnote/dnote/pkg/cli/context" "github.com/dnote/dnote/pkg/cli/infra" + "github.com/dnote/dnote/pkg/cli/utils" "github.com/pkg/errors" "github.com/spf13/cobra" - - "github.com/dnote/dnote/pkg/cli/cmd/cat" - "github.com/dnote/dnote/pkg/cli/cmd/ls" - "github.com/dnote/dnote/pkg/cli/utils" ) var example = ` @@ -68,27 +67,26 @@ func NewCmd(ctx context.DnoteCtx) *cobra.Command { func newRun(ctx context.DnoteCtx) infra.RunEFunc { return func(cmd *cobra.Command, args []string) error { - var run infra.RunEFunc - if len(args) == 0 { - run = ls.NewRun(ctx, nameOnly) + // List all books + return listBooks(ctx, os.Stdout, nameOnly) } else if len(args) == 1 { if nameOnly { return errors.New("--name-only flag is only valid when viewing books") } if utils.IsNumber(args[0]) { - run = cat.NewRun(ctx, contentOnly) + // View a note by index + return viewNote(ctx, os.Stdout, args[0], contentOnly) } else { - run = ls.NewRun(ctx, false) + // List notes in a book + return listNotes(ctx, os.Stdout, args[0]) } } else if len(args) == 2 { - // DEPRECATED: passing book name to view command is deprecated - run = cat.NewRun(ctx, false) - } else { - return errors.New("Incorrect number of arguments") + // View a note in a book (book name + note index) + return viewNote(ctx, os.Stdout, args[1], contentOnly) } - return run(cmd, args) + return errors.New("Incorrect number of arguments") } } diff --git a/pkg/cli/main.go b/pkg/cli/main.go index 2afbaf36..2fb1c564 100644 --- a/pkg/cli/main.go +++ b/pkg/cli/main.go @@ -26,12 +26,10 @@ import ( // commands "github.com/dnote/dnote/pkg/cli/cmd/add" - "github.com/dnote/dnote/pkg/cli/cmd/cat" "github.com/dnote/dnote/pkg/cli/cmd/edit" "github.com/dnote/dnote/pkg/cli/cmd/find" "github.com/dnote/dnote/pkg/cli/cmd/login" "github.com/dnote/dnote/pkg/cli/cmd/logout" - "github.com/dnote/dnote/pkg/cli/cmd/ls" "github.com/dnote/dnote/pkg/cli/cmd/remove" "github.com/dnote/dnote/pkg/cli/cmd/root" "github.com/dnote/dnote/pkg/cli/cmd/sync" @@ -79,10 +77,8 @@ func main() { root.Register(login.NewCmd(*ctx)) root.Register(logout.NewCmd(*ctx)) root.Register(add.NewCmd(*ctx)) - root.Register(ls.NewCmd(*ctx)) root.Register(sync.NewCmd(*ctx)) root.Register(version.NewCmd(*ctx)) - root.Register(cat.NewCmd(*ctx)) root.Register(view.NewCmd(*ctx)) root.Register(find.NewCmd(*ctx)) diff --git a/pkg/cli/main_test.go b/pkg/cli/main_test.go index 5da1915e..727a5c3e 100644 --- a/pkg/cli/main_test.go +++ b/pkg/cli/main_test.go @@ -20,6 +20,7 @@ import ( "log" "os" "os/exec" + "strings" "testing" "github.com/dnote/dnote/pkg/assert" @@ -568,3 +569,65 @@ func TestDBPathFlag(t *testing.T) { db2.QueryRow("SELECT count(*) FROM books WHERE label = ?", "db1-book").Scan(&db2HasDB1Book) assert.Equal(t, db2HasDB1Book, 0, "db2 should not have db1's book") } + +func TestView(t *testing.T) { + t.Run("view note by rowid", func(t *testing.T) { + _, opts := setupTestEnv(t) + + db, dbPath := database.InitTestFileDB(t) + testutils.Setup4(t, db) + + output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "1") + + assert.Equal(t, strings.Contains(output, "Booleans have toString()"), true, "should contain note content") + assert.Equal(t, strings.Contains(output, "book name"), true, "should show metadata") + }) + + t.Run("view note content only", func(t *testing.T) { + _, opts := setupTestEnv(t) + + db, dbPath := database.InitTestFileDB(t) + testutils.Setup4(t, db) + + output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "1", "--content-only") + + assert.Equal(t, strings.Contains(output, "Booleans have toString()"), true, "should contain note content") + assert.Equal(t, strings.Contains(output, "book name"), false, "should not show metadata") + }) + + t.Run("list books", func(t *testing.T) { + _, opts := setupTestEnv(t) + + db, dbPath := database.InitTestFileDB(t) + testutils.Setup1(t, db) + + output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view") + + assert.Equal(t, strings.Contains(output, "js"), true, "should list js book") + assert.Equal(t, strings.Contains(output, "linux"), true, "should list linux book") + }) + + t.Run("list notes in book", func(t *testing.T) { + _, opts := setupTestEnv(t) + + db, dbPath := database.InitTestFileDB(t) + testutils.Setup2(t, db) + + output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "js") + + assert.Equal(t, strings.Contains(output, "n1 body"), true, "should list note 1") + assert.Equal(t, strings.Contains(output, "n2 body"), true, "should list note 2") + }) + + t.Run("view note by book name and rowid", func(t *testing.T) { + _, opts := setupTestEnv(t) + + db, dbPath := database.InitTestFileDB(t) + testutils.Setup4(t, db) + + output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "js", "2") + + assert.Equal(t, strings.Contains(output, "Date object implements mathematical comparisons"), true, "should contain note content") + assert.Equal(t, strings.Contains(output, "book name"), true, "should show metadata") + }) +} diff --git a/pkg/cli/output/output.go b/pkg/cli/output/output.go index fe6e3c87..d272ba88 100644 --- a/pkg/cli/output/output.go +++ b/pkg/cli/output/output.go @@ -19,6 +19,7 @@ package output import ( "fmt" + "io" "time" "github.com/dnote/dnote/pkg/cli/database" @@ -26,7 +27,7 @@ import ( ) // NoteInfo prints a note information -func NoteInfo(info database.NoteInfo) { +func NoteInfo(w io.Writer, info database.NoteInfo) { log.Infof("book name: %s\n", info.BookLabel) log.Infof("created at: %s\n", time.Unix(0, info.AddedOn).Format("Jan 2, 2006 3:04pm (MST)")) if info.EditedOn != 0 { @@ -35,13 +36,13 @@ func NoteInfo(info database.NoteInfo) { log.Infof("note id: %d\n", info.RowID) log.Infof("note uuid: %s\n", info.UUID) - fmt.Printf("\n------------------------content------------------------\n") - fmt.Printf("%s", info.Content) - fmt.Printf("\n-------------------------------------------------------\n") + fmt.Fprintf(w, "\n------------------------content------------------------\n") + fmt.Fprintf(w, "%s", info.Content) + fmt.Fprintf(w, "\n-------------------------------------------------------\n") } -func NoteContent(info database.NoteInfo) { - fmt.Printf("%s", info.Content) +func NoteContent(w io.Writer, info database.NoteInfo) { + fmt.Fprintf(w, "%s", info.Content) } // BookInfo prints a note information diff --git a/pkg/cli/testutils/main.go b/pkg/cli/testutils/main.go index 581cbd7f..db3282d7 100644 --- a/pkg/cli/testutils/main.go +++ b/pkg/cli/testutils/main.go @@ -144,7 +144,7 @@ type RunDnoteCmdOptions struct { } // RunDnoteCmd runs a dnote command -func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string) { +func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string) string { t.Logf("running: %s %s", binaryName, strings.Join(arg, " ")) cmd, stderr, stdout, err := NewDnoteCmd(opts, binaryName, arg...) @@ -162,6 +162,8 @@ func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg . // Print stdout if and only if test fails later t.Logf("\n%s", stdout) + + return stdout.String() } // WaitDnoteCmd runs a dnote command and passes stdout to the callback. From 9fa312e3fc6139788533ca6cd1ada8c16a10519c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 21:48:59 -0800 Subject: [PATCH 32/33] Bump golang.org/x/crypto from 0.42.0 to 0.45.0 (#716) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.42.0 to 0.45.0. - [Commits](https://github.com/golang/crypto/compare/v0.42.0...v0.45.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.45.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 9 ++++----- go.sum | 18 ++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 3b87c5ec..48dfc85c 100644 --- a/go.mod +++ b/go.mod @@ -14,10 +14,9 @@ require ( github.com/mattn/go-sqlite3 v1.14.32 github.com/pkg/errors v0.9.1 github.com/radovskyb/watcher v1.0.7 - github.com/robfig/cron v1.2.0 github.com/sergi/go-diff v1.3.1 github.com/spf13/cobra v1.10.1 - golang.org/x/crypto v0.42.0 + golang.org/x/crypto v0.45.0 golang.org/x/time v0.13.0 gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/yaml.v2 v2.4.0 @@ -36,9 +35,9 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/stretchr/testify v1.8.1 // indirect - golang.org/x/sys v0.36.0 // indirect - golang.org/x/term v0.35.0 // indirect - golang.org/x/text v0.29.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/term v0.37.0 // indirect + golang.org/x/text v0.31.0 // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index e175da0d..8b3c653a 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/radovskyb/watcher v1.0.7 h1:AYePLih6dpmS32vlHfhCeli8127LzkIgwJGcwwe8tUE= github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg= -github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= -github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -73,15 +71,15 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= -golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= +golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= +golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ= -golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI= golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From f34a96abbe47e8b516ea7cac2bdec06c64c01493 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:11:45 -0800 Subject: [PATCH 33/33] Bump immutable from 5.1.3 to 5.1.5 in /pkg/server/assets (#718) Bumps [immutable](https://github.com/immutable-js/immutable-js) from 5.1.3 to 5.1.5. - [Release notes](https://github.com/immutable-js/immutable-js/releases) - [Changelog](https://github.com/immutable-js/immutable-js/blob/main/CHANGELOG.md) - [Commits](https://github.com/immutable-js/immutable-js/compare/v5.1.3...v5.1.5) --- updated-dependencies: - dependency-name: immutable dependency-version: 5.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkg/server/assets/package-lock.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/server/assets/package-lock.json b/pkg/server/assets/package-lock.json index 610d8eb4..7eb1c411 100644 --- a/pkg/server/assets/package-lock.json +++ b/pkg/server/assets/package-lock.json @@ -363,10 +363,11 @@ } }, "node_modules/immutable": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.3.tgz", - "integrity": "sha512-+chQdDfvscSF1SJqv2gn4SRO2ZyS3xL3r7IW/wWEEzrzLisnOlKiQu5ytC/BVNcS15C39WT2Hg/bjKjDMcu+zg==", - "dev": true + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.5.tgz", + "integrity": "sha512-t7xcm2siw+hlUM68I+UEOK+z84RzmN59as9DZ7P1l0994DKUWV7UXBMQZVxaoMSRQ+PBZbHCOoBt7a2wxOMt+A==", + "dev": true, + "license": "MIT" }, "node_modules/is-extglob": { "version": "2.1.1",