Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/controlplane/internal/biz/referrer.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ func (s *ReferrerUseCase) GetFromRoot(ctx context.Context, digest, rootKind, use
return nil, NewErrInvalidUUID(err)
}

if _, err = cr_v1.NewHash(digest); err != nil {
return nil, NewErrValidation(fmt.Errorf("invalid digest format: %w", err))
}

// We pass the list of organizationsIDs from where to look for the referrer
// For now we just pass the list of organizations the user is member of
// in the future we will expand this to publicly available orgs and so on.
Expand Down
13 changes: 6 additions & 7 deletions app/controlplane/internal/biz/referrer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ func (s *referrerIntegrationTestSuite) TestExtractAndPersists() {
s.Equal([]uuid.UUID{s.workflow1.ID}, got.WorkflowIDs)
})

s.T().Run("can get sha1 digests too", func(t *testing.T) {
got, err := s.Referrer.GetFromRoot(ctx, wantReferrerCommit.Digest, "", s.user.ID)
s.NoError(err)
s.Equal(wantReferrerCommit.Digest, got.Digest)
})

s.T().Run("can't be accessed by a second user in another org", func(t *testing.T) {
// the user2 has not access to org1
got, err := s.Referrer.GetFromRoot(ctx, wantReferrerAtt.Digest, "", s.user2.ID)
Expand Down Expand Up @@ -255,13 +261,6 @@ func (s *referrerIntegrationTestSuite) TestExtractAndPersists() {
require.Len(t, got.References, 0)
})

s.T().Run("or it's an invalid digest", func(t *testing.T) {
got, err := s.Referrer.GetFromRoot(ctx, "sha256:deadbeef", "", s.user.ID)
s.True(biz.IsErrValidation(err))
s.ErrorContains(err, "invalid digest format")
s.Nil(got)
})

s.T().Run("or it does not exist", func(t *testing.T) {
got, err := s.Referrer.GetFromRoot(ctx, "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "", s.user.ID)
s.True(biz.IsNotFound(err))
Expand Down