brewlog/tests/cli/invites_cli.rs
Niels Göttsch 9cf8ce5d79 feat(auth): generate additional invite links for onboarding users
Add an authenticated POST /api/v1/invites endpoint that mints a
single-use, 7-day registration link after the first-user bootstrap.
Expose it via a new "Invite" section on the admin page and a
`brewlog invite create` CLI command.

The registration_tokens table, repository, and NewRegistrationToken
already supported additional tokens; this adds the authenticated
surfaces (session cookie or bearer token) to trigger creation.
2026-07-16 12:38:36 +02:00

26 lines
721 B
Rust

use crate::helpers::{create_token, run_brewlog};
use crate::test_macros::define_cli_auth_test;
define_cli_auth_test!(
test_create_invite_requires_authentication,
&["invite", "create"]
);
#[test]
fn test_create_invite_with_authentication() {
let token = create_token("test-create-invite");
let output = run_brewlog(&["invite", "create"], &[("BREWLOG_TOKEN", &token)]);
assert!(
output.status.success(),
"invite create with auth should succeed: {}",
String::from_utf8_lossy(&output.stderr)
);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("/register/"),
"Should print a registration link, got: {stdout}"
);
}