1
0
Fork 0
mirror of synced 2024-06-14 16:54:52 +12:00

converted env vars to dsn format

This commit is contained in:
prateek banga 2023-10-31 02:05:50 +05:30
parent a01d361886
commit 0dafc59cc2
6 changed files with 88 additions and 74 deletions

14
.env
View file

@ -99,14 +99,6 @@ _APP_VCS_GITHUB_WEBHOOK_SECRET=
_APP_MIGRATIONS_FIREBASE_CLIENT_ID=
_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET=
_APP_ASSISTANT_OPENAI_API_KEY=
_APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID=
_APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY=
_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM=
_APP_MESSAGE_SMS_PROVIDER_MSG91_TO=
_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_API_KEY=
_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_DOMAIN=
_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_FROM=
_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_RECEIVER_EMAIL=
_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_IS_EU_REGION=
_APP_MESSAGE_PUSH_PROVIDER_FCM_SERVERY_KEY=
_APP_MESSAGE_PUSH_PROVIDER_FCM_RECEIVER_TOKEN=
_APP_MESSAGE_SMS_TEST_DSN=
_APP_MESSAGE_EMAIL_TEST_DSN=
_APP_MESSAGE_PUSH_TEST_DSN=

View file

@ -188,17 +188,9 @@ services:
- _APP_MIGRATIONS_FIREBASE_CLIENT_ID
- _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET
- _APP_ASSISTANT_OPENAI_API_KEY
- _APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID
- _APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY
- _APP_MESSAGE_SMS_PROVIDER_MSG91_FROM
- _APP_MESSAGE_SMS_PROVIDER_MSG91_TO
- _APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_API_KEY
- _APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_DOMAIN
- _APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_FROM
- _APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_RECEIVER_EMAIL
- _APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_IS_EU_REGION
- _APP_MESSAGE_PUSH_PROVIDER_FCM_SERVERY_KEY
- _APP_MESSAGE_PUSH_PROVIDER_FCM_RECEIVER_TOKEN
- _APP_MESSAGE_SMS_TEST_DSN
- _APP_MESSAGE_EMAIL_TEST_DSN
- _APP_MESSAGE_PUSH_TEST_DSN
appwrite-realtime:
entrypoint: realtime
<<: *x-logging

View file

