-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch yaml libraries to use json annotations
Signed-off-by: Matt Moore <[email protected]>
- Loading branch information
Showing
4 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2024 Chainguard, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package webhook | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/octo-sts/app/pkg/octosts" | ||
"sigs.k8s.io/yaml" | ||
) | ||
|
||
func TestYAMLUnmarshalStrict(t *testing.T) { | ||
const orgPolicy = ` | ||
issuer: https://issuer.enforce.dev | ||
subject: 9e8b549b441afc4f082e9dccb5d1eeda843af975 | ||
claim_pattern: | ||
email: .* | ||
permissions: | ||
metadata: read | ||
administration: read | ||
repositories: [] # Act over all of the repos in the org. | ||
` | ||
const repoPolicy = ` | ||
issuer: https://issuer.enforce.dev | ||
subject: 9e8b549b441afc4f082e9dccb5d1eeda843af975 | ||
claim_pattern: | ||
email: .* | ||
permissions: | ||
metadata: read | ||
administration: read | ||
` | ||
if err := yaml.UnmarshalStrict([]byte(orgPolicy), &octosts.OrgTrustPolicy{}); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
tp := &octosts.TrustPolicy{} | ||
if err := yaml.UnmarshalStrict([]byte(orgPolicy), tp); err == nil { | ||
t.Errorf("Wanted error, got: %v", tp) | ||
} | ||
if err := yaml.UnmarshalStrict([]byte(repoPolicy), &octosts.TrustPolicy{}); err != nil { | ||
t.Error(err) | ||
} | ||
} |