mcp-context-forge icon indicating copy to clipboard operation
mcp-context-forge copied to clipboard

[TESTING][SECURITY]: Core authentication manual test plan (JWT, Basic Auth, API tokens, email/password)

Open crivetimihai opened this issue 10 months ago β€’ 7 comments

πŸ” Testing: Core Authentication Manual Test Plan

Goal

Produce a comprehensive manual test plan for all local/internal authentication mechanisms including JWT tokens, Basic Auth, API tokens, and email/password authentication. This plan validates that authentication works correctly, securely rejects invalid credentials, and properly handles edge cases.

Why Now?

Core authentication is the foundation of the security model. Manual testing is needed to:

  1. Security Baseline: Validate that all authentication methods correctly identify and authenticate users before Release 1.0.0-RC1
  2. Credential Handling: Ensure invalid, expired, and malformed credentials are properly rejected with appropriate error messages
  3. Integration Validation: Verify authentication works consistently across all API endpoints and transports
  4. Regression Prevention: Establish baseline for automated regression testing

πŸ“– User Stories

US-1: Security Engineer - JWT Token Validation

As a Security Engineer I want comprehensive tests for JWT token validation So that I can verify tokens are properly verified and invalid tokens are rejected

Acceptance Criteria:

Feature: JWT Token Validation

  Scenario: Valid JWT token grants access
    Given a JWT token signed with the correct secret
    And the token has not expired
    And the token contains valid claims (sub, exp, iat)
    When I make a request with the token in Authorization header
    Then the request should return status 200
    And the user context should be populated from token claims

  Scenario: Expired JWT token is rejected
    Given a JWT token that expired 1 hour ago
    When I make a request with the expired token
    Then the request should return status 401
    And the response should indicate "Token has expired"

  Scenario: JWT with invalid signature is rejected
    Given a JWT token signed with an incorrect secret
    When I make a request with the invalid token
    Then the request should return status 401
    And the response should indicate "Invalid token signature"

  Scenario: JWT with missing required claims is rejected
    Given a JWT token without the "sub" claim
    When I make a request with the token
    Then the request should return status 401
    And the response should indicate "Invalid token claims"

  Scenario: JWT extracted from cookie when header missing
    Given a valid JWT token stored in the "jwt_token" cookie
    And no Authorization header is present
    When I make a request with the cookie
    Then the request should return status 200
    And the user should be authenticated from the cookie token

  Scenario Outline: JWT audience/issuer validation
    Given REQUIRE_TOKEN_EXPIRATION is <exp_required>
    And a JWT token with <token_state>
    When I make a request with the token
    Then the request should return status <status>

    Examples:
      | exp_required | token_state      | status |
      | true         | no exp claim     | 401    |
      | false        | no exp claim     | 200    |
      | true         | valid exp claim  | 200    |

Technical Requirements:

  • JWT extracted from Authorization: Bearer <token> header
  • JWT extracted from jwt_token cookie as fallback
  • Signature verification using JWT_SECRET_KEY
  • Configurable expiration requirement (REQUIRE_TOKEN_EXPIRATION)
  • JTI claim support for revocation (REQUIRE_JTI)
US-2: Platform Admin - Basic Authentication

As a Platform Administrator I want tests for Basic Auth username/password validation So that I can verify admin access is properly secured

Acceptance Criteria:

Feature: Basic Authentication

  Scenario: Valid Basic Auth credentials grant access
    Given BASIC_AUTH_USER is "admin"
    And BASIC_AUTH_PASSWORD is "secure-password-123"
    When I make a request with Authorization: Basic <base64(admin:secure-password-123)>
    Then the request should return status 200
    And the user should be authenticated as admin

  Scenario: Invalid Basic Auth password is rejected
    Given BASIC_AUTH_USER is "admin"
    And BASIC_AUTH_PASSWORD is "secure-password-123"
    When I make a request with Authorization: Basic <base64(admin:wrong-password)>
    Then the request should return status 401
    And the response should indicate "Invalid credentials"

  Scenario: Invalid Basic Auth username is rejected
    Given BASIC_AUTH_USER is "admin"
    When I make a request with Authorization: Basic <base64(wronguser:any-password)>
    Then the request should return status 401

  Scenario: Malformed Basic Auth header is rejected
    When I make a request with Authorization: Basic not-valid-base64!!!
    Then the request should return status 401
    And the response should indicate "Invalid authorization header"

  Scenario: Basic Auth with empty password is rejected
    When I make a request with Authorization: Basic <base64(admin:)>
    Then the request should return status 401

  Scenario: Basic Auth header without credentials is rejected
    When I make a request with Authorization: Basic
    Then the request should return status 401

Technical Requirements:

  • Base64 decoding of credentials
  • Constant-time password comparison to prevent timing attacks
  • No information leakage in error messages (don't reveal if username exists)
US-3: Developer - API Token Authentication

As a Developer I want tests for API token authentication So that I can verify programmatic access works correctly

Acceptance Criteria:

Feature: API Token Authentication

  Scenario: Valid API token in Authorization: Bearer header grants access
    Given an active API token exists in the database
    When I make a request with Authorization: Bearer <token-value>
    Then the request should return status 200
    And the user context should match the token owner

  Scenario: Valid API token in Authorization Bearer header grants access
    Given an active API token exists in the database
    When I make a request with Authorization: Bearer <token-value>
    Then the request should return status 200

  Scenario: Revoked API token is rejected
    Given an API token that has been revoked
    When I make a request with the revoked token
    Then the request should return status 401
    And the response should indicate "Token revoked"

  Scenario: Expired API token is rejected
    Given an API token with expires_at in the past
    When I make a request with the expired token
    Then the request should return status 401
    And the response should indicate "Token expired"

  Scenario: Non-existent API token is rejected
    When I make a request with Authorization: Bearer non-existent-token-12345
    Then the request should return status 401
    And the response should indicate "Invalid token"

  Scenario: Inactive API token is rejected
    Given an API token with is_active=false
    When I make a request with the inactive token
    Then the request should return status 401

  Scenario: API token usage is logged
    Given a valid API token
    When I make a request with the token
    Then a TokenUsageLog entry should be created
    And the entry should include timestamp, endpoint, and IP address

Technical Requirements:

  • Token lookup in database by token value
  • Check is_active, expires_at, and revocation status
  • Log token usage for auditing
  • Support both Authorization: Bearer and Authorization Bearer headers
US-4: End User - Email/Password Authentication

As an End User I want tests for email/password login flow So that I can verify the login process works securely

Acceptance Criteria:

Feature: Email/Password Authentication

  Scenario: Valid email and password grants access
    Given a user exists with email "[email protected]"
    And the user's password is "ValidPass123!"
    When I POST to /auth/login with email and password
    Then the request should return status 200
    And the response should contain a JWT access token
    And the response should contain a refresh token

  Scenario: Invalid password is rejected
    Given a user exists with email "[email protected]"
    When I POST to /auth/login with email and wrong password
    Then the request should return status 401
    And the response should indicate "Invalid credentials"
    And an EmailAuthEvent should be logged with success=false

  Scenario: Non-existent email is rejected
    When I POST to /auth/login with email "[email protected]"
    Then the request should return status 401
    And the response should indicate "Invalid credentials"
    And the error should NOT reveal that the email doesn't exist

  Scenario: Inactive user cannot login
    Given a user exists with is_active=false
    When I POST to /auth/login with the user's credentials
    Then the request should return status 401
    And the response should indicate "Account disabled"

  Scenario: Password change required redirects appropriately
    Given a user with password_change_required=true
    When I POST to /auth/login with valid credentials
    Then the request should return status 200
    And the response should include password_change_required=true
    And limited access should be granted until password is changed

  Scenario: Successful login logs authentication event
    Given a valid user
    When I POST to /auth/login with valid credentials
    Then an EmailAuthEvent should be created
    And the event should include client_ip and user_agent
    And the event should have success=true

  Scenario: Failed login attempts are tracked
    Given a valid user
    When I POST to /auth/login with wrong password 5 times
    Then 5 EmailAuthEvent entries should be created with success=false
    And the security logger should detect potential brute force

Technical Requirements:

  • Argon2id password verification
  • JWT token generation on successful login
  • Authentication event logging
  • Password change enforcement
  • Brute force detection integration
US-5: Operations - Proxy Header Authentication

As an Operations Engineer I want tests for proxy/header-based authentication So that I can verify authentication works behind a reverse proxy

Acceptance Criteria:

Feature: Proxy Header Authentication

  Scenario: Trusted proxy header authenticates user
    Given TRUST_PROXY_AUTH is true
    And PROXY_USER_HEADER is "X-Authenticated-User"
    When I make a request with X-Authenticated-User: [email protected]
    Then the request should be authenticated as [email protected]

  Scenario: Proxy header ignored when trust disabled
    Given TRUST_PROXY_AUTH is false
    When I make a request with X-Authenticated-User: [email protected]
    Then the request should return status 401
    And proxy headers should be ignored

  Scenario: Platform admin email grants admin access
    Given TRUST_PROXY_AUTH is true
    And PLATFORM_ADMIN_EMAIL is "[email protected]"
    When I make a request with X-Authenticated-User: [email protected]
    Then the user should have is_admin=true

  Scenario: Empty proxy header is rejected
    Given TRUST_PROXY_AUTH is true
    When I make a request with X-Authenticated-User: (empty)
    Then the request should return status 401

  Scenario: Malformed email in proxy header is rejected
    Given TRUST_PROXY_AUTH is true
    When I make a request with X-Authenticated-User: not-an-email
    Then the request should return status 401
    And the response should indicate "Invalid user identifier"

Technical Requirements:

  • TRUST_PROXY_AUTH configuration toggle
  • Configurable header name (PROXY_USER_HEADER)
  • Email validation for proxy header value
  • Platform admin email matching
US-6: Security Auditor - Authentication Failure Handling

As a Security Auditor I want tests for authentication failure handling So that I can verify errors don't leak sensitive information

Acceptance Criteria:

Feature: Authentication Failure Handling

  Scenario: No authentication provided returns 401
    Given AUTH_REQUIRED is true
    When I make a request without any authentication
    Then the request should return status 401
    And the response should indicate "Authentication required"

  Scenario: Error messages don't reveal internal details
    When I make a request with an invalid JWT token
    Then the response should NOT contain stack traces
    And the response should NOT contain internal error messages
    And the response should NOT contain file paths

  Scenario: Authentication errors are logged
    When authentication fails for any reason
    Then the failure should be logged with:
      | Field | Value |
      | level | WARNING or ERROR |
      | reason | failure type |
      | client_ip | request IP |
      | endpoint | request path |

  Scenario: Multiple auth methods tried in order
    Given a request with both Authorization header and Authorization: Bearer
    When the request is processed
    Then Bearer token should be tried first
    And API key should be tried if Bearer fails
    And the first successful auth should be used

  Scenario: Malformed Authorization header type is rejected
    When I make a request with Authorization: Digest abc123
    Then the request should return status 401
    And only Bearer and Basic types should be accepted

Technical Requirements:

  • Consistent error response format
  • No information disclosure in errors
  • Proper logging of all authentication attempts
  • Clear authentication method precedence

πŸ— Test Architecture

Authentication Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        AUTHENTICATION DECISION FLOW                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚ Incoming Request β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚ Has Authorizationβ”‚
                              β”‚ Header?          β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ YES                                 β”‚ NO
                    β–Ό                                     β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ Parse Header    β”‚                   β”‚ Has Authorization: Bearer   β”‚
          β”‚ Type            β”‚                   β”‚ Header?         β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚                                     β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚          β”‚          β”‚               β”‚ YES                β”‚ NO
        β–Ό          β–Ό          β–Ό               β–Ό                    β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Bearer β”‚ β”‚ Basic  β”‚ β”‚ Other  β”‚    β”‚ API Token β”‚      β”‚ Has Cookie?   β”‚
   β”‚ Token  β”‚ β”‚ Auth   β”‚ β”‚ Type   β”‚    β”‚ Lookup    β”‚      β”‚ jwt_token  β”‚
   β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚          β”‚          β”‚               β”‚                    β”‚
       β–Ό          β–Ό          β–Ό               β”‚          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚          β”‚ YES             β”‚ NO
   β”‚ JWT    β”‚ β”‚ User/  β”‚ β”‚ Reject β”‚          β”‚          β–Ό                 β–Ό
   β”‚ Verify β”‚ β”‚ Pass   β”‚ β”‚ 401    β”‚          β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚ Check  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚    β”‚ JWT from  β”‚   β”‚ Proxy Auth? β”‚
       β”‚      β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜                     β”‚    β”‚ Cookie    β”‚   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚          β”‚                          β”‚    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜          β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚ Auth Success?    β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ YES                                 β”‚ NO
                    β–Ό                                     β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ Populate        β”‚                   β”‚ Return 401      β”‚
          β”‚ request.state   β”‚                   β”‚ Unauthorized    β”‚
          β”‚ .user           β”‚                   β”‚                 β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

JWT Token Structure

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           JWT TOKEN CLAIMS                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Header (Algorithm & Type)
{
  "alg": "HS256",
  "typ": "JWT"
}

Payload (Claims)
{
  "sub": "[email protected]",     # Subject (user email) - REQUIRED
  "exp": 1735689600,             # Expiration time - REQUIRED if REQUIRE_TOKEN_EXPIRATION
  "iat": 1735603200,             # Issued at time
  "jti": "unique-token-id",      # JWT ID - REQUIRED if REQUIRE_JTI
  "teams": ["team-alpha"],       # Team memberships (null = admin)
  "is_admin": false,             # Admin flag
  "permissions": ["tools.read"], # Optional permission restrictions
  "environment": "production"    # Environment claim for isolation
}

Signature
HMACSHA256(
  base64UrlEncode(header) + "." + base64UrlEncode(payload),
  JWT_SECRET_KEY
)

Authentication Method Precedence

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    AUTHENTICATION METHOD PRECEDENCE                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Priority β”‚ Method              β”‚ Header/Source              β”‚ Notes
─────────┼─────────────────────┼────────────────────────────┼─────────────────
   1     β”‚ Bearer Token (JWT)  β”‚ Authorization: Bearer xxx  β”‚ Primary method
   2     β”‚ Basic Auth          β”‚ Authorization: Basic xxx   β”‚ Admin access
   3     β”‚ API Token           β”‚ Authorization: Bearer xxx             β”‚ Programmatic
   4     β”‚ API Token           β”‚ Authorization: Bearer xxx  β”‚ Fallback lookup
   5     β”‚ Cookie Token        β”‚ Cookie: jwt_token=xxx   β”‚ Web UI sessions
   6     β”‚ Proxy Header        β”‚ X-Authenticated-User: xxx      β”‚ If TRUST_PROXY_AUTH

πŸ“‹ Test Environment Setup

Prerequisites

0. Start Docker Compose Stack

# Start the stack
docker compose up -d

# Verify health
curl http://localhost:8080/health

1. Configuration

# Core authentication settings
export JWT_SECRET_KEY="test-secret-key-minimum-32-characters-long"
export BASIC_AUTH_USER="admin"
export BASIC_AUTH_PASSWORD="AdminPass123!"
export AUTH_REQUIRED=true
export REQUIRE_TOKEN_EXPIRATION=true
export REQUIRE_JTI=false

# Proxy authentication (disabled by default)
export TRUST_PROXY_AUTH=false
export PROXY_USER_HEADER="X-Authenticated-User"
export PLATFORM_ADMIN_EMAIL="[email protected]"

2. Test Users

Create the following test users in the database:

Email Password is_admin is_active password_change_required
[email protected] ActivePass123! false true false
[email protected] AdminPass123! true true false
[email protected] InactivePass123! false false false
[email protected] TempPass123! false true true
# Create test users via API (requires admin token)
curl -X POST "http://localhost:8080/auth/email/admin/users" \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "ActivePass123!",
    "is_admin": false
  }'

3. Test Tokens

Generate tokens for testing:

# Valid JWT token (expires in 1 hour)
export VALID_JWT=$(python -m mcpgateway.utils.create_jwt_token \
  --username [email protected] \
  --exp 60 \
  --secret "$JWT_SECRET_KEY")

# Expired JWT token
export EXPIRED_JWT=$(python -m mcpgateway.utils.create_jwt_token \
  --username [email protected] \
  --exp -60 \
  --secret "$JWT_SECRET_KEY")

# JWT with wrong signature
export INVALID_SIG_JWT=$(python -m mcpgateway.utils.create_jwt_token \
  --username [email protected] \
  --exp 60 \
  --secret "wrong-secret-key-for-testing")

# Admin JWT token
export ADMIN_JWT=$(python -m mcpgateway.utils.create_jwt_token \
  --username [email protected] \
  --is-admin \
  --exp 60 \
  --secret "$JWT_SECRET_KEY")

# Base64 encoded Basic Auth
export BASIC_AUTH_VALID=$(echo -n "admin:AdminPass123!" | base64)
export BASIC_AUTH_INVALID=$(echo -n "admin:wrongpassword" | base64)

4. API Tokens

Create API tokens in the database for testing:

# Create a valid API token
curl -X POST "http://localhost:8080/tokens" \
  -H "Authorization: Bearer $ADMIN_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "test-api-token",
    "expires_in_days": 30
  }'
# Save the returned token value as TEST_API_TOKEN

πŸ§ͺ Manual Test Cases

Section 1: JWT Token Authentication

Case Token State Expected HTTP Status
JWT-01 Valid, not expired Authenticated 200
JWT-02 Expired Rejected 401
JWT-03 Invalid signature Rejected 401
JWT-04 Missing sub claim Rejected 401
JWT-05 Missing exp (required) Rejected 401
JWT-06 Missing exp (not required) Authenticated 200
JWT-07 Revoked (JTI in blacklist) Rejected 401
JWT-08 Malformed (not valid JWT) Rejected 401
JWT-09 Empty token Rejected 401
JWT-10 From cookie (valid) Authenticated 200
JWT-01: Valid JWT token authenticates

Preconditions:

  • Valid JWT token generated with correct secret
  • Token not expired

Steps:

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $VALID_JWT" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 200 OK
  • Response contains list of accessible tools
  • User context populated from token claims
JWT-02: Expired JWT token rejected

Preconditions:

  • JWT token with exp claim in the past

Steps:

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $EXPIRED_JWT" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 401 Unauthorized
  • Response: {"detail": "Token has expired"} or similar
  • No user context populated
JWT-03: Invalid signature rejected

Preconditions:

  • JWT token signed with incorrect secret

Steps:

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $INVALID_SIG_JWT" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 401 Unauthorized
  • Response indicates invalid token
  • No information about the secret leaked
JWT-10: JWT from cookie authenticates

Preconditions:

  • Valid JWT token
  • No Authorization header

Steps:

curl -X GET "http://localhost:8080/tools" \
  -H "Cookie: jwt_token=$VALID_JWT" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 200 OK
  • User authenticated from cookie token

Section 2: Basic Authentication

Case Credentials Expected HTTP Status
BASIC-01 Valid username/password Authenticated 200
BASIC-02 Invalid password Rejected 401
BASIC-03 Invalid username Rejected 401
BASIC-04 Malformed base64 Rejected 401
BASIC-05 Empty password Rejected 401
BASIC-06 Empty username Rejected 401
BASIC-07 Missing colon separator Rejected 401
BASIC-01: Valid Basic Auth credentials

Preconditions:

  • BASIC_AUTH_USER and BASIC_AUTH_PASSWORD configured

Steps:

curl -X GET "http://localhost:8080/health" \
  -H "Authorization: Basic $BASIC_AUTH_VALID" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 200 OK
  • User authenticated as admin
BASIC-02: Invalid password rejected

Preconditions:

  • BASIC_AUTH_USER configured

Steps:

curl -X GET "http://localhost:8080/health" \
  -H "Authorization: Basic $BASIC_AUTH_INVALID" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 401 Unauthorized
  • Response does not reveal that password was wrong (vs username)

Section 3: API Token Authentication

Case Token State Expected HTTP Status
API-01 Valid, active Authenticated 200
API-02 Revoked Rejected 401
API-03 Expired Rejected 401
API-04 Non-existent Rejected 401
API-05 Inactive (is_active=false) Rejected 401
API-06 Via Authorization: Bearer header Authenticated 200
API-07 Via Authorization Bearer Authenticated 200
API-01: Valid API token authenticates

Preconditions:

  • Active API token exists in database

Steps:

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $TEST_API_TOKEN" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 200 OK
  • User context matches token owner
  • TokenUsageLog entry created

Section 4: Email/Password Authentication

Case Credentials Expected HTTP Status
EMAIL-01 Valid email/password JWT returned 200
EMAIL-02 Invalid password Rejected 401
EMAIL-03 Non-existent email Rejected 401
EMAIL-04 Inactive user Rejected 401
EMAIL-05 Password change required Limited access 200
EMAIL-01: Valid login returns JWT

Preconditions:

Steps:

curl -X POST "http://localhost:8080/auth/login" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "ActivePass123!"
  }' \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 200 OK
  • Response contains jwt_token (JWT)
  • Response may contain refresh_token
  • EmailAuthEvent logged with success=true
EMAIL-03: Non-existent email rejected without revealing

Preconditions:

  • Email does not exist in database

Steps:

curl -X POST "http://localhost:8080/auth/login" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "AnyPassword123!"
  }' \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

  • HTTP 401 Unauthorized
  • Response: {"detail": "Invalid credentials"}
  • Error message does NOT reveal that email doesn't exist
  • Same response as invalid password (timing-safe)

Section 5: Proxy Header Authentication

Case Configuration Header Expected HTTP Status
PROXY-01 TRUST=true Valid email Authenticated 200
PROXY-02 TRUST=false Valid email Ignored, 401 401
PROXY-03 TRUST=true Platform admin Admin access 200
PROXY-04 TRUST=true Empty header Rejected 401
PROXY-05 TRUST=true Invalid email Rejected 401
PROXY-01: Trusted proxy header authenticates

Preconditions:

  • TRUST_PROXY_AUTH=true
  • PROXY_USER_HEADER=X-Authenticated-User

Steps:

curl -X GET "http://localhost:8080/tools" \
  -H "X-Authenticated-User: [email protected]" \
  -w "\nHTTP Status: %{http_code}\n"

Expected Result:

Section 6: Authentication Edge Cases

Case Scenario Expected HTTP Status
EDGE-01 No auth, AUTH_REQUIRED=true Rejected 401
EDGE-02 No auth, AUTH_REQUIRED=false Anonymous access 200
EDGE-03 Multiple auth headers First valid wins 200
EDGE-04 Unsupported auth type Rejected 401
EDGE-05 Null/undefined token Rejected 401

🧾 Complete Test Matrix

JWT Token Validation

# Claim State Secret Expired Expected
1 Valid sub, valid exp Correct No ALLOW
2 Valid sub, valid exp Correct Yes DENY
3 Valid sub, valid exp Wrong No DENY
4 Missing sub Correct No DENY
5 Valid sub, no exp Correct N/A ALLOW (if not required)
6 Valid sub, no exp Correct N/A DENY (if required)
7 Valid, JTI revoked Correct No DENY
8 Malformed JWT N/A N/A DENY

Authentication Method Priority

# Bearer Basic Authorization: Bearer Cookie Proxy Expected Auth
1 Valid - - - - Bearer JWT
2 Invalid Valid - - - Basic Auth
3 - - Valid - - API Token
4 - - - Valid - Cookie JWT
5 - - - - Valid Proxy Header
6 - - - - - 401 (if required)

Error Response Validation

# Scenario Response Must NOT Contain
1 Invalid JWT Stack trace, file paths
2 Wrong password "password incorrect" (vs "user not found")
3 Invalid signature Actual secret or key info
4 Expired token Internal timestamps
5 Any auth failure Database error details

βœ… Success Criteria

  • [x] All JWT validation scenarios tested (valid, expired, invalid signature, missing claims)
  • [x] Basic Auth tested with valid/invalid credentials
  • [x] API token authentication tested across all states
  • [x] Email/password login flow validated
  • [ ] Proxy header authentication tested when enabled/disabled
  • [ ] Error messages verified to not leak sensitive information
  • [ ] Authentication events properly logged
  • [x] Cookie-based JWT authentication working
  • [x] All test cases documented with curl examples
  • [x] Edge cases covered (no auth, multiple auth headers, malformed input)

🏁 Definition of Done

  • [ ] Manual test plan reviewed by Security team
  • [x] All test users and tokens created in test environment
  • [x] All test cases executed with documented results
  • [ ] JWT validation covers all claim scenarios
  • [x] Basic Auth timing-safe password comparison verified
  • [x] API token lifecycle (active, revoked, expired) tested
  • [x] Email/password flow including password change tested
  • [ ] Proxy auth tested in both enabled and disabled modes
  • [ ] Error responses validated for information disclosure
  • [ ] Authentication logging verified (success and failure)
  • [x] Test results documented and any failures triaged
  • [ ] Plan linked to automated regression suite (#TBD)

πŸ”— References

  • mcpgateway/auth.py - Core authentication logic
  • mcpgateway/routers/auth.py - Auth endpoints
  • mcpgateway/services/email_auth_service.py - Email/password service
  • mcpgateway/config.py - Authentication configuration
  • mcpgateway/middleware/rbac.py - RBAC middleware

πŸ“ Notes

πŸ”Ή Timing Attacks: Password comparison must use constant-time comparison to prevent timing attacks that could reveal valid usernames.

πŸ”Ή Error Messages: Authentication errors should be generic ("Invalid credentials") rather than specific ("Password incorrect" vs "User not found") to prevent user enumeration.

πŸ”Ή Token Precedence: When multiple authentication methods are present, Bearer token takes precedence over API key, which takes precedence over cookies.

πŸ”Ή Credential Caching: JWT verification may be cached for performance. Tests should account for cache TTL when testing token revocation.

crivetimihai avatar Jan 25 '26 12:01 crivetimihai

Tested on local environment.

TC01. Create test users

TC01.1 Create active user - Success βœ…

curl -X 'POST' \
'http://localhost:8000/auth/email/admin/users' \
-H 'accept: application/json' \
-H 'Authorization: Bearer $ADMIN_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"email": "[email protected]",
"password": "ActivePass123!",
"full_name": "[email protected]",
"is_admin": false,
"is_active": true,
"password_change_required" : false
}'

Results 201 TC01.2 create inactive user - can not create via API inactive users - defect #2524 - Failed ❌

curl -X 'POST' \
  'http://localhost:8000/auth/email/admin/users' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "[email protected]",
  "password": "InactivePass123!",
  "full_name": "[email protected]",
  "is_admin": false,
   "is_active": false,
   "password_change_required" : false
}'`

Results 201

Image

TC01.3 Create active user that has password_change_required true - defect #2523 - Failed ❌

curl -X 'POST' \
  'http://localhost:8000/auth/email/admin/users' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "[email protected]",
  "password": "TempPass123!",
  "full_name": "[email protected]",
  "is_admin": false,
   "is_active": true,
   "password_change_required" : true
}'`

Results 201 TC01.4 Negative test - Create with the same email run again point 1.3 - Success βœ… Results 409

Image

List users

Image Image

TC01.5 Negative test -Create a user with a password less than 8 characters - Success βœ… Results 422

Image

TC02. Edit Users

TC02.1 Set an user inactive - defect #2524 - Failed ❌

 curl -X 'PUT' \
  'http://localhost:4444/auth/email/admin/users/inactive%40example.com' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "[email protected]",
  "password": "InactivePass123!",
  "full_name": "[email protected]",
  "is_admin": false,
   "is_active":false
}'
Image

TC02.2 Set the password change to true - defect #2523 - Failed ❌

 curl -X 'PUT' \
  'http://localhost:4444/auth/email/admin/users/inactive%40example.com' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "[email protected]",
  "password": "InactivePass123!",
  "full_name": "[email protected]",
  "is_admin": false,
   "is_active":false,
   "password_change_required" : true
}'
Image

TC03 Basic auth on UI

TC03.1 Valid username/password - Success βœ…

Image Image

TC03.2 Inactive user - Success βœ…

Image Image

TC03.3 Invalid username - Success βœ…

Image Image

TC03.4 Invalid password - Success βœ…

Image Image

TC03.5 User with password required changes active - Success βœ…

Image Image Image

TC03.6 Admin user - Success βœ…

Image Image

TC03.7 Delete user - Success βœ…

No notification TC03.8 Empty password - Success βœ…

Image

TC03.9 Empty username - Success βœ…

Image

TC04 API calls - Token

TC04.1 Create a valid API Token via Swagger - 403 error - Failed ❌

curl -X 'POST' \
  'http://localhost:4444/tokens' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_JWT' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "TEST_API_TOKEN_VIA_API",
  "description": "TEST_API_TOKEN_VIA_API expires in 30 Days",
  "expires_in_days": 30
}'
Image

TC04.2 User with no admin access - Success βœ…

Image

TC04.3 Not authenticated - Success βœ…

Image

TC04.4 Admin Token - No Access to Private Tools - Empty list - Success βœ…

Image Image

TC04.5 Admin Token - No Access to Team Tools - Empty list - Success βœ…

Image Image

TC04.6 Admin Token - Access to Public Tools - Lis of tools loaded - Success βœ…

Image Image

TC04.7 Admin Token - Not a Valid token - Code 401 - Success βœ…

Image

IuliaGaitan avatar Jan 27 '26 13:01 IuliaGaitan

Case Token State Expected HTTP Status Test Status
TC04.1 Create a valid API Token Authenticated 200 Pass βœ…
TC04.2 Valid with user with no admin access Authenticated 200 Pass βœ…
TC04.3 Not authenticated Not authenticated 500 Pass βœ…
TC04.4 Admin Token - No Access to Private Tools - Empty list Authenticated 200 Pass βœ…
TC04.5 Admin Token - No Access to Team Tools - Empty list Authenticated 200 Pass βœ…
TC04.6 Admin Token - Access to Public Tools - Lis of tools loaded Authenticated 200 Pass βœ…
TC04.7 Admin Token - Not a Valid token Authenticated 200 Pass βœ…
TC04.8 Use create token on TC04.1 and try to check data Authenticated 200 Pass βœ…
TC04.9 Create a API Token inactive via Swagger Authenticated 201 Failed ❌
TC04.10 Update an API Token via Swagger Authenticated 201 Failed ❌
TC04.11 UI API Tokens - Last Used and Usage Stats not showing any data Authenticated 200 Failed ❌
TC04.12 Expired Rejected 401 Pass βœ…
TC04.13 Revoked Rejected 401 Pass βœ…
TC04.14 Malformed Rejected 401 Pass βœ…

TC04.1 Create a valid API Token via Swagger - 201 message - Success βœ…

curl -X 'POST' \
  'http://localhost:4444/tokens' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_JWT' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "TEST_API_TOKEN_VIA_API",
  "description": "TEST_API_TOKEN_VIA_API expires in 30 Days",
  "expires_in_days": 30
}'
Image

TC04.8 Use create token on TC04.1 and try to check data - 200 message - Success βœ…

Image

TC04.9 Create a API Token inactive via Swagger - 200 message -#2572 Failed ❌

curl -X 'POST' \
  'http://localhost:4444/tokens' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_JWT' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "TEST_API_TOKEN_VIA_API_EXPIRED",
  "description": "TEST_API_TOKEN_VIA_API_EXPIRED is expired",
 "is_active": false,
  "expires_in_days": -2
}'
Image

TC04.10 Update an API Token via Swagger - 200 message - but the values are the same - #2572 Failed ❌

curl -X 'PUT' \
  'http://localhost:8000/tokens/d53c89d4-84d1-4c19-9497-afa0bbe24bec' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer $ADMIN_JWT' \
  -H 'Content-Type: application/json' \
  -d '{ 
  "name": "TEST_API_TOKEN_VIA_API_EXPIRED",
  "description": "TEST_API_TOKEN_VIA_API_EXPIRED is expired",
  "is_active": false
}'
Image

TC04.11 UI API Tokens - Last Used and Usage Stats not showing any data #2572 - Failed ❌

Image

TC04.12 Use expired API token on Swagger and try to check data - 401 message - Success βœ…

Image

TC04.13 Use revoked API token on Swagger and try to check data - 401 message - Success βœ…

Image Image Image

TC04.14 Use Malformed API token on Swagger and try to check data - 401 message - Success βœ…

Image

IuliaGaitan avatar Jan 29 '26 15:01 IuliaGaitan

TC05 JWT Token Authentication using curl

TC Name Case Token State Expected HTTP Status Result
TC5.01 Valid token Valid & non-expired Request succeeds 200 βœ… Pass
TC5.02 Missing token Not provided Unauthorized error 401 βœ… Pass
TC5.03 Expired token Expired signature Token expired error 401 βœ… Pass
TC5.04 Invalid signature Tampered/wrong key Invalid token error 401 βœ… Pass
TC5.05 Malformed token Incomplete JWT format Bad request error 400 βœ… Pass
TC5.06 Wrong secret Valid but wrong key Signature mismatch 401 βœ… Pass
TC5.07 Missing claims Missing required fields Invalid claims error 401 βœ… Pass
TC5.08 Revoked token In blacklist Token revoked error 401 βœ… Pass
TC5.09 Valid refresh token Refresh endpoint New access token issued 200 βœ… Pass
TC5.010 Admin role required User role insufficient Forbidden 403 βœ… Pass

TC05.1 Valid token - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $VALID_JWT" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 200 OK
Image

TC5.02 Missing token - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 401 Unauthorized
Image

TC5.03 Expired token - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $EXPIRED_JWT" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 401 Token expired
Image

TC5.04: Invalid signature - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.invalid.signature" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 401 Invalid token
Image

TC5.05: Malformed token - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer malformed_jwt_string" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 400 Bad request
Image

TC5.06: Wrong secret - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $WRONG_SECRET_JWT" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 401 Signature mismatch
Image

TC5.07: Missing claims - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $NO_CLAIMS_JWT" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 401 Invalid claims
Image

TC5.08: Revoked token - Success βœ…

curl -X GET "http://localhost:8080/tools" \
  -H "Authorization: Bearer $REVOKED_JWT" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 401 Token revoked
Image

TC5.09: Valid refresh token - Success βœ…

curl -X POST "http://localhost:8080/auth/refresh" \
  -H "Authorization: Bearer $REFRESH_TOKEN" \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 200 New token issued
Image

TC5.10: Admin role required (user role insufficient) - Success βœ…

curl -X POST "http://localhost:8080/admin/users" \
  -H "Authorization: Bearer $USER_JWT" \
  -H "Content-Type: application/json" \
  -d '{"username":"newuser"}' \
  -w "\nHTTP Status: %{http_code}\n"
# Expected: 403 Forbidden
Image Image

IuliaGaitan avatar Jan 30 '26 15:01 IuliaGaitan

TC06 Basic Authentication

TC Name Case Credentials Expected HTTP Status Result
TC06.01 Valid credentials Valid username:password in base64 Access granted 200 βœ… Pass
TC06.02 Invalid credentials Invalid username:password in base64 Authentication failed 401 βœ… Pass
TC06.03 Missing authorization None Authentication required 401 βœ… Pass
TC06.04 Malformed header Non-Basic format Invalid format 401 βœ… Pass
TC06.05 Empty credentials Empty string after Basic Invalid credentials 401 βœ… Pass
TC06.06 Invalid base64 Non-base64 encoded string Decoding error 401 βœ… Pass

TC06.01 - Valid Credentials Test - Success βœ… curl -X GET "http://localhost:8080/health"
-H "Authorization: Basic $BASIC_AUTH_VALID"
-w "\nHTTP Status: %{http_code}\n"

Image

TC06.02 - Invalid Credentials Test -401 - Success βœ… curl -X GET "http://localhost:8080/tools"
-H "Authorization: Basic $BASIC_AUTH_INVALID"
-w "\nHTTP Status: %{http_code}\n"

Image

TC06.03 - Missing Authorization Header - Success βœ… curl -X GET "http://localhost:8080/tools"
-w "\nHTTP Status: %{http_code}\n"

Image

TC06.04 - Malformed Authorization Header - Success βœ… curl -X GET "http://localhost:8080/health"
-H "Authorization: InvalidFormat"
-w "\nHTTP Status: %{http_code}\n"

Image

TC06.05 - Empty Credentials - Success βœ… curl -X GET "http://localhost:8080/health"
-H "Authorization: Basic "
-w "\nHTTP Status: %{http_code}\n"

Image

TC06.06 - Invalid Base64 Encoding - Success βœ… curl -X GET "http://localhost:8080/health"
-H "Authorization: Basic NotBase64!!!"
-w "\nHTTP Status: %{http_code}\n"

Image

IuliaGaitan avatar Jan 30 '26 18:01 IuliaGaitan

TC07 Email/Password Authentication

Case Credentials Expected HTTP Status Test Result
TC07.01 Valid email/password JWT returned 200 βœ…
TC07.02 Invalid password Rejected 500 βœ…
TC07.03 Non-existent email Rejected 500 βœ…
TC07.04 Inactive user Rejected 500 βœ…
TC07.05 Password change required Limited access 200 βœ…
  1. TC07.01: Valid email/password - Success βœ…
curl -X POST http://localhost:8080/auth/login \
     -H 'Content-Type: application/json' \
     -d '{"email": "[email protected]", "password": "validpassword"}'
Image
  1. TC07.02: Invalid password - Success βœ…
 curl -X POST http://localhost:8080/auth/login \
     -H 'Content-Type: application/json' \
     -d '{"email": "[email protected]", "password": "wrongpassword"}'
Image
  1. TC07.03: Non-existent email - Success βœ…
  curl -X POST http://localhost:8080/auth/login \
     -H 'Content-Type: application/json' \
     -d '{"email": "[email protected]", "password": "anypassword"}'
Image
  1. TC07.04: Inactive user - Success βœ…
 curl -X POST http://localhost:8080/auth/login \
     -H 'Content-Type: application/json' \
     -d '{"email": "[email protected]", "password": "validpassword"}'
Image
  1. TC07.05: Password change required - Success βœ…
curl -X POST http://localhost:8080/auth/login \
    -H 'Content-Type: application/json' \
    -d '{"email": "[email protected]", "password": "validpassword"}'
