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
13 changes: 12 additions & 1 deletion ear_appraisal.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Contributors to the Veraison project.
// Copyright 2023-2026 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0

package ear
Expand All @@ -25,6 +25,17 @@ type Appraisal struct {
AppraisalExtensions
}

// NewAppraisal returns a new Appraisal with its status set to TrustTierNone
// and all its claims set to NoClaim.
func NewAppraisal() *Appraisal {
status := TrustTierNone

return &Appraisal{
Status: &status,
TrustVector: &TrustVector{},
}
}

// AppraisalExtensions contains any proprietary claims that can be optionally
// attached to the Appraisal. For now only veraison-specific extensions are
// supported.
Expand Down
10 changes: 10 additions & 0 deletions ear_appraisal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,13 @@ func TestAppraisalExtensions_GetKeyAttestation_fail_akpub_no_b64url(t *testing.T
_, err := tv.GetKeyAttestation()
assert.EqualError(t, err, `"ear.veraison.key-attestation" malformed: decoding "akpub": illegal base64 data at input byte 84`)
}

func TestNewAppraisal(t *testing.T) {
appraisal := NewAppraisal()

assert.Equal(t, TrustTierNone, *appraisal.Status)

for _, claim := range appraisal.TrustVector.AsMap() {
assert.Equal(t, NoClaim, claim)
}
}