@ -11,6 +11,7 @@ use Utopia\App;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\DSN\DSN;
use function sleep;
@ -743,10 +744,11 @@ class AccountCustomClientTest extends Scope
public function testCreatePhone(): array
{
$to = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_TO');
$from = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM');
$authKey = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY');
$senderId = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID');
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
$to = $smsDSN->getParam('to');
$from = $smsDSN->getParam('from');
$authKey = $smsDSN->getPassword();
$senderId = $smsDSN->getUser();
if (empty($to) || empty($from) || empty($authKey) || empty($senderId)) {
$this->markTestSkipped('SMS provider not configured');

View file

@ -8,6 +8,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\App;
use Utopia\Database\Helpers\ID;
use Utopia\DSN\DSN;
class AccountTest extends Scope
{
@ -123,10 +124,11 @@ class AccountTest extends Scope
*/
public function testCreatePhoneVerification(): array
{
$to = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_TO');
$from = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM');
$authKey = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY');
$senderId = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID');
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
$to = $smsDSN->getParam('to');
$from = $smsDSN->getParam('from');
$authKey = $smsDSN->getPassword();
$senderId = $smsDSN->getUser();
if (empty($to) || empty($from) || empty($authKey) || empty($senderId)) {
$this->markTestSkipped('SMS provider not configured');

View file

@ -8,6 +8,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\App;
use Utopia\Database\Helpers\ID;
use Utopia\DSN\DSN;
class MessagingTest extends Scope
{
@ -526,11 +527,13 @@ class MessagingTest extends Scope
public function testSendEmail()
{
$to = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_RECEIVER_EMAIL');
$from = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_FROM');
$apiKey = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_API_KEY');
$domain = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_DOMAIN');
$isEuRegion = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_IS_EU_REGION');
$emailDSN = new DSN(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'));
$to = $emailDSN->getParam('to');
$from = $emailDSN->getParam('from');
$isEuRegion = $emailDSN->getParam('isEuRegion');
$apiKey = $emailDSN->getPassword();
$domain = $emailDSN->getUser();
if (empty($to) || empty($from) || empty($apiKey) || empty($domain) || empty($isEuRegion)) {
$this->markTestSkipped('Email provider not configured');
}
@ -671,11 +674,13 @@ class MessagingTest extends Scope
*/
public function testUpdateEmail(array $email)
{
$to = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_RECEIVER_EMAIL');
$from = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_FROM');
$apiKey = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_API_KEY');
$domain = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_DOMAIN');
$isEuRegion = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_IS_EU_REGION');
$emailDSN = new DSN(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'));
$to = $emailDSN->getParam('to');
$from = $emailDSN->getParam('from');
$isEuRegion = $emailDSN->getParam('isEuRegion');
$apiKey = $emailDSN->getPassword();
$domain = $emailDSN->getUser();
if (empty($to) || empty($from) || empty($apiKey) || empty($domain) || empty($isEuRegion)) {
$this->markTestSkipped('Email provider not configured');
}
@ -828,10 +833,12 @@ class MessagingTest extends Scope
public function testSendSMS()
{
$to = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_TO');
$from = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM');
$senderId = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID');
$authKey = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY');
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
$to = $smsDSN->getParam('to');
$from = $smsDSN->getParam('from');
$authKey = $smsDSN->getPassword();
$senderId = $smsDSN->getUser();
if (empty($to) || empty($from) || empty($senderId) || empty($authKey)) {
$this->markTestSkipped('SMS provider not configured');
}
@ -969,10 +976,12 @@ class MessagingTest extends Scope
*/
public function testUpdateSMS(array $sms)
{
$to = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_TO');
$from = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM');
$senderId = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID');
$authKey = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY');
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
$to = $smsDSN->getParam('to');
$from = $smsDSN->getParam('from');
$authKey = $smsDSN->getPassword();
$senderId = $smsDSN->getUser();
if (empty($to) || empty($from) || empty($senderId) || empty($authKey)) {
$this->markTestSkipped('SMS provider not configured');
}
@ -1123,8 +1132,10 @@ class MessagingTest extends Scope
public function testSendPushNotification()
{
$to = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_RECEIVER_TOKEN');
$serverKey = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_SERVERY_KEY');
$pushDSN = new DSN(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'));
$to = $pushDSN->getParam('to');
$serverKey = $pushDSN->getPassword();
if (empty($to) || empty($serverKey)) {
$this->markTestSkipped('Push provider not configured');
}
@ -1262,8 +1273,10 @@ class MessagingTest extends Scope
*/
public function testUpdatePushNotification(array $push)
{
$to = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_RECEIVER_TOKEN');
$serverKey = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_SERVERY_KEY');
$pushDSN = new DSN(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'));
$to = $pushDSN->getParam('to');
$serverKey = $pushDSN->getPassword();
if (empty($to) || empty($serverKey)) {
$this->markTestSkipped('Push provider not configured');
}

View file

@ -5,6 +5,7 @@ namespace Tests\E2E\Services\Messaging;
use Tests\E2E\Client;
use Utopia\App;
use Utopia\Database\Helpers\ID;
use Utopia\DSN\DSN;
trait MessagingBase
{
@ -407,11 +408,13 @@ trait MessagingBase
public function testSendEmail()
{
$to = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_RECEIVER_EMAIL');
$from = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_FROM');
$apiKey = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_API_KEY');
$domain = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_DOMAIN');
$isEuRegion = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_IS_EU_REGION');
$emailDSN = new DSN(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'));
$to = $emailDSN->getParam('to');
$from = $emailDSN->getParam('from');
$isEuRegion = $emailDSN->getParam('isEuRegion');
$apiKey = $emailDSN->getPassword();
$domain = $emailDSN->getUser();
if (empty($to) || empty($from) || empty($apiKey) || empty($domain) || empty($isEuRegion)) {
$this->markTestSkipped('Email provider not configured');
}
@ -516,11 +519,13 @@ trait MessagingBase
*/
public function testUpdateEmail(array $email)
{
$to = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_RECEIVER_EMAIL');
$from = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_FROM');
$apiKey = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_API_KEY');
$domain = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_DOMAIN');
$isEuRegion = App::getEnv('_APP_MESSAGE_EMAIL_PROVIDER_MAILGUN_IS_EU_REGION');
$emailDSN = new DSN(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'));
$to = $emailDSN->getParam('to');
$from = $emailDSN->getParam('from');
$isEuRegion = $emailDSN->getParam('isEuRegion');
$apiKey = $emailDSN->getPassword();
$domain = $emailDSN->getUser();
if (empty($to) || empty($from) || empty($apiKey) || empty($domain) || empty($isEuRegion)) {
$this->markTestSkipped('Email provider not configured');
}
@ -640,10 +645,12 @@ trait MessagingBase
public function testSendSMS()
{
$to = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_TO');
$from = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM');
$senderId = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID');
$authKey = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY');
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
$to = $smsDSN->getParam('to');
$from = $smsDSN->getParam('from');
$authKey = $smsDSN->getPassword();
$senderId = $smsDSN->getUser();
if (empty($to) || empty($from) || empty($senderId) || empty($authKey)) {
$this->markTestSkipped('SMS provider not configured');
}
@ -746,10 +753,12 @@ trait MessagingBase
*/
public function testUpdateSMS(array $sms)
{
$to = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_TO');
$from = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM');
$senderId = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_SENDER_ID');
$authKey = App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_AUTH_KEY');
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
$to = $smsDSN->getParam('to');
$from = $smsDSN->getParam('from');
$authKey = $smsDSN->getPassword();
$senderId = $smsDSN->getUser();
if (empty($to) || empty($from) || empty($senderId) || empty($authKey)) {
$this->markTestSkipped('SMS provider not configured');
}
@ -867,8 +876,10 @@ trait MessagingBase
public function testSendPushNotification()
{
$to = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_RECEIVER_TOKEN');
$serverKey = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_SERVERY_KEY');
$pushDSN = new DSN(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'));
$to = $pushDSN->getParam('to');
$serverKey = $pushDSN->getPassword();
if (empty($to) || empty($serverKey)) {
$this->markTestSkipped('Push provider not configured');
}
@ -970,8 +981,10 @@ trait MessagingBase
*/
public function testUpdatePushNotification(array $push)
{
$to = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_RECEIVER_TOKEN');
$serverKey = App::getEnv('_APP_MESSAGE_PUSH_PROVIDER_FCM_SERVERY_KEY');
$pushDSN = new DSN(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'));
$to = $pushDSN->getParam('to');
$serverKey = $pushDSN->getPassword();
if (empty($to) || empty($serverKey)) {
$this->markTestSkipped('Push provider not configured');
}