Skip to content

Add test suites for all 4 languages #8

Description

@thatsjet

Summary

No tests exist for any language implementation. Add comprehensive test suites that validate the same behaviors across all 4 languages to ensure cross-language consistency.

Test Matrix

Every language must test these scenarios:

# Test Case Expected Behavior
1 Construct with default YAML path Logger loads all 46 events
2 Construct with explicit YAML path Custom path works
3 Construct with nonexistent YAML path Raises/throws appropriate error
4 Construct with corrupt/invalid YAML Raises/throws appropriate error
5 Log one event per category (10 categories) Correct output for each
6 Event string format event_type:param1,param2
7 Required fields always present datetime, appid, event, level, description
8 Each optional field populates (10 fields) useragent, source_ip, host_ip, hostname, protocol, port, request_uri, request_method, region, geo
9 Custom fields passthrough Extra kwargs/options appear in output
10 Description override via options Custom description replaces default
11 Empty params list Event string has no colon suffix
12 Unknown event type Raises/throws with descriptive message
13 List all events Returns 46 event names
14 List by category filter "Authentication" returns 10 events
15 List by nonexistent category Returns empty list
16 Get event info — valid type Returns correct category, prefix, level, description, parameters
17 Get event info — invalid type Raises/throws with descriptive message
18 Log level correctness INFO events → INFO, WARN → WARN, CRITICAL → CRITICAL
19 Datetime format Matches ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+00:00$ (see issue #3)

Per-Language Instructions

Python

  • File: python/tests/test_security_event_logger.py
  • Framework: pytest
  • Setup: Add [project.optional-dependencies] dev = ["pytest>=7.0"] to pyproject.toml
  • Run: cd python && pytest tests/
  • Fixture: Use @pytest.fixture to create logger with explicit path to ../security_events.yaml
  • Create python/tests/__init__.py (empty)

Node.js

  • File: nodejs/tests/security_event_logger.test.js
  • Framework: Jest
  • Setup: npm install --save-dev jest and update package.json scripts: "test": "jest"
  • Run: cd nodejs && npx jest

Go

  • File: golang/security_event_logger_test.go
  • Framework: Standard testing package
  • Run: cd golang && go test -v ./...
  • Use t.Run() subtests for organized output
  • No external test dependencies needed

Java

  • File: java/src/test/java/com/securityeventlogger/SecurityEventLoggerTest.java
  • Framework: JUnit 5
  • Setup: Add to pom.xml:
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>5.10.2</version>
        <scope>test</scope>
    </dependency>
    Add maven-surefire-plugin for test execution.
  • Run: cd java && mvn test

Verification

  • All 4 test suites pass
  • Each test suite covers all 19 scenarios above
  • Test output is readable (descriptive test names)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Important — should be in first releasetestingTest suite additions or improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions