Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Encode consumer id in error message (#3849)
Browse files Browse the repository at this point in the history
* encode consumer info in error message

* bump values.yaml

* make linter happy

* adapt e2e test
  • Loading branch information
dragobt authored May 9, 2024
1 parent 48af9ca commit 20de3d5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chart/compass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ global:
name: compass-pairing-adapter
director:
dir: dev/incubator/
version: "PR-3787"
version: "PR-3849"
name: compass-director
hydrator:
dir: dev/incubator/
Expand Down Expand Up @@ -228,7 +228,7 @@ global:
name: compass-external-services-mock
e2e_tests:
dir: dev/incubator/
version: "PR-3787"
version: "PR-3849"
name: compass-e2e-tests
isLocalEnv: false
isForTesting: false
Expand Down
4 changes: 2 additions & 2 deletions components/director/internal/domain/apptemplate/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -895,10 +895,10 @@ func (r *Resolver) retrieveAppTemplate(ctx context.Context,
return appTemplate, nil
}
}
return nil, errors.Errorf("application template with id %s and consumer id %q not found", *appTemplateID, consumerID)
return nil, errors.Errorf("application template with id %s and consumer id REDACTED_%x not found", *appTemplateID, sha256.Sum256([]byte(consumerID)))
}
if len(templates) < 1 {
return nil, errors.Errorf("application template with name %q and consumer id %q not found", appTemplateName, consumerID)
return nil, errors.Errorf("application template with name %q and consumer id REDACTED_%x not found", appTemplateName, sha256.Sum256([]byte(consumerID)))
}
if len(templates) > 1 {
return nil, errors.Errorf("unexpected number of application templates. found %d", len(appTemplates))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apptemplate_test

import (
"context"
"crypto/sha256"
"errors"
"fmt"
"testing"
Expand Down Expand Up @@ -2103,7 +2104,7 @@ func TestResolver_RegisterApplicationFromTemplate(t *testing.T) {
WebhookSvcFn: UnusedWebhookSvc,
SystemFieldDiscoveryEngine: UnusedSystemFieldDiscoveryEngine,
ExpectedOutput: nil,
ExpectedError: errors.New("application template with name \"bar\" and consumer id \"consumer-id\" not found"),
ExpectedError: fmt.Errorf("application template with name \"bar\" and consumer id REDACTED_%x not found", sha256.Sum256([]byte("consumer-id"))),
},
{
Name: "Returns error when list application templates by name return more than one application template",
Expand Down Expand Up @@ -2442,7 +2443,7 @@ func TestResolver_RegisterApplicationFromTemplate(t *testing.T) {
WebhookConvFn: UnusedWebhookConv,
WebhookSvcFn: UnusedWebhookSvc,
SystemFieldDiscoveryEngine: UnusedSystemFieldDiscoveryEngine,
ExpectedError: errors.New("application template with id customTemplateID and consumer id \"consumer-id\" not found"),
ExpectedError: fmt.Errorf("application template with id customTemplateID and consumer id REDACTED_%x not found", sha256.Sum256([]byte("consumer-id"))),
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package application

import (
"context"
"crypto/sha256"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -2225,7 +2226,7 @@ func TestRegisterApplicationFromTemplate_DifferentSubaccount(t *testing.T) {

// THEN
require.NotNil(t, err)
require.Contains(t, err.Error(), fmt.Sprintf("application template with name %q and consumer id %q not found", appTemplateName, conf.TestProviderSubaccountIDRegion2))
require.Contains(t, err.Error(), fmt.Sprintf("application template with name %q and consumer id REDACTED_%x not found", appTemplateName, sha256.Sum256([]byte(conf.TestProviderSubaccountIDRegion2))))
}

func TestAddWebhookToApplicationTemplateWithTenant(t *testing.T) {
Expand Down

0 comments on commit 20de3d5

Please sign in to comment.