fix(console): update Twilio sms provider settings (#6732)

fix: update sms provider settings

Co-authored-by: Elio Bischof <elio@zitadel.com>
This commit is contained in:
Miguel Cabrerizo 2023-10-24 14:55:39 +02:00 committed by GitHub
parent b4fd566746
commit 36eeae1071
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 68 additions and 7 deletions

View File

@ -18,7 +18,7 @@
<input cnslInput name="senderNumber" formControlName="senderNumber" />
</cnsl-form-field>
<button *ngIf="twilio" type="button" mat-stroked-button (click)="changeToken()">
<button *ngIf="twilio" type="button" mat-stroked-button (click)="changeToken()" data-e2e="edit-sms-token-button">
{{ 'SETTING.SMS.TWILIO.CHANGETOKEN' | translate }}
</button>
</form>

View File

@ -61,15 +61,14 @@ export class DialogAddSMSProviderComponent {
}
public closeDialogWithRequest(): void {
if (!!this.twilio) {
if (!!this.twilio && this.twilioProvider && this.twilioProvider.id) {
this.req = new UpdateSMSProviderTwilioRequest();
this.req.setId(this.twilioProvider.id);
this.req.setSid(this.sid?.value);
this.req.setSenderNumber(this.senderNumber?.value);
this.dialogRef.close(this.req);
} else {
this.req = new AddSMSProviderTwilioRequest();
this.req.setSid(this.sid?.value);
this.req.setToken(this.token?.value);
this.req.setSenderNumber(this.senderNumber?.value);

View File

@ -24,6 +24,7 @@
*ngIf="twilio && twilio.id"
[disabled]="(['iam.write'] | hasRole | async) === false"
mat-stroked-button
data-e2e="activate-sms-provider-button"
(click)="toggleSMSProviderState(twilio.id)"
>
<span *ngIf="twilio.state === SMSProviderConfigState.SMS_PROVIDER_CONFIG_ACTIVE">{{

View File

@ -33,6 +33,7 @@ export class NotificationSMSProviderComponent implements OnInit {
ngOnInit(): void {
this.fetchData();
}
private fetchData(): void {
this.smsProvidersLoading = true;
this.service
@ -63,7 +64,7 @@ export class NotificationSMSProviderComponent implements OnInit {
this.service
.updateSMSProviderTwilio(req as UpdateSMSProviderTwilioRequest)
.then(() => {
this.toast.showInfo('SETTING.SMS.TWILIO.ADDED', true);
this.toast.showInfo('SETTING.SMS.TWILIO.UPDATED', true);
this.fetchData();
})
.catch((error) => {

View File

@ -1085,6 +1085,7 @@
"TOKEN": "Токен",
"SENDERNUMBER": "Номер на изпращача",
"ADDED": "Twilio добави успешно.",
"UPDATED": "Twilio се актуализира успешно.",
"REMOVED": "Twilio премахнат",
"CHANGETOKEN": "Промяна на токена",
"SETTOKEN": "Задаване на токен",

View File

@ -1091,6 +1091,7 @@
"TOKEN": "Token",
"SENDERNUMBER": "Sender Number",
"ADDED": "Twilio erfolgreich hinzugefügt.",
"UPDATED": "Twilio wurde erfolgreich aktualisiert.",
"REMOVED": "Twilio entfernt",
"CHANGETOKEN": "Token ändern",
"SETTOKEN": "Token setzen",

View File

@ -1092,6 +1092,7 @@
"TOKEN": "Token",
"SENDERNUMBER": "Sender Number",
"ADDED": "Twilio added successfully.",
"UPDATED": "Twilio updated successfully.",
"REMOVED": "Twilio removed",
"CHANGETOKEN": "Change Token",
"SETTOKEN": "Set Token",

View File

@ -1092,6 +1092,7 @@
"TOKEN": "Token",
"SENDERNUMBER": "Número de emisor",
"ADDED": "Twilio añadido con éxito.",
"UPDATED": "Twilio actualizado con éxito",
"REMOVED": "Twilio eliminado",
"CHANGETOKEN": "Cambiar token",
"SETTOKEN": "Establecer token",

View File

@ -1091,6 +1091,7 @@
"TOKEN": "Jeton",
"SENDERNUMBER": "Numéro d'expéditeur",
"ADDED": "Twilio a été ajouté avec succès.",
"UPDATED": "Twilio a été mis à jour avec succès.",
"REMOVED": "Twilio a été supprimé avec succès",
"CHANGETOKEN": "Changer de Token",
"SETTOKEN": "Définir le jeton",

View File

@ -1091,6 +1091,7 @@
"TOKEN": "Token",
"SENDERNUMBER": "Sender Number",
"ADDED": "Twilio aggiunto con successo.",
"UPDATED": "Twilio aggiornato correttamente.",
"REMOVED": "Twilio rimosso con successo.",
"CHANGETOKEN": "Cambia Token",
"SETTOKEN": "Cambia Token",

View File

@ -1092,6 +1092,7 @@
"TOKEN": "トークン",
"SENDERNUMBER": "送信者番号",
"ADDED": "Twilioは正常に追加されました。",
"UPDATED": "Twilio が正常に更新されました。",
"REMOVED": "Twilioが削除されました",
"CHANGETOKEN": "トークンを変更する",
"SETTOKEN": "トークンを設定する",

View File

@ -1093,6 +1093,7 @@
"TOKEN": "Токен",
"SENDERNUMBER": "Број на испраќач",
"ADDED": "Twilio e успешно додаден.",
"UPDATED": "Twilio се ажурираше успешно.",
"REMOVED": "Twilio отстранет",
"CHANGETOKEN": "Смени токен",
"SETTOKEN": "Постави токен",

View File

@ -1091,6 +1091,7 @@
"TOKEN": "Token",
"SENDERNUMBER": "Numer nadawcy",
"ADDED": "Twilio dodano pomyślnie.",
"UPDATED": "Twilio zostało pomyślnie zaktualizowane.",
"REMOVED": "Twilio usunięte",
"CHANGETOKEN": "Zmień Token",
"SETTOKEN": "Ustaw Token",

View File

@ -1093,6 +1093,7 @@
"TOKEN": "Token",
"SENDERNUMBER": "Número do remetente",
"ADDED": "Twilio adicionado com sucesso.",
"UPDATED": "Twilio atualizado com sucesso.",
"REMOVED": "Twilio removido",
"CHANGETOKEN": "Alterar token",
"SETTOKEN": "Definir token",

View File

@ -1091,6 +1091,7 @@
"TOKEN": "令牌",
"SENDERNUMBER": "发件人号码",
"ADDED": "Twilio 添加成功。",
"UPDATED": "Twilio 更新成功。",
"REMOVED": "Twilio 已删除",
"CHANGETOKEN": "更改令牌",
"SETTOKEN": "设置令牌",

View File

@ -19,7 +19,6 @@ describe('instance notifications', () => {
cy.visit(smtpPath);
cy.contains('SMTP Settings');
});
it(`should add SMTP provider settings`, () => {
cy.visit(smtpPath);
cy.get('[formcontrolname="senderAddress"]').clear().type('sender@example.com');
@ -33,7 +32,6 @@ describe('instance notifications', () => {
cy.get('[formcontrolname="hostAndPort"]').should('have.value', 'smtp.mailtrap.io:2525');
cy.get('[formcontrolname="user"]').should('have.value', 'user@example.com');
});
it(`should add SMTP provider password`, () => {
cy.visit(smtpPath);
cy.get('[data-e2e="add-smtp-password-button"]').click();
@ -60,5 +58,56 @@ describe('instance notifications', () => {
cy.get('h4').contains('Twilio');
cy.get('.state').contains('Inactive');
});
it(`should activate SMS provider`, () => {
cy.visit(smsPath);
cy.get('h4').contains('Twilio');
cy.get('.state').contains('Inactive');
cy.get('[data-e2e="activate-sms-provider-button"]').click();
cy.shouldConfirmSuccess();
cy.get('.state').contains('Active');
});
it(`should edit SMS provider`, () => {
cy.visit(smsPath);
cy.get('h4').contains('Twilio');
cy.get('.state').contains('Active');
cy.get('[data-e2e="new-twilio-button"]').click();
cy.get('[formcontrolname="sid"]').should('have.value', 'test');
cy.get('[formcontrolname="senderNumber"]').should('have.value', '2312123132');
cy.get('[formcontrolname="sid"]').clear().type('test2');
cy.get('[formcontrolname="senderNumber"]').clear().type('6666666666');
cy.get('[data-e2e="save-sms-settings-button"]').click();
cy.shouldConfirmSuccess();
});
it(`should contain edited values`, () => {
cy.visit(smsPath);
cy.get('h4').contains('Twilio');
cy.get('.state').contains('Active');
cy.get('[data-e2e="new-twilio-button"]').click();
cy.get('[formcontrolname="sid"]').should('have.value', 'test2');
cy.get('[formcontrolname="senderNumber"]').should('have.value', '6666666666');
});
it(`should edit SMS provider token`, () => {
cy.visit(smsPath);
cy.get('h4').contains('Twilio');
cy.get('.state').contains('Active');
cy.get('[data-e2e="new-twilio-button"]').click();
cy.get('[data-e2e="edit-sms-token-button"]').click();
cy.get('[data-e2e="notification-setting-password"]').clear().type('newsupertoken');
cy.get('[data-e2e="save-notification-setting-password-button"]').click();
cy.shouldConfirmSuccess();
});
it(`should remove SMS provider`, () => {
cy.visit(smsPath);
cy.get('h4').contains('Twilio');
cy.get('.state').contains('Active');
cy.get('[data-e2e="remove-sms-provider-button"]').click();
cy.get('[data-e2e="confirm-dialog-button"]').click();
cy.shouldConfirmSuccess();
});
});
});