mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 00:27:31 +00:00
fix: sms providers (#3801)
This commit is contained in:
@@ -3,6 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -11,12 +12,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
)
|
||||
|
||||
var (
|
||||
sid = "sid"
|
||||
token = "token"
|
||||
senderNumber = "sender-number"
|
||||
)
|
||||
|
||||
func TestSMSProjection_reduces(t *testing.T) {
|
||||
type args struct {
|
||||
event func(t *testing.T) eventstore.Event
|
||||
@@ -39,7 +34,8 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
"token": {
|
||||
"cryptoType": 0,
|
||||
"algorithm": "RSA-265",
|
||||
"keyId": "key-id"
|
||||
"keyId": "key-id",
|
||||
"crypted": "Y3J5cHRlZA=="
|
||||
},
|
||||
"senderNumber": "sender-number"
|
||||
}`),
|
||||
@@ -54,11 +50,10 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.sms_configs (id, aggregate_id, instance_id, creation_date, change_date, resource_owner, instance_id, state, sequence) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.sms_configs (id, aggregate_id, creation_date, change_date, resource_owner, instance_id, state, sequence) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
@@ -73,7 +68,12 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
"id",
|
||||
"instance-id",
|
||||
"sid",
|
||||
anyArg{},
|
||||
&crypto.CryptoValue{
|
||||
CryptoType: crypto.TypeEncryption,
|
||||
Algorithm: "RSA-265",
|
||||
KeyID: "key-id",
|
||||
Crypted: []byte("crypted"),
|
||||
},
|
||||
"sender-number",
|
||||
},
|
||||
},
|
||||
@@ -105,8 +105,59 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
{
|
||||
expectedStmt: "UPDATE projections.sms_configs_twilio SET (sid, sender_number) = ($1, $2) WHERE (sms_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
&sid,
|
||||
&senderNumber,
|
||||
"sid",
|
||||
"sender-number",
|
||||
"id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.sms_configs SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceSMSConfigTwilioTokenChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.SMSConfigTwilioTokenChangedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"id": "id",
|
||||
"token": {
|
||||
"cryptoType": 0,
|
||||
"algorithm": "RSA-265",
|
||||
"keyId": "key-id",
|
||||
"crypted": "Y3J5cHRlZA=="
|
||||
}
|
||||
}`),
|
||||
), instance.SMSConfigTwilioTokenChangedEventMapper),
|
||||
},
|
||||
reduce: (&SMSConfigProjection{}).reduceSMSConfigTwilioTokenChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: SMSConfigProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.sms_configs_twilio SET (token) = ($1) WHERE (sms_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&crypto.CryptoValue{
|
||||
CryptoType: crypto.TypeEncryption,
|
||||
Algorithm: "RSA-265",
|
||||
KeyID: "key-id",
|
||||
Crypted: []byte("crypted"),
|
||||
},
|
||||
"id",
|
||||
"instance-id",
|
||||
},
|
||||
|
Reference in New Issue
Block a user