fix: claim verified domain from usernames (#603)

* fix: return orgDomain validationType

* added missing translations for orgDomain activity

* claim org domain

* show message if domain token was requested

* fix tests

* fix tests

Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
Livio Amstutz
2020-08-18 08:57:16 +02:00
committed by GitHub
parent 406924bed8
commit 1a00faf132
41 changed files with 15945 additions and 16717 deletions

View File

@@ -578,6 +578,7 @@ func TestOrgEventstore_ValidateOrgDomain(t *testing.T) {
type args struct {
ctx context.Context
domain *org_model.OrgDomain
users func(ctx context.Context, domain string) ([]*es_models.Aggregate, error)
}
tests := []struct {
name string
@@ -682,6 +683,26 @@ func TestOrgEventstore_ValidateOrgDomain(t *testing.T) {
isErr: errors.IsInternal,
},
},
{
name: "(user) aggregate fails",
fields: fields{Eventstore: newTestEventstore(t).
expectFilterEvents([]*es_models.Event{orgCreatedEvent(), orgDomainAddedEvent(), orgDomainVerificationAddedEvent("token")}, nil).
expectDecrypt().
expectVerification(true).
expectAggregateCreator().
expectPushEvents(0, errors.ThrowInternal(nil, "EVENT-S8WzW", "test")),
},
args: args{
ctx: authz.NewMockContext("org", "user"),
domain: &org_model.OrgDomain{ObjectRoot: es_models.ObjectRoot{AggregateID: "hodor-org"}, Domain: "hodor.org", ValidationType: org_model.OrgDomainValidationTypeHTTP},
users: func(ctx context.Context, domain string) ([]*es_models.Aggregate, error) {
return nil, errors.ThrowInternal(nil, "id", "internal error")
},
},
res: res{
isErr: errors.IsPreconditionFailed,
},
},
{
name: "push failed",
fields: fields{Eventstore: newTestEventstore(t).
@@ -719,7 +740,7 @@ func TestOrgEventstore_ValidateOrgDomain(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.fields.Eventstore.ValidateOrgDomain(tt.args.ctx, tt.args.domain)
err := tt.fields.Eventstore.ValidateOrgDomain(tt.args.ctx, tt.args.domain, tt.args.users)
if tt.res.isErr == nil && err != nil {
t.Errorf("no error expected got:%T %v", err, err)
}