-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclaims_common_test.go
54 lines (45 loc) · 1.18 KB
/
claims_common_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2023 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package psatoken
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_PsaLifeCycleState(t *testing.T) {
type TestVector struct {
Val uint16
Text string
}
validTestVectors := []TestVector{
{0x0000, "unknown"},
{0x00a7, "unknown"},
{0x00ff, "unknown"},
{0x1010, "assembly-and-test"},
{0x2001, "psa-rot-provisioning"},
{0x20ff, "psa-rot-provisioning"},
{0x3000, "secured"},
{0x3090, "secured"},
{0x30ff, "secured"},
{0x4020, "non-psa-rot-debug"},
{0x5000, "recoverable-psa-rot-debug"},
{0x50af, "recoverable-psa-rot-debug"},
{0x6001, "decommissioned"},
{0x60ff, "decommissioned"},
}
for _, tv := range validTestVectors {
state := LifeCycleToState(tv.Val)
assert.True(t, state.IsValid())
assert.Equal(t, tv.Text, state.String())
}
invalidTestVectors := []TestVector{
{0x1500, "doesn't matter"},
{0x6100, "won't be used"},
{0x8a47, "who cares?"},
{0xffff, "pineapples"},
}
for _, tv := range invalidTestVectors {
state := LifeCycleToState(tv.Val)
assert.False(t, state.IsValid())
assert.Equal(t, "invalid", state.String())
}
}