Skip to content

(feat) O3-5097: Add support for remote logo URLs via HTTP/HTTPS#7

Open
sanks011 wants to merge 2 commits into
openmrs:mainfrom
sanks011:O3-5097-add-support-for-remote-logo-urls-via-http-https
Open

(feat) O3-5097: Add support for remote logo URLs via HTTP/HTTPS#7
sanks011 wants to merge 2 commits into
openmrs:mainfrom
sanks011:O3-5097-add-support-for-remote-logo-urls-via-http-https

Conversation

@sanks011

Copy link
Copy Markdown

Implements comprehensive remote logo fetching with the following features:

Features:

  • HTTP/HTTPS URL support for patient ID sticker logos
  • Persistent disk caching with SHA-256 hashed filenames
  • Content-Type header validation
  • File format validation using magic bytes (PNG, JPEG, GIF)
  • 5MB file size limit enforcement
  • Proper resource cleanup (all connections/streams closed)
  • Network error fallback to cached version
  • Graceful fallback to default logo

Security:

  • Only HTTP/HTTPS protocols allowed
  • Connection timeout: 10s, Read timeout: 30s
  • File size limits prevent DoS attacks
  • Local file paths remain sandboxed to app data directory

Components Added:

  • RemoteLogoService: Core service for fetching and caching remote logos
  • RemoteLogoServiceTest: Unit tests for validation logic
  • RemoteLogoServiceIntegrationTest: Integration tests with embedded HTTP server
  • PatientIdStickerXmlReportRenderer: Updated to support both remote URLs and local paths
  • RemoteLogoUrl.md: Comprehensive documentation

Acceptance Criteria Completed:
Remote logos can be fetched via HTTP/HTTPS URLs
Downloaded files are cached persistently on disk
Content-Type headers are validated before processing
File contents are validated as valid image formats
All HTTP connections and streams are properly closed
Network errors result in graceful fallback to cache
Invalid file types return clear error messages
File size limits are enforced (5MB max)
Unit tests cover all error scenarios
Integration tests verify actual HTTP requests work correctly
Documentation updated with configuration options

Related:
Jira Ticket: https://openmrs.atlassian.net/browse/O3-5097

Implements comprehensive remote logo fetching with the following features:

Features:
- HTTP/HTTPS URL support for patient ID sticker logos
- Persistent disk caching with SHA-256 hashed filenames
- Content-Type header validation
- File format validation using magic bytes (PNG, JPEG, GIF)
- 5MB file size limit enforcement
- Proper resource cleanup (all connections/streams closed)
- Network error fallback to cached version
- Graceful fallback to default logo

Security:
- Only HTTP/HTTPS protocols allowed
- Connection timeout: 10s, Read timeout: 30s
- File size limits prevent DoS attacks
- Local file paths remain sandboxed to app data directory

Components Added:
- RemoteLogoService: Core service for fetching and caching remote logos
- RemoteLogoServiceTest: Unit tests for validation logic
- RemoteLogoServiceIntegrationTest: Integration tests with embedded HTTP server
- PatientIdStickerXmlReportRenderer: Updated to support both remote URLs and local paths
- RemoteLogoUrl.md: Comprehensive documentation

Acceptance Criteria Completed:
 Remote logos can be fetched via HTTP/HTTPS URLs
 Downloaded files are cached persistently on disk
 Content-Type headers are validated before processing
 File contents are validated as valid image formats
 All HTTP connections and streams are properly closed
 Network errors result in graceful fallback to cache
 Invalid file types return clear error messages
 File size limits are enforced (5MB max)
 Unit tests cover all error scenarios
 Integration tests verify actual HTTP requests work correctly
 Documentation updated with configuration options

Related: https://openmrs.atlassian.net/browse/O3-5097
@dkayiwa

dkayiwa commented Dec 29, 2025

Copy link
Copy Markdown
Member

@sanks011 did you see the build failure?

@sanks011

Copy link
Copy Markdown
Author

@sanks011 did you see the build failure?

I've added mockito-inline dependency to fix static mocking in tests - build should pass now.

@denniskigen
denniskigen requested a review from jnsereko July 2, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants