diff --git a/corim/example_profile_test.go b/corim/example_profile_test.go index b62a9da..becff46 100644 --- a/corim/example_profile_test.go +++ b/corim/example_profile_test.go @@ -104,10 +104,10 @@ func Example_profile_unmarshal() { Extensions.MustGetString("Address")) fmt.Printf("Measurements:\n") - for _, refVal := range extractedComid.Triples.ReferenceValues.Values { + for _, m := range extractedComid.Triples.ReferenceValues.Values[0].Measurements.Values { - val := hex.EncodeToString((*refVal.Measurement.Val.Digests)[0].HashValue) - tsInt := refVal.Measurement.Val.Extensions.MustGetInt64("timestamp") + val := hex.EncodeToString((*m.Val.Digests)[0].HashValue) + tsInt := m.Val.Extensions.MustGetInt64("timestamp") ts := time.Unix(tsInt, 0).UTC() fmt.Printf(" %v taken at %s\n", val, ts.Format("2006-01-02T15:04:05")) @@ -152,6 +152,15 @@ func Example_profile_marshal() { log.Fatalf("could not set entity Address: %v", err) } + refVal := comid.ValueTriple{ + Environment: comid.Environment{ + Class: comid.NewClassImplID(comid.TestImplID). + SetVendor("ACME Ltd."). + SetModel("RoadRunner 2.0"), + }, + Measurements: *comid.NewMeasurements(), + } + measurement := comid.MustNewPSAMeasurement( comid.MustCreatePSARefValID( comid.TestSignerID, "BL", "5.0.5", @@ -168,15 +177,7 @@ func Example_profile_marshal() { log.Fatal("could not register refval extensions") } - refVal := comid.ValueTriple{ - Environment: comid.Environment{ - Class: comid.NewClassImplID(comid.TestImplID). - SetVendor("ACME Ltd."). - SetModel("RoadRunner 2.0"), - }, - Measurement: *measurement, - } - + refVal.Measurements.Add(measurement) myComid.Triples.AddReferenceValue(refVal) err = myComid.Valid() @@ -194,5 +195,5 @@ func Example_profile_marshal() { fmt.Printf("corim: %v", hex.EncodeToString(buf)) // output: - // corim: a300f6018158d8d901faa40065656e2d474201a100676578616d706c650281a4006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028101206f3132332046616b652053747265657404a1008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e30a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00037822687474703a2f2f6578616d706c652e636f6d2f6578616d706c652d70726f66696c65 + // corim: a300f6018158d9d901faa40065656e2d474201a100676578616d706c650281a4006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028101206f3132332046616b652053747265657404a1008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e3081a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00037822687474703a2f2f6578616d706c652e636f6d2f6578616d706c652d70726f66696c65 } diff --git a/corim/profiles_test.go b/corim/profiles_test.go index 34c5e89..4b4a917 100644 --- a/corim/profiles_test.go +++ b/corim/profiles_test.go @@ -126,7 +126,7 @@ func TestProfile_marshaling(t *testing.T) { address := cmd.Entities.Values[0].Extensions.MustGetString("Address") assert.Equal(t, "123 Fake Street", address) - ts := cmd.Triples.ReferenceValues.Values[0].Measurement. + ts := cmd.Triples.ReferenceValues.Values[0].Measurements.Values[0]. Val.Extensions.MustGetInt("timestamp") assert.Equal(t, 1720782190, ts) @@ -169,7 +169,7 @@ func TestProfile_marshaling(t *testing.T) { address = cmd.Entities.Values[0].Extensions.MustGetString("Address") assert.Equal(t, "123 Fake Street", address) - ts = cmd.Triples.ReferenceValues.Values[0].Measurement. + ts = cmd.Triples.ReferenceValues.Values[0].Measurements.Values[0]. Val.Extensions.MustGetInt("timestamp") assert.Equal(t, 1720782190, ts) diff --git a/corim/testcases/comid.json b/corim/testcases/comid.json index 974a473..dedf63d 100644 --- a/corim/testcases/comid.json +++ b/corim/testcases/comid.json @@ -35,6 +35,7 @@ "value": "cfg v1.0.0" }, "value": { + "timestamp": 1720782190, "raw-value": { "type": "bytes", "value": "cmF3dmFsdWUKcmF3dmFsdWUK" diff --git a/corim/testcases/src/corim-with-extensions.yaml b/corim/testcases/src/corim-with-extensions.yaml index 0eec372..7c09bf5 100644 --- a/corim/testcases/src/corim-with-extensions.yaml +++ b/corim/testcases/src/corim-with-extensions.yaml @@ -33,57 +33,42 @@ YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= 1: ACME 2: RoadRunner - - 0: - tag: 601 - value: - 1: BL - 4: 2.1.0 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: PRoT - 4: 1.3.5 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: ARoT - 4: 0.1.4 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= - -1: 1720782190 - + - - 0: + tag: 601 + value: + 1: BL + 4: 2.1.0 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: PRoT + 4: 1.3.5 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: ARoT + 4: 0.1.4 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= + -1: 1720782190 diff --git a/corim/testcases/src/example-corim.yaml b/corim/testcases/src/example-corim.yaml index 7dff794..091f1da 100644 --- a/corim/testcases/src/example-corim.yaml +++ b/corim/testcases/src/example-corim.yaml @@ -36,57 +36,42 @@ YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= 1: ACME 2: RoadRunner - - 0: - tag: 601 - value: - 1: BL - 4: 2.1.0 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: PRoT - 4: 1.3.5 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: ARoT - 4: 0.1.4 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= - -1: 1720782190 - + - - 0: + tag: 601 + value: + 1: BL + 4: 2.1.0 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: PRoT + 4: 1.3.5 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: ARoT + 4: 0.1.4 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= + -1: 1720782190 diff --git a/corim/testcases/src/good-corim.yaml b/corim/testcases/src/good-corim.yaml index ca12ebe..a04e9cb 100644 --- a/corim/testcases/src/good-corim.yaml +++ b/corim/testcases/src/good-corim.yaml @@ -27,54 +27,39 @@ YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= 1: ACME 2: RoadRunner - - 0: - tag: 601 - value: - 1: BL - 4: 2.1.0 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: PRoT - 4: 1.3.5 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: ARoT - 4: 0.1.4 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= - + - - 0: + tag: 601 + value: + 1: BL + 4: 2.1.0 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= + - 0: + tag: 601 + value: + 1: PRoT + 4: 1.3.5 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= + - 0: + tag: 601 + value: + 1: ARoT + 4: 0.1.4 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=