Skip to content

Commit fd9f8a3

Browse files
cevianclaude
andauthored
Add spec for tiger db create role command (#58)
Implement `tiger db create role` command Adds a new command to create PostgreSQL database roles with enhanced safety features for AI agents and automated tools. Features: - Create roles with auto-generated or explicit passwords - Read-only enforcement via tsdb_admin.read_only_role for safe AI agent access - Inherit permissions from existing roles with --from flag (supports multiple roles) - Statement timeout configuration for query time limits - Password storage integration (keyring/pgpass) - Special handling for tsdbadmin inheritance using TimescaleDB Cloud functions Implementation details: - Uses transactions for atomic role creation and configuration - Supports both standard PostgreSQL role creation and TimescaleDB Cloud special functions - Handles --from tsdbadmin with timescale_functions.create_bare_readonly_role() and timescale_functions.grant_tsdbadmin_to_role() to bypass ADMIN OPTION restrictions - Validates that tsdbadmin inheritance requires --read-only flag - Prevents SQL injection with proper identifier sanitization - StringSliceVar for --from flag supporting both comma-separated and multiple flags Testing: - Comprehensive integration tests for all role creation scenarios - Tests for read-only enforcement with table access verification - Tests for role inheritance and permission grants - SQL injection prevention tests - Duplicate role name error handling Documentation: - Added detailed specifications in specs/spec.md - Updated CLAUDE.md with development guidelines - Created integration test helper script for easier testing - Documented default permissions behavior and use cases Fixes: - Fixed authentication test failures by removing invalid --project-id flags - Renamed TestServiceNotFound to TestServiceNotFoundIntegration for pattern matching - Simplified test-integration.sh script from 84 to 31 lines following Unix philosophy Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5120c35 commit fd9f8a3

File tree

6 files changed

+1236
-13
lines changed

6 files changed

+1236
-13
lines changed

CLAUDE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,32 @@ go run ./cmd/tiger --help
3838
```
3939

4040
### Integration Testing
41+
42+
#### Using the Test Script (Recommended)
43+
```bash
44+
# Run all integration tests (default pattern: Integration)
45+
./scripts/test-integration.sh
46+
47+
# Run with verbose output
48+
./scripts/test-integration.sh -v
49+
50+
# Run specific test pattern (overrides default)
51+
./scripts/test-integration.sh -run CreateRole
52+
53+
# Run with custom timeout
54+
./scripts/test-integration.sh -timeout 10m
55+
56+
# Combine flags (any go test flags are supported)
57+
./scripts/test-integration.sh -v -run CreateRole_WithInheritedGrants -timeout 5m
58+
```
59+
60+
The script automatically:
61+
- Loads environment variables from `.env` file
62+
- Builds the tiger CLI binary
63+
- Runs tests matching "Integration" pattern by default
64+
- Passes all arguments through to `go test` (supports all standard go test flags)
65+
66+
#### Manual Testing
4167
```bash
4268
# Run all tests (integration tests will skip without credentials)
4369
go test ./...

0 commit comments

Comments
 (0)