mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
504fe5b761
* feat: remove exif data from uploaded images (#3221) * feat: remove exif tags from images * feat: remove exif data * feat: remove exif * fix: add preferredLoginName to user grant response (#3271) * chore: log webauthn parse error (#3272) * log error * log error * feat: Help link in privacy policy * fix: convert correct detail data on organization (#3279) * fix: handle empty editor users * fix: add some missing translations (#3291) * fix: org policy translations * fix: metadata event types translation * fix: translations * fix: filter resource owner correctly on project grant members (#3281) * fix: filter resource owner correctly on project grant members * fix: filter resource owner correctly on project grant members * fix: add orgIDs to zitadel permissions request Co-authored-by: fabi <fabienne.gerschwiler@gmail.com> * fix: get IAM memberships correctly in MyZitadelPermissions (#3309) * fix: correct login names on auth and notification users (#3349) * fix: correct login names on auth and notification users * fix: migration * fix: handle resource owner in action flows (#3361) * fix merge * fix: exchange exif library (#3366) * fix: exchange exif library * ignore tiffs * requested fixes * feat: Help link in privacy policy Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
143 lines
3.9 KiB
Go
143 lines
3.9 KiB
Go
package query
|
|
|
|
import (
|
|
"database/sql"
|
|
"database/sql/driver"
|
|
"errors"
|
|
"fmt"
|
|
"regexp"
|
|
"testing"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
errs "github.com/caos/zitadel/internal/errors"
|
|
)
|
|
|
|
func Test_PrivacyPolicyPrepares(t *testing.T) {
|
|
type want struct {
|
|
sqlExpectations sqlExpectation
|
|
err checkErr
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
prepare interface{}
|
|
want want
|
|
object interface{}
|
|
}{
|
|
{
|
|
name: "preparePrivacyPolicyQuery no result",
|
|
prepare: preparePrivacyPolicyQuery,
|
|
want: want{
|
|
sqlExpectations: mockQueries(
|
|
regexp.QuoteMeta(`SELECT projections.privacy_policies.id,`+
|
|
` projections.privacy_policies.sequence,`+
|
|
` projections.privacy_policies.creation_date,`+
|
|
` projections.privacy_policies.change_date,`+
|
|
` projections.privacy_policies.resource_owner,`+
|
|
` projections.privacy_policies.privacy_link,`+
|
|
` projections.privacy_policies.tos_link,`+
|
|
` projections.privacy_policies.help_link,`+
|
|
` projections.privacy_policies.is_default,`+
|
|
` projections.privacy_policies.state`+
|
|
` FROM projections.privacy_policies`),
|
|
nil,
|
|
nil,
|
|
),
|
|
err: func(err error) (error, bool) {
|
|
if !errs.IsNotFound(err) {
|
|
return fmt.Errorf("err should be NotFoundError got: %w", err), false
|
|
}
|
|
return nil, true
|
|
},
|
|
},
|
|
object: (*PrivacyPolicy)(nil),
|
|
},
|
|
{
|
|
name: "preparePrivacyPolicyQuery found",
|
|
prepare: preparePrivacyPolicyQuery,
|
|
want: want{
|
|
sqlExpectations: mockQuery(
|
|
regexp.QuoteMeta(`SELECT projections.privacy_policies.id,`+
|
|
` projections.privacy_policies.sequence,`+
|
|
` projections.privacy_policies.creation_date,`+
|
|
` projections.privacy_policies.change_date,`+
|
|
` projections.privacy_policies.resource_owner,`+
|
|
` projections.privacy_policies.privacy_link,`+
|
|
` projections.privacy_policies.tos_link,`+
|
|
` projections.privacy_policies.help_link,`+
|
|
` projections.privacy_policies.is_default,`+
|
|
` projections.privacy_policies.state`+
|
|
` FROM projections.privacy_policies`),
|
|
[]string{
|
|
"id",
|
|
"sequence",
|
|
"creation_date",
|
|
"change_date",
|
|
"resource_owner",
|
|
"privacy_link",
|
|
"tos_link",
|
|
"help_link",
|
|
"is_default",
|
|
"state",
|
|
},
|
|
[]driver.Value{
|
|
"pol-id",
|
|
uint64(20211109),
|
|
testNow,
|
|
testNow,
|
|
"ro",
|
|
"privacy.ch",
|
|
"tos.ch",
|
|
"help.ch",
|
|
true,
|
|
domain.PolicyStateActive,
|
|
},
|
|
),
|
|
},
|
|
object: &PrivacyPolicy{
|
|
ID: "pol-id",
|
|
CreationDate: testNow,
|
|
ChangeDate: testNow,
|
|
Sequence: 20211109,
|
|
ResourceOwner: "ro",
|
|
State: domain.PolicyStateActive,
|
|
PrivacyLink: "privacy.ch",
|
|
TOSLink: "tos.ch",
|
|
HelpLink: "help.ch",
|
|
IsDefault: true,
|
|
},
|
|
},
|
|
{
|
|
name: "preparePrivacyPolicyQuery sql err",
|
|
prepare: preparePrivacyPolicyQuery,
|
|
want: want{
|
|
sqlExpectations: mockQueryErr(
|
|
regexp.QuoteMeta(`SELECT projections.privacy_policies.id,`+
|
|
` projections.privacy_policies.sequence,`+
|
|
` projections.privacy_policies.creation_date,`+
|
|
` projections.privacy_policies.change_date,`+
|
|
` projections.privacy_policies.resource_owner,`+
|
|
` projections.privacy_policies.privacy_link,`+
|
|
` projections.privacy_policies.tos_link,`+
|
|
` projections.privacy_policies.help_link,`+
|
|
` projections.privacy_policies.is_default,`+
|
|
` projections.privacy_policies.state`+
|
|
` FROM projections.privacy_policies`),
|
|
sql.ErrConnDone,
|
|
),
|
|
err: func(err error) (error, bool) {
|
|
if !errors.Is(err, sql.ErrConnDone) {
|
|
return fmt.Errorf("err should be sql.ErrConnDone got: %w", err), false
|
|
}
|
|
return nil, true
|
|
},
|
|
},
|
|
object: nil,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assertPrepare(t, tt.prepare, tt.object, tt.want.sqlExpectations, tt.want.err)
|
|
})
|
|
}
|
|
}
|