Skip to content

Conversation

superstructor
Copy link

Prior:

Summary

  • Add ModicaSMS provider implementing controller.SMSer interface
  • Support provider selection via AUTH_SMS_PROVIDER environment variable
  • Maintain backward compatibility with existing Twilio configuration
  • Add extensive test coverage including mock server and validation tests

This is a re-creation of #667 incorporating the feedback from @dbarrosop, sorry I broke my fork repo.

Configuration

New environment variables:

  • AUTH_SMS_MODICA_USERNAME - Modica API username
  • AUTH_SMS_MODICA_PASSWORD - Modica API password

Provider selection:

  • Set AUTH_SMS_PROVIDER=modica to use Modica Group
  • Defaults to twilio for backward compatibility

Technical Details

  • API Integration: Uses Modica REST v2 API with HTTPS and Basic Authentication
  • Input Validation: Enforces international phone format (+ prefix required)
  • Error Handling: Parses structured API error responses with fallback for malformed responses
  • HTTP Client: Production configuration with 30s timeout, connection pooling, and TLS settings
  • Testing: Comprehensive test suite with mock server, validation tests, and integration test support

Test Coverage

  • Unit tests for provider initialization and SMS sending
  • Mock server tests for various API response scenarios
  • Input validation tests for phone format and message content
  • Integration tests (requires environment variables)
  • Error handling tests for API failures and malformed responses

Before submitting this PR:

Checklist

  • No breaking changes
  • Tests pass
  • New features have new tests
  • Documentation is updated

Breaking changes

No breaking changes. The implementation maintains full backward compatibility with existing Twilio configurations and defaults to Twilio when no
provider is specified.

Tests

  • All existing tests pass with go test -v ./...
  • New comprehensive test suite for Modica provider with 100% coverage
  • Mock server tests validate API request/response format
  • Integration tests support real API testing with credentials
  • Input validation tests ensure proper error handling

Documentation

  • Updated environment-variables.md with new Modica configuration options
  • Updated AUTH_SMS_PROVIDER documentation to show both twilio and modica options
  • Added documentation for AUTH_SMS_MODICA_USERNAME and AUTH_SMS_MODICA_PASSWORD
  • Code follows existing patterns and conventions from CLAUDE.md guidelines (as DEVELOPER.md seemed outdated)

Test Plan

  • Verify Twilio SMS still works (backward compatibility)
  • Test Modica SMS with valid credentials
  • Confirm proper error messages for invalid phone formats
  • Validate provider switching via environment variable
  • Run full test suite: go test -v ./go/notifications/sms/

Warning

Despite extensive tests I havn't actually done e2e testing in the nhost stack (e..g cloud) with this setup and would appreciate your help with doing so, I can provide test Modica group credentials on DM if needed.

- Add ModicaSMS provider implementing controller.SMSer interface
- Support provider selection via AUTH_SMS_PROVIDER environment variable
- Maintain backward compatibility with existing Twilio configuration
- Add extensive test coverage including mock server and validation tests
@superstructor
Copy link
Author

Thanks for the patience been a bit sick with a winter lung 🫁 infection, finally got back to this @dbarrosop I've re-run integration tests to be sure w/ actual credentials to send notifications to my phone. Hope this one is good to go 🙏🏻 😄

@dbarrosop
Copy link
Member

dbarrosop commented Sep 16, 2025

Oh, I hope everything is fine and you are feeling better now. I will try to find a time this or next week to take a look. We are in the middle of finishing a launch for next week and it might be a bit hectic for a short while.

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