Image

IuliaGaitan avatar Feb 02 '26 16:02 IuliaGaitan

TC01 – Create Test Users

Test Case Description Expected Result Actual Result Status
TC01.1 Create active user 201 201 βœ… Pass
TC01.2 Create inactive user 201 201 βœ… Pass
TC01.3 Create user with password_change_required = true 201 201 βœ… Pass
TC01.4 Duplicate email 409 409 βœ… Pass
TC01.5 Password < 8 chars 422 422 βœ… Pass

TC02 – Edit Users

Test Case Description Expected Result Actual Result Status
TC02.1 Set user inactive Should succeed Error βœ… Pass
TC02.2 Set password_change_required = true Should succeed Error βœ… Pass

TC03 – Basic Auth on UI

Test Case Description Expected Result Actual Result Status
TC03.1 Valid username/password Success Success βœ… Pass
TC03.2 Inactive user login Should fail Failure shown βœ… Pass
TC03.3 Invalid username Should fail Failure shown βœ… Pass
TC03.4 Invalid password Should fail Failure shown βœ… Pass
TC03.5 Password change required flow Redirect correctly Correct flow βœ… Pass
TC03.6 Admin login Success Successful βœ… Pass
TC03.7 Delete user User deleted Success βœ… Pass
TC03.8 Empty password Should fail Failure βœ… Pass
TC03.9 Empty username Should fail Failure βœ… Pass

**TC04 – API Calls / Tokens **

Case Token State Expected HTTP Status Test Status
TC04.1 Create a valid API Token Token management requires interactive session (web login). API tokens cannot create, modify, or revoke tokens 403 Failed ❌
TC04.2 Valid with user with no admin access Token management requires interactive session (web login). API tokens cannot create, modify, or revoke tokens 403 Failed ❌
TC04.3 Not authenticated Not authenticated 500 Pass βœ…
TC04.4 Admin Token - No Access to Private Tools - Empty list Authenticated 200 Pass βœ…
TC04.5 Admin Token - No Access to Team Tools - Empty list Authenticated 200 Pass βœ…
TC04.6 Admin Token - Access to Public Tools - Lis of tools loaded Authenticated 200 Pass βœ…
TC04.7 Admin Token - Not a Valid token Not authenticated 401 Pass βœ…
TC04.8 Create a token token on UI and try to check data Authenticated 200 Pass βœ…
TC04.9 Create a API Token inactive via Swagger Token management requires interactive session (web login). API tokens cannot create, modify, or revoke tokens 403 Pass βœ…
TC04.10 Update an API Token via Swagger Token management requires interactive session (web login). API tokens cannot create, modify, or revoke tokens 403 Pass βœ…
TC04.11 UI API Tokens - Last Used and Usage Stats not showing any data Authenticated 200 Failed ❌
TC04.12 Expired Rejected 401 Pass βœ…
TC04.13 Revoked Rejected 401 Pass βœ…
TC04.14 Malformed Rejected 401 Pass βœ…

TC04 will de retested after #2870 will be fixed

TC04.9 Create a API Token inactive via Swagger

Image

TC05 JWT Token Authentication using curl / Swagger

TC Name Case Token State Expected HTTP Status Result
TC5.01 Valid token Valid & non-expired Request succeeds 200 βœ… Pass
TC5.02 Missing token Not provided Unauthorized error 401 βœ… Pass
TC5.03 Expired token Expired signature Token expired error 401 βœ… Pass
TC5.04 Invalid signature Tampered/wrong key Invalid token error 401 βœ… Pass
TC5.05 Malformed token Incomplete JWT format Bad request error 400 βœ… Pass
TC5.06 Wrong secret Valid but wrong key Signature mismatch 401 βœ… Pass
TC5.07 Missing claims Missing required fields Invalid claims error 401 βœ… Pass
TC5.08 Revoked token In blacklist Token revoked error 401 βœ… Pass
TC5.09 Valid refresh token Refresh endpoint New access token issued 200 βœ… Pass
TC5.010 Admin role required User role insufficient Forbidden 403 βœ… Pass

TC06 Basic Authentication - API Calls - Removed

TC Name Case Credentials Expected HTTP Status Result
TC06.01 Valid credentials Valid username:password in base64 Authorization token required 401 βœ… Pass
TC06.02 Invalid credentials Invalid username:password in base64 Authentication failed 401 βœ… Pass
TC06.03 Missing authorization None Authentication required 401 βœ… Pass
TC06.04 Malformed header Non-Basic format Invalid format 401 βœ… Pass
TC06.05 Empty credentials Empty string after Basic Invalid credentials 401 βœ… Pass
TC06.06 Invalid base64 Non-base64 encoded string Decoding error 401 βœ… Pass

TC07 Email/Password Authentication - API Calls - Removed

Case Credentials Expected HTTP Status Test Result
TC07.01 Valid email/password Authorization token required 401 βœ…
TC07.02 Invalid password Rejected 500 βœ…
TC07.03 Non-existent email Rejected 500 βœ…
TC07.04 Inactive user Rejected 500 βœ…
TC07.05 Password change required Limited access 401 βœ…

IuliaGaitan avatar Feb 11 '26 13:02 IuliaGaitan

Deferred to Release 1.0.0 (GA) milestone and demoted from Must to Should.

Rationale: Manual test plans covering this area exist in tests/manual/testcases/security_tests.yaml and automated OWASP tests are implemented in Playwright (tests/playwright/security/owasp/). These issues track test plan execution, not code work β€” they are pre-GA validation activities that don't block RC3 code freeze.

jonpspri avatar Apr 13 '26 09:04 jonpspri