feat: SMTP Templates (#6932)

* feat: smtp templates poc

* feat: add isActive & ProviderType to SMTP backend

* feat: change providertype to uint32 and fix tests

* feat: minimal smtp provider component

* feat: woking on diiferent providers

* feat: keep working on providers

* feat: initial stepper for new provider

* fix: settings list and working on stepper

* feat: step 1 and 2 form inputs

* feat: starter for smtp test step

* fix: misspelled SMPT

* fix: remove tests for now

* feat: add tls toggle remove old google provider

* feat: working on add smtp and table

* fix: duplicated identifiers

* fix: settings list

* fix: add missing smtp config properties

* fix: add configID to smtp config table

* fix: working on listproviders

* feat: working in listSMTPConfigs

* fix: add count to listsmtpconfigs

* fix: getting empty results from listSMTPConfigs

* feat: table now shows real data

* fix: remaining styles for smtp-table

* fix: remove old notification-smtp-provider-component

* feat: delete smtp configuration

* feat: deactivate smtp config

* feat: replace isActive with state for smtp config

* feat: activate smtp config

* fix: remaining errors after main merge

* fix: list smtp providers panic and material mdc

* feat: refactor to only one provider component

* feat: current provider details view

* fix: refactor AddSMTPConfig and ChangeSMTPConfig

* fix: smtp config reduce issue

* fix: recover domain in NewIAMSMTPConfigWriteModel

* fix: add code needed by SetUpInstance

* fix: go tests and warn about passing context to InstanceAggregateFromWriteModel

* fix: i18n and add missing trans for fr, it, zh

* fix: add e2e tests

* docs: add smtp templates

* fix: remove provider_type, add description

* fix: remaining error from merge main

* fix: add @stebenz change for primary key

* fix: inactive placed after removed to prevent deleted configs to show as inactive

* fix: smtp provider id can be empty (migrated)

* feat: add mailchimp transactional template

* feat: add Brevo (Sendinblue) template

* feat: change brevo logo, add color to tls icon

* fix: queries use resourceowner, id must not be empty

* fix: deal with old smtp settings and tests

* fix: resourceOwner is the instanceID

* fix: remove aggregate_id, rename SMTPConfigByAggregateID with SMTPConfigActive

* fix: add tests for multiple configs with different IDs

* fix: conflict

* fix: remove notification-smtp-provider

* fix: add @peintnermax suggestions, rename module and fix e2e tests

* fix: remove material legacy modules

* fix: remove ctx as parameter for  InstanceAggregateFromWriteModel

* fix: add Id to SMTPConfigToPb

* fix:  change InstanceAggregateFromWriteModel to avoid linter errors

* fix import

* rm unused package-lock

* update yarn lock

---------

Co-authored-by: Elio Bischof <elio@zitadel.com>
Co-authored-by: Max Peintner <max@caos.ch>
Co-authored-by: Stefan Benz <46600784+stebenz@users.noreply.github.com>
This commit is contained in:
Miguel Cabrerizo
2024-04-11 09:16:10 +02:00
committed by GitHub
parent e2f0cd034a
commit d229da6af7
93 changed files with 6359 additions and 6132 deletions

View File

@@ -9,26 +9,28 @@ import (
"testing"
"github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/zerrors"
)
var (
prepareSMTPConfigStmt = `SELECT projections.smtp_configs1.aggregate_id,` +
` projections.smtp_configs1.creation_date,` +
` projections.smtp_configs1.change_date,` +
` projections.smtp_configs1.resource_owner,` +
` projections.smtp_configs1.sequence,` +
` projections.smtp_configs1.tls,` +
` projections.smtp_configs1.sender_address,` +
` projections.smtp_configs1.sender_name,` +
` projections.smtp_configs1.reply_to_address,` +
` projections.smtp_configs1.host,` +
` projections.smtp_configs1.username,` +
` projections.smtp_configs1.password` +
` FROM projections.smtp_configs1` +
prepareSMTPConfigStmt = `SELECT projections.smtp_configs2.creation_date,` +
` projections.smtp_configs2.change_date,` +
` projections.smtp_configs2.resource_owner,` +
` projections.smtp_configs2.sequence,` +
` projections.smtp_configs2.tls,` +
` projections.smtp_configs2.sender_address,` +
` projections.smtp_configs2.sender_name,` +
` projections.smtp_configs2.reply_to_address,` +
` projections.smtp_configs2.host,` +
` projections.smtp_configs2.username,` +
` projections.smtp_configs2.password,` +
` projections.smtp_configs2.id,` +
` projections.smtp_configs2.state,` +
` projections.smtp_configs2.description` +
` FROM projections.smtp_configs2` +
` AS OF SYSTEM TIME '-1 ms'`
prepareSMTPConfigCols = []string{
"aggregate_id",
"creation_date",
"change_date",
"resource_owner",
@@ -40,6 +42,9 @@ var (
"smtp_host",
"smtp_user",
"smtp_password",
"id",
"state",
"description",
}
)
@@ -80,7 +85,6 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
regexp.QuoteMeta(prepareSMTPConfigStmt),
prepareSMTPConfigCols,
[]driver.Value{
"agg-id",
testNow,
testNow,
"ro",
@@ -92,11 +96,13 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
"host",
"user",
&crypto.CryptoValue{},
"2232323",
domain.SMTPConfigStateActive,
"test",
},
),
},
object: &SMTPConfig{
AggregateID: "agg-id",
CreationDate: testNow,
ChangeDate: testNow,
ResourceOwner: "ro",
@@ -108,6 +114,93 @@ func Test_SMTPConfigsPrepares(t *testing.T) {
Host: "host",
User: "user",
Password: &crypto.CryptoValue{},
ID: "2232323",
State: domain.SMTPConfigStateActive,
Description: "test",
},
},
{
name: "prepareSMTPConfigQuery another config found",
prepare: prepareSMTPConfigQuery,
want: want{
sqlExpectations: mockQuery(
regexp.QuoteMeta(prepareSMTPConfigStmt),
prepareSMTPConfigCols,
[]driver.Value{
testNow,
testNow,
"ro",
uint64(20211109),
true,
"sender2",
"name2",
"reply-to2",
"host2",
"user2",
&crypto.CryptoValue{},
"44442323",
domain.SMTPConfigStateInactive,
"test2",
},
),
},
object: &SMTPConfig{
CreationDate: testNow,
ChangeDate: testNow,
ResourceOwner: "ro",
Sequence: 20211109,
TLS: true,
SenderAddress: "sender2",
SenderName: "name2",
ReplyToAddress: "reply-to2",
Host: "host2",
User: "user2",
Password: &crypto.CryptoValue{},
ID: "44442323",
State: domain.SMTPConfigStateInactive,
Description: "test2",
},
},
{
name: "prepareSMTPConfigQuery yet another config found",
prepare: prepareSMTPConfigQuery,
want: want{
sqlExpectations: mockQuery(
regexp.QuoteMeta(prepareSMTPConfigStmt),
prepareSMTPConfigCols,
[]driver.Value{
testNow,
testNow,
"ro",
uint64(20211109),
true,
"sender3",
"name3",
"reply-to3",
"host3",
"user3",
&crypto.CryptoValue{},
"23234444",
domain.SMTPConfigStateInactive,
"test3",
},
),
},
object: &SMTPConfig{
CreationDate: testNow,
ChangeDate: testNow,
ResourceOwner: "ro",
Sequence: 20211109,
TLS: true,
SenderAddress: "sender3",
SenderName: "name3",
ReplyToAddress: "reply-to3",
Host: "host3",
User: "user3",
Password: &crypto.CryptoValue{},
ID: "23234444",
State: domain.SMTPConfigStateInactive,
Description: "test3",
},
},
{