Skip to content

Add CORS configuration for test environment #47

@stanleykc

Description

@stanleykc

Summary

CORS is configured for local and docker environments but not for the test environment. This prevents proper CORS testing and may indicate production configuration gaps.

Current Behavior

  1. CORS is configured in `application-local.yml` and `application-docker.yml`
  2. Test environment (`application-test.yml`) has no CORS configuration
  3. CORS preflight (OPTIONS) requests return `401 Unauthorized` in tests
  4. Security tests for CORS are currently `@Disabled`

Expected Behavior

Test environment should have CORS configured to allow:

  1. Testing of CORS preflight requests
  2. Verification of allowed origins
  3. Validation of credentials and allowed methods

Technical Details

  • Location: `UnityAuth/src/test/resources/application-test.yml`
  • Test Reference: `SecurityEdgeCasesTest` CORS tests (currently disabled)
  • Related Configs:
    • `application-local.yml` (lines 5-21)
    • `application-docker.yml` (CORS config)

Suggested Fix

Add CORS configuration to test environment:

```yaml

application-test.yml

micronaut:
server:
cors:
enabled: true
configurations:
web:
allowed-origins-regex: '^http://(.*?)(?:localhost|127.0.0.1)(?::\d+)?$'
allowedOrigins:
- http://localhost:3000
- http://localhost:3001
localhost-pass-through: true
```

After adding configuration, enable the `@Disabled` CORS tests in `SecurityEdgeCasesTest`.

Acceptance Criteria

  • CORS configuration added to test environment
  • All CORS tests in `SecurityEdgeCasesTest` passing (remove `@Disabled`)
  • Document CORS requirements in README

Labels

  • testing
  • configuration
  • enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions