Skip to content

Commit

Permalink
Add Name measurement value
Browse files Browse the repository at this point in the history
Fixes veraison#56

Signed-off-by: Dionna Glaze <[email protected]>
  • Loading branch information
deeglaze committed Dec 24, 2024
1 parent b690f86 commit ea39f1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions comid/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ type Mval struct {
SerialNumber *string `cbor:"8,keyasint,omitempty" json:"serial-number,omitempty"`
UEID *eat.UEID `cbor:"9,keyasint,omitempty" json:"ueid,omitempty"`
UUID *UUID `cbor:"10,keyasint,omitempty" json:"uuid,omitempty"`
Name *string `cbor:"11,keyasint,omitempty" json:"name,omitempty"`
IntegrityRegisters *IntegrityRegisters `cbor:"14,keyasint,omitempty" json:"integrity-registers,omitempty"`
Extensions
}
Expand Down Expand Up @@ -435,6 +436,7 @@ func (o Mval) Valid() error {
o.SerialNumber == nil &&
o.UEID == nil &&
o.UUID == nil &&
o.Name == nil &&
o.IntegrityRegisters == nil {
return fmt.Errorf("no measurement value set")
}
Expand Down Expand Up @@ -764,6 +766,15 @@ func (o *Measurement) SetUUID(u UUID) *Measurement {
return o
}

// SetName sets the supplied name string in the measurement-values-map of the
// target measurement
func (o *Measurement) SetName(name string) *Measurement {
if o != nil {
o.Val.Name = &name
}
return o
}

func (o Measurement) Valid() error {
if o.Key != nil && o.Key.IsSet() {
if err := o.Key.Valid(); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions comid/measurement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ func TestMeasurement_NewUUIDMeasurement_bad_uuid(t *testing.T) {
assert.Nil(t, tv.SetUUID(nonRFC4122UUID))
}

func TestMeasurement_NameMeasurement(t *testing.T) {
want := "Maureen"
got := *(&Measurement{}).SetName("Maureen").Val.Name
assert.Equal(t, want, got)
}

var (
testMKeyUintMin uint64
testMKeyUintMax = ^uint64(0)
Expand Down

0 comments on commit ea39f1f

Please sign in to comment.