Skip to content

Commit 25757a2

Browse files
authored
fix policy loader wrongly setting provider and name (#1259)
Signed-off-by: Jose I. Paris <[email protected]>
1 parent a27203e commit 25757a2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

pkg/policies/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (c *ChainloopLoader) Load(ctx context.Context, attachment *v1.PolicyAttachm
9595
return nil, fmt.Errorf("invalid policy reference %q", ref)
9696
}
9797

98-
name, provider := ProviderParts(ref)
98+
provider, name := ProviderParts(ref)
9999

100100
resp, err := c.Client.GetPolicy(ctx, &pb.AttestationServiceGetPolicyRequest{
101101
Provider: provider,

pkg/policies/policies_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,34 @@ func (s *testSuite) TestVerifyAttestations() {
247247
}
248248
}
249249

250+
func (s *testSuite) TestProviderParts() {
251+
testCases := []struct {
252+
ref string
253+
prov string
254+
name string
255+
}{
256+
{
257+
ref: "chainloop://cyclonedx-freshness",
258+
prov: "",
259+
name: "cyclonedx-freshness",
260+
},
261+
{
262+
ref: "chainloop://provider/cyclonedx-freshness",
263+
prov: "provider",
264+
name: "cyclonedx-freshness",
265+
},
266+
}
267+
268+
for _, tc := range testCases {
269+
s.Run(tc.name, func() {
270+
prov, name := ProviderParts(tc.ref)
271+
s.Equal(tc.prov, prov)
272+
s.Equal(tc.name, name)
273+
})
274+
}
275+
276+
}
277+
250278
func (s *testSuite) TestArgumentsInViolations() {
251279
schema := &v12.CraftingSchema{
252280
Policies: &v12.Policies{

0 commit comments

Comments
 (0)