mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Rename app to Lemma
This commit is contained in:
@@ -4,13 +4,13 @@ package main
|
||||
import (
|
||||
"log"
|
||||
|
||||
"novamd/internal/app"
|
||||
"novamd/internal/logging"
|
||||
"lemma/internal/app"
|
||||
"lemma/internal/logging"
|
||||
)
|
||||
|
||||
// @title NovaMD API
|
||||
// @title Lemma API
|
||||
// @version 1.0
|
||||
// @description This is the API for NovaMD markdown note taking app.
|
||||
// @description This is the API for Lemma markdown note taking app.
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @BasePath /api/v1
|
||||
|
||||
@@ -1295,7 +1295,7 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to write response",
|
||||
"description": "Failed to delete file",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
@@ -1777,8 +1777,8 @@ var SwaggerInfo = &swag.Spec{
|
||||
Host: "",
|
||||
BasePath: "/api/v1",
|
||||
Schemes: []string{},
|
||||
Title: "NovaMD API",
|
||||
Description: "This is the API for NovaMD markdown note taking app.",
|
||||
Title: "Lemma API",
|
||||
Description: "This is the API for Lemma markdown note taking app.",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "This is the API for NovaMD markdown note taking app.",
|
||||
"title": "NovaMD API",
|
||||
"description": "This is the API for Lemma markdown note taking app.",
|
||||
"title": "Lemma API",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
@@ -1288,7 +1288,7 @@
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to write response",
|
||||
"description": "Failed to delete file",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
|
||||
@@ -239,11 +239,11 @@ definitions:
|
||||
type: object
|
||||
info:
|
||||
contact: {}
|
||||
description: This is the API for NovaMD markdown note taking app.
|
||||
description: This is the API for Lemma markdown note taking app.
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
title: NovaMD API
|
||||
title: Lemma API
|
||||
version: "1.0"
|
||||
paths:
|
||||
/admin/stats:
|
||||
@@ -844,7 +844,7 @@ paths:
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
"500":
|
||||
description: Failed to write response
|
||||
description: Failed to delete file
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
security:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# NovaMD Package Documentation
|
||||
# Lemma Package Documentation
|
||||
|
||||
Generated documentation for all packages in the NovaMD project.
|
||||
Generated documentation for all packages in the Lemma project.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -26,7 +26,7 @@ configuration, initializes the server, and starts the server.
|
||||
## docs
|
||||
|
||||
```go
|
||||
package docs // import "novamd/docs"
|
||||
package docs // import "lemma/docs"
|
||||
|
||||
Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||
|
||||
@@ -37,8 +37,8 @@ var SwaggerInfo = &swag.Spec{
|
||||
Host: "",
|
||||
BasePath: "/api/v1",
|
||||
Schemes: []string{},
|
||||
Title: "NovaMD API",
|
||||
Description: "This is the API for NovaMD markdown note taking app.",
|
||||
Title: "Lemma API",
|
||||
Description: "This is the API for Lemma markdown note taking app.",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
@@ -51,7 +51,7 @@ var SwaggerInfo = &swag.Spec{
|
||||
## internal/app
|
||||
|
||||
```go
|
||||
package app // import "novamd/internal/app"
|
||||
package app // import "lemma/internal/app"
|
||||
|
||||
Package app provides application-level functionality for initializing and
|
||||
running the server
|
||||
@@ -118,7 +118,7 @@ func (s *Server) Start() error
|
||||
## internal/auth
|
||||
|
||||
```go
|
||||
package auth // import "novamd/internal/auth"
|
||||
package auth // import "lemma/internal/auth"
|
||||
|
||||
Package auth provides JWT token generation and validation
|
||||
|
||||
@@ -210,7 +210,7 @@ const (
|
||||
## internal/context
|
||||
|
||||
```go
|
||||
package context // import "novamd/internal/context"
|
||||
package context // import "lemma/internal/context"
|
||||
|
||||
Package context provides functions for managing request context
|
||||
|
||||
@@ -261,7 +261,7 @@ func GetUserFromContext(ctx context.Context) (*UserClaims, error)
|
||||
## internal/db
|
||||
|
||||
```go
|
||||
package db // import "novamd/internal/db"
|
||||
package db // import "lemma/internal/db"
|
||||
|
||||
Package db provides the database access layer for the application. It contains
|
||||
methods for interacting with the database, such as creating, updating, and
|
||||
@@ -369,7 +369,7 @@ type WorkspaceWriter interface {
|
||||
## internal/git
|
||||
|
||||
```go
|
||||
package git // import "novamd/internal/git"
|
||||
package git // import "lemma/internal/git"
|
||||
|
||||
Package git provides functionalities to interact with Git repositories,
|
||||
including cloning, pulling, committing, and pushing changes.
|
||||
@@ -409,7 +409,7 @@ type Config struct {
|
||||
## internal/handlers
|
||||
|
||||
```go
|
||||
package handlers // import "novamd/internal/handlers"
|
||||
package handlers // import "lemma/internal/handlers"
|
||||
|
||||
Package handlers contains the request handlers for the api routes.
|
||||
|
||||
@@ -825,7 +825,7 @@ type WorkspaceStats struct {
|
||||
## internal/models
|
||||
|
||||
```go
|
||||
package models // import "novamd/internal/models"
|
||||
package models // import "lemma/internal/models"
|
||||
|
||||
Package models contains the data models used throughout the application.
|
||||
These models are used to represent data in the database, as well as to validate
|
||||
@@ -902,7 +902,7 @@ func (w *Workspace) ValidateGitSettings() error
|
||||
## internal/secrets
|
||||
|
||||
```go
|
||||
package secrets // import "novamd/internal/secrets"
|
||||
package secrets // import "lemma/internal/secrets"
|
||||
|
||||
Package secrets provides an Encryptor interface for encrypting and decrypting
|
||||
strings using AES-256-GCM.
|
||||
@@ -931,7 +931,7 @@ func NewService(key string) (Service, error)
|
||||
## internal/storage
|
||||
|
||||
```go
|
||||
package storage // import "novamd/internal/storage"
|
||||
package storage // import "lemma/internal/storage"
|
||||
|
||||
Package storage provides functionalities to interact with the file system,
|
||||
including listing files, finding files by name, getting file content, saving
|
||||
@@ -1091,4 +1091,3 @@ type WorkspaceManager interface {
|
||||
storage.
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ generate_anchor() {
|
||||
}
|
||||
|
||||
# Create documentation file
|
||||
echo "# NovaMD Package Documentation
|
||||
echo "# Lemma Package Documentation
|
||||
|
||||
Generated documentation for all packages in the NovaMD project.
|
||||
Generated documentation for all packages in the Lemma project.
|
||||
|
||||
## Table of Contents
|
||||
" > documentation.md
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module novamd
|
||||
module lemma
|
||||
|
||||
go 1.23.1
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/secrets"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/secrets"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -32,7 +32,7 @@ type Config struct {
|
||||
// DefaultConfig returns a new Config instance with default values
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
DBPath: "./novamd.db",
|
||||
DBPath: "./lemma.db",
|
||||
WorkDir: "./data",
|
||||
StaticPath: "../app/dist",
|
||||
Port: "8080",
|
||||
@@ -45,12 +45,12 @@ func DefaultConfig() *Config {
|
||||
// validate checks if the configuration is valid
|
||||
func (c *Config) validate() error {
|
||||
if c.AdminEmail == "" || c.AdminPassword == "" {
|
||||
return fmt.Errorf("NOVAMD_ADMIN_EMAIL and NOVAMD_ADMIN_PASSWORD must be set")
|
||||
return fmt.Errorf("LEMMA_ADMIN_EMAIL and LEMMA_ADMIN_PASSWORD must be set")
|
||||
}
|
||||
|
||||
// Validate encryption key
|
||||
if err := secrets.ValidateKey(c.EncryptionKey); err != nil {
|
||||
return fmt.Errorf("invalid NOVAMD_ENCRYPTION_KEY: %w", err)
|
||||
return fmt.Errorf("invalid LEMMA_ENCRYPTION_KEY: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -70,52 +70,52 @@ func (c *Config) Redact() *Config {
|
||||
func LoadConfig() (*Config, error) {
|
||||
config := DefaultConfig()
|
||||
|
||||
if env := os.Getenv("NOVAMD_ENV"); env != "" {
|
||||
if env := os.Getenv("LEMMA_ENV"); env != "" {
|
||||
config.IsDevelopment = env == "development"
|
||||
}
|
||||
|
||||
if dbPath := os.Getenv("NOVAMD_DB_PATH"); dbPath != "" {
|
||||
if dbPath := os.Getenv("LEMMA_DB_PATH"); dbPath != "" {
|
||||
config.DBPath = dbPath
|
||||
}
|
||||
|
||||
if workDir := os.Getenv("NOVAMD_WORKDIR"); workDir != "" {
|
||||
if workDir := os.Getenv("LEMMA_WORKDIR"); workDir != "" {
|
||||
config.WorkDir = workDir
|
||||
}
|
||||
|
||||
if staticPath := os.Getenv("NOVAMD_STATIC_PATH"); staticPath != "" {
|
||||
if staticPath := os.Getenv("LEMMA_STATIC_PATH"); staticPath != "" {
|
||||
config.StaticPath = staticPath
|
||||
}
|
||||
|
||||
if port := os.Getenv("NOVAMD_PORT"); port != "" {
|
||||
if port := os.Getenv("LEMMA_PORT"); port != "" {
|
||||
config.Port = port
|
||||
}
|
||||
|
||||
if rootURL := os.Getenv("NOVAMD_ROOT_URL"); rootURL != "" {
|
||||
if rootURL := os.Getenv("LEMMA_ROOT_URL"); rootURL != "" {
|
||||
config.RootURL = rootURL
|
||||
}
|
||||
|
||||
if domain := os.Getenv("NOVAMD_DOMAIN"); domain != "" {
|
||||
if domain := os.Getenv("LEMMA_DOMAIN"); domain != "" {
|
||||
config.Domain = domain
|
||||
}
|
||||
|
||||
if corsOrigins := os.Getenv("NOVAMD_CORS_ORIGINS"); corsOrigins != "" {
|
||||
if corsOrigins := os.Getenv("LEMMA_CORS_ORIGINS"); corsOrigins != "" {
|
||||
config.CORSOrigins = strings.Split(corsOrigins, ",")
|
||||
}
|
||||
|
||||
config.AdminEmail = os.Getenv("NOVAMD_ADMIN_EMAIL")
|
||||
config.AdminPassword = os.Getenv("NOVAMD_ADMIN_PASSWORD")
|
||||
config.EncryptionKey = os.Getenv("NOVAMD_ENCRYPTION_KEY")
|
||||
config.JWTSigningKey = os.Getenv("NOVAMD_JWT_SIGNING_KEY")
|
||||
config.AdminEmail = os.Getenv("LEMMA_ADMIN_EMAIL")
|
||||
config.AdminPassword = os.Getenv("LEMMA_ADMIN_PASSWORD")
|
||||
config.EncryptionKey = os.Getenv("LEMMA_ENCRYPTION_KEY")
|
||||
config.JWTSigningKey = os.Getenv("LEMMA_JWT_SIGNING_KEY")
|
||||
|
||||
// Configure rate limiting
|
||||
if reqStr := os.Getenv("NOVAMD_RATE_LIMIT_REQUESTS"); reqStr != "" {
|
||||
if reqStr := os.Getenv("LEMMA_RATE_LIMIT_REQUESTS"); reqStr != "" {
|
||||
parsed, err := strconv.Atoi(reqStr)
|
||||
if err == nil {
|
||||
config.RateLimitRequests = parsed
|
||||
}
|
||||
}
|
||||
|
||||
if windowStr := os.Getenv("NOVAMD_RATE_LIMIT_WINDOW"); windowStr != "" {
|
||||
if windowStr := os.Getenv("LEMMA_RATE_LIMIT_WINDOW"); windowStr != "" {
|
||||
parsed, err := time.ParseDuration(windowStr)
|
||||
if err == nil {
|
||||
config.RateLimitWindow = parsed
|
||||
@@ -123,7 +123,7 @@ func LoadConfig() (*Config, error) {
|
||||
}
|
||||
|
||||
// Configure log level, if isDevelopment is set, default to debug
|
||||
if logLevel := os.Getenv("NOVAMD_LOG_LEVEL"); logLevel != "" {
|
||||
if logLevel := os.Getenv("LEMMA_LOG_LEVEL"); logLevel != "" {
|
||||
parsed := logging.ParseLogLevel(logLevel)
|
||||
config.LogLevel = parsed
|
||||
} else if config.IsDevelopment {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package app_test
|
||||
|
||||
import (
|
||||
"novamd/internal/app"
|
||||
"lemma/internal/app"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
func TestDefaultConfig(t *testing.T) {
|
||||
@@ -17,7 +17,7 @@ func TestDefaultConfig(t *testing.T) {
|
||||
got interface{}
|
||||
expected interface{}
|
||||
}{
|
||||
{"DBPath", cfg.DBPath, "./novamd.db"},
|
||||
{"DBPath", cfg.DBPath, "./lemma.db"},
|
||||
{"WorkDir", cfg.WorkDir, "./data"},
|
||||
{"StaticPath", cfg.StaticPath, "../app/dist"},
|
||||
{"Port", cfg.Port, "8080"},
|
||||
@@ -46,20 +46,20 @@ func TestLoad(t *testing.T) {
|
||||
// Helper function to reset environment variables
|
||||
cleanup := func() {
|
||||
envVars := []string{
|
||||
"NOVAMD_ENV",
|
||||
"NOVAMD_DB_PATH",
|
||||
"NOVAMD_WORKDIR",
|
||||
"NOVAMD_STATIC_PATH",
|
||||
"NOVAMD_PORT",
|
||||
"NOVAMD_ROOT_URL",
|
||||
"NOVAMD_DOMAIN",
|
||||
"NOVAMD_CORS_ORIGINS",
|
||||
"NOVAMD_ADMIN_EMAIL",
|
||||
"NOVAMD_ADMIN_PASSWORD",
|
||||
"NOVAMD_ENCRYPTION_KEY",
|
||||
"NOVAMD_JWT_SIGNING_KEY",
|
||||
"NOVAMD_RATE_LIMIT_REQUESTS",
|
||||
"NOVAMD_RATE_LIMIT_WINDOW",
|
||||
"LEMMA_ENV",
|
||||
"LEMMA_DB_PATH",
|
||||
"LEMMA_WORKDIR",
|
||||
"LEMMA_STATIC_PATH",
|
||||
"LEMMA_PORT",
|
||||
"LEMMA_ROOT_URL",
|
||||
"LEMMA_DOMAIN",
|
||||
"LEMMA_CORS_ORIGINS",
|
||||
"LEMMA_ADMIN_EMAIL",
|
||||
"LEMMA_ADMIN_PASSWORD",
|
||||
"LEMMA_ENCRYPTION_KEY",
|
||||
"LEMMA_JWT_SIGNING_KEY",
|
||||
"LEMMA_RATE_LIMIT_REQUESTS",
|
||||
"LEMMA_RATE_LIMIT_WINDOW",
|
||||
}
|
||||
for _, env := range envVars {
|
||||
if err := os.Unsetenv(env); err != nil {
|
||||
@@ -73,17 +73,17 @@ func TestLoad(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
// Set required env vars
|
||||
setEnv(t, "NOVAMD_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "NOVAMD_ADMIN_PASSWORD", "password123")
|
||||
setEnv(t, "NOVAMD_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=") // 32 bytes base64 encoded
|
||||
setEnv(t, "LEMMA_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "LEMMA_ADMIN_PASSWORD", "password123")
|
||||
setEnv(t, "LEMMA_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=") // 32 bytes base64 encoded
|
||||
|
||||
cfg, err := app.LoadConfig()
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
|
||||
if cfg.DBPath != "./novamd.db" {
|
||||
t.Errorf("default DBPath = %v, want %v", cfg.DBPath, "./novamd.db")
|
||||
if cfg.DBPath != "./lemma.db" {
|
||||
t.Errorf("default DBPath = %v, want %v", cfg.DBPath, "./lemma.db")
|
||||
}
|
||||
})
|
||||
|
||||
@@ -93,19 +93,19 @@ func TestLoad(t *testing.T) {
|
||||
|
||||
// Set all environment variables
|
||||
envs := map[string]string{
|
||||
"NOVAMD_ENV": "development",
|
||||
"NOVAMD_DB_PATH": "/custom/db/path.db",
|
||||
"NOVAMD_WORKDIR": "/custom/work/dir",
|
||||
"NOVAMD_STATIC_PATH": "/custom/static/path",
|
||||
"NOVAMD_PORT": "3000",
|
||||
"NOVAMD_ROOT_URL": "http://localhost:3000",
|
||||
"NOVAMD_CORS_ORIGINS": "http://localhost:3000,http://localhost:3001",
|
||||
"NOVAMD_ADMIN_EMAIL": "admin@example.com",
|
||||
"NOVAMD_ADMIN_PASSWORD": "password123",
|
||||
"NOVAMD_ENCRYPTION_KEY": "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=",
|
||||
"NOVAMD_JWT_SIGNING_KEY": "secret-key",
|
||||
"NOVAMD_RATE_LIMIT_REQUESTS": "200",
|
||||
"NOVAMD_RATE_LIMIT_WINDOW": "30m",
|
||||
"LEMMA_ENV": "development",
|
||||
"LEMMA_DB_PATH": "/custom/db/path.db",
|
||||
"LEMMA_WORKDIR": "/custom/work/dir",
|
||||
"LEMMA_STATIC_PATH": "/custom/static/path",
|
||||
"LEMMA_PORT": "3000",
|
||||
"LEMMA_ROOT_URL": "http://localhost:3000",
|
||||
"LEMMA_CORS_ORIGINS": "http://localhost:3000,http://localhost:3001",
|
||||
"LEMMA_ADMIN_EMAIL": "admin@example.com",
|
||||
"LEMMA_ADMIN_PASSWORD": "password123",
|
||||
"LEMMA_ENCRYPTION_KEY": "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=",
|
||||
"LEMMA_JWT_SIGNING_KEY": "secret-key",
|
||||
"LEMMA_RATE_LIMIT_REQUESTS": "200",
|
||||
"LEMMA_RATE_LIMIT_WINDOW": "30m",
|
||||
}
|
||||
|
||||
for k, v := range envs {
|
||||
@@ -165,38 +165,38 @@ func TestLoad(t *testing.T) {
|
||||
name: "missing admin email",
|
||||
setupEnv: func(t *testing.T) {
|
||||
cleanup()
|
||||
setEnv(t, "NOVAMD_ADMIN_PASSWORD", "password123")
|
||||
setEnv(t, "NOVAMD_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
|
||||
setEnv(t, "LEMMA_ADMIN_PASSWORD", "password123")
|
||||
setEnv(t, "LEMMA_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
|
||||
},
|
||||
expectedError: "NOVAMD_ADMIN_EMAIL and NOVAMD_ADMIN_PASSWORD must be set",
|
||||
expectedError: "LEMMA_ADMIN_EMAIL and LEMMA_ADMIN_PASSWORD must be set",
|
||||
},
|
||||
{
|
||||
name: "missing admin password",
|
||||
setupEnv: func(t *testing.T) {
|
||||
cleanup()
|
||||
setEnv(t, "NOVAMD_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "NOVAMD_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
|
||||
setEnv(t, "LEMMA_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "LEMMA_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
|
||||
},
|
||||
expectedError: "NOVAMD_ADMIN_EMAIL and NOVAMD_ADMIN_PASSWORD must be set",
|
||||
expectedError: "LEMMA_ADMIN_EMAIL and LEMMA_ADMIN_PASSWORD must be set",
|
||||
},
|
||||
{
|
||||
name: "missing encryption key",
|
||||
setupEnv: func(t *testing.T) {
|
||||
cleanup()
|
||||
setEnv(t, "NOVAMD_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "NOVAMD_ADMIN_PASSWORD", "password123")
|
||||
setEnv(t, "LEMMA_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "LEMMA_ADMIN_PASSWORD", "password123")
|
||||
},
|
||||
expectedError: "invalid NOVAMD_ENCRYPTION_KEY: encryption key is required",
|
||||
expectedError: "invalid LEMMA_ENCRYPTION_KEY: encryption key is required",
|
||||
},
|
||||
{
|
||||
name: "invalid encryption key",
|
||||
setupEnv: func(t *testing.T) {
|
||||
cleanup()
|
||||
setEnv(t, "NOVAMD_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "NOVAMD_ADMIN_PASSWORD", "password123")
|
||||
setEnv(t, "NOVAMD_ENCRYPTION_KEY", "invalid-key")
|
||||
setEnv(t, "LEMMA_ADMIN_EMAIL", "admin@example.com")
|
||||
setEnv(t, "LEMMA_ADMIN_PASSWORD", "password123")
|
||||
setEnv(t, "LEMMA_ENCRYPTION_KEY", "invalid-key")
|
||||
},
|
||||
expectedError: "invalid NOVAMD_ENCRYPTION_KEY: invalid base64 encoding: illegal base64 data at input byte 7",
|
||||
expectedError: "invalid LEMMA_ENCRYPTION_KEY: invalid base64 encoding: illegal base64 data at input byte 7",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/models"
|
||||
"novamd/internal/secrets"
|
||||
"novamd/internal/storage"
|
||||
"lemma/internal/auth"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/models"
|
||||
"lemma/internal/secrets"
|
||||
"lemma/internal/storage"
|
||||
)
|
||||
|
||||
// initSecretsService initializes the secrets service
|
||||
@@ -79,7 +79,7 @@ func initAuth(cfg *Config, database db.Database) (auth.JWTManager, auth.SessionM
|
||||
func setupAdminUser(database db.Database, storageManager storage.Manager, cfg *Config) error {
|
||||
// Check if admin user exists
|
||||
adminUser, err := database.GetUserByEmail(cfg.AdminEmail)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
if err != nil && !strings.Contains(err.Error(), "user not found") {
|
||||
return fmt.Errorf("failed to check for existing admin user: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/storage"
|
||||
"lemma/internal/auth"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/storage"
|
||||
)
|
||||
|
||||
// Options holds all dependencies and configuration for the server
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/handlers"
|
||||
"novamd/internal/logging"
|
||||
"lemma/internal/auth"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/handlers"
|
||||
"lemma/internal/logging"
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
httpSwagger "github.com/swaggo/http-swagger"
|
||||
|
||||
_ "novamd/docs" // Swagger docs
|
||||
_ "lemma/docs" // Swagger docs
|
||||
)
|
||||
|
||||
// setupRouter creates and configures the chi router with middleware and routes
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"lemma/internal/logging"
|
||||
"net/http"
|
||||
"novamd/internal/logging"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"lemma/internal/logging"
|
||||
"net/http"
|
||||
"novamd/internal/logging"
|
||||
)
|
||||
|
||||
var logger logging.Logger
|
||||
|
||||
@@ -4,7 +4,7 @@ package auth
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"novamd/internal/logging"
|
||||
"lemma/internal/logging"
|
||||
"time"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"novamd/internal/auth"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/auth"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
func TestNewJWTService(t *testing.T) {
|
||||
|
||||
@@ -2,9 +2,9 @@ package auth
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/logging"
|
||||
"net/http"
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/logging"
|
||||
)
|
||||
|
||||
func getMiddlewareLogger() logging.Logger {
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/auth"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/models"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
// Mock SessionManager
|
||||
|
||||
@@ -2,9 +2,9 @@ package auth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/models"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/auth"
|
||||
"lemma/internal/models"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
// Mock SessionStore
|
||||
|
||||
@@ -4,9 +4,9 @@ package context
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/models"
|
||||
"net/http"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/models"
|
||||
)
|
||||
|
||||
type contextKey string
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/context"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/context"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
func TestGetRequestContext(t *testing.T) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"lemma/internal/db"
|
||||
"net/http"
|
||||
"novamd/internal/db"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/models"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
// MockDB implements the minimal database interface needed for testing
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/models"
|
||||
"novamd/internal/secrets"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/models"
|
||||
"lemma/internal/secrets"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3" // SQLite driver
|
||||
)
|
||||
|
||||
@@ -3,9 +3,9 @@ package db_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"novamd/internal/db"
|
||||
"lemma/internal/db"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
_ "lemma/internal/testenv"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/models"
|
||||
)
|
||||
|
||||
// CreateSession inserts a new session record into the database
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/models"
|
||||
_ "lemma/internal/testenv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/models"
|
||||
_ "lemma/internal/testenv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package db
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/models"
|
||||
)
|
||||
|
||||
// CreateUser inserts a new user record into the database
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/models"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
func TestUserOperations(t *testing.T) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package db
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/models"
|
||||
)
|
||||
|
||||
// CreateWorkspace inserts a new workspace record into the database
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/models"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
func TestWorkspaceOperations(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"novamd/internal/logging"
|
||||
"lemma/internal/logging"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
|
||||
@@ -3,12 +3,12 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/models"
|
||||
"lemma/internal/storage"
|
||||
"net/http"
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/models"
|
||||
"novamd/internal/storage"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/handlers"
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/handlers"
|
||||
"lemma/internal/models"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"lemma/internal/auth"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/models"
|
||||
"net/http"
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/models"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"novamd/internal/handlers"
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/handlers"
|
||||
"lemma/internal/models"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/storage"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/storage"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/models"
|
||||
"novamd/internal/storage"
|
||||
"lemma/internal/models"
|
||||
"lemma/internal/storage"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -2,9 +2,9 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/logging"
|
||||
"net/http"
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/logging"
|
||||
)
|
||||
|
||||
// CommitRequest represents a request to commit changes
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/models"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -2,10 +2,10 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/storage"
|
||||
"net/http"
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/storage"
|
||||
)
|
||||
|
||||
// ErrorResponse is a generic error response
|
||||
|
||||
@@ -14,15 +14,15 @@ import (
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"novamd/internal/app"
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/git"
|
||||
"novamd/internal/models"
|
||||
"novamd/internal/secrets"
|
||||
"novamd/internal/storage"
|
||||
"lemma/internal/app"
|
||||
"lemma/internal/auth"
|
||||
"lemma/internal/db"
|
||||
"lemma/internal/git"
|
||||
"lemma/internal/models"
|
||||
"lemma/internal/secrets"
|
||||
"lemma/internal/storage"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
// testHarness encapsulates all the dependencies needed for testing
|
||||
@@ -50,7 +50,7 @@ func setupTestHarness(t *testing.T) *testHarness {
|
||||
t.Helper()
|
||||
|
||||
// Create temporary directory for test files
|
||||
tempDir, err := os.MkdirTemp("", "novamd-test-*")
|
||||
tempDir, err := os.MkdirTemp("", "lemma-test-*")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create temp directory: %v", err)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"lemma/internal/logging"
|
||||
"net/http"
|
||||
"novamd/internal/logging"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/handlers"
|
||||
"lemma/internal/handlers"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
func TestStaticHandler_Integration(t *testing.T) {
|
||||
// Create temporary directory for test static files
|
||||
tempDir, err := os.MkdirTemp("", "novamd-static-test-*")
|
||||
tempDir, err := os.MkdirTemp("", "lemmastatic-test-*")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/logging"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/logging"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/handlers"
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/handlers"
|
||||
"lemma/internal/models"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/logging"
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/context"
|
||||
"lemma/internal/logging"
|
||||
"lemma/internal/models"
|
||||
)
|
||||
|
||||
// DeleteWorkspaceResponse contains the name of the next workspace after deleting the current one
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/models"
|
||||
"lemma/internal/models"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"novamd/internal/logging"
|
||||
"lemma/internal/logging"
|
||||
)
|
||||
|
||||
// Service is an interface for encrypting and decrypting strings
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/secrets"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/secrets"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
func TestValidateKey(t *testing.T) {
|
||||
|
||||
@@ -2,11 +2,11 @@ package storage_test
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"novamd/internal/storage"
|
||||
"lemma/internal/storage"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
// TestFileNode ensures FileNode structs are created correctly
|
||||
|
||||
@@ -2,7 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"novamd/internal/logging"
|
||||
"lemma/internal/logging"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
type mockDirEntry struct {
|
||||
|
||||
@@ -2,7 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"novamd/internal/git"
|
||||
"lemma/internal/git"
|
||||
)
|
||||
|
||||
// RepositoryManager defines the interface for managing Git repositories.
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/git"
|
||||
"novamd/internal/storage"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/git"
|
||||
"lemma/internal/storage"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
// MockGitClient implements git.Client interface for testing
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"novamd/internal/git"
|
||||
"lemma/internal/git"
|
||||
)
|
||||
|
||||
// Manager interface combines all storage interfaces.
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/storage"
|
||||
_ "novamd/internal/testenv"
|
||||
"lemma/internal/storage"
|
||||
_ "lemma/internal/testenv"
|
||||
)
|
||||
|
||||
func TestValidatePath(t *testing.T) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package testenv provides a setup for testing the application.
|
||||
package testenv
|
||||
|
||||
import "novamd/internal/logging"
|
||||
import "lemma/internal/logging"
|
||||
|
||||
func init() {
|
||||
// Initialize the logger
|
||||
|
||||
Reference in New Issue
Block a user