-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
Scheme
skeleton to Realm Provisioning Path
Signed-off-by: Yogesh Deshpande <[email protected]>
- Loading branch information
1 parent
cc95c0e
commit c3848d5
Showing
14 changed files
with
465 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2023 Contributors to the Veraison project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
.DEFAULT_GOAL := test | ||
|
||
GOPKG := github.com/veraison/services/scheme/cca-realm | ||
SRCS := $(wildcard *.go) | ||
|
||
SUBDIR += plugin | ||
|
||
include ../../mk/common.mk | ||
include ../../mk/lint.mk | ||
include ../../mk/pkg.mk | ||
include ../../mk/subdir.mk | ||
include ../../mk/test.mk |
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,33 @@ | ||
// Copyright 2022-2023 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package cca_realm | ||
|
||
import ( | ||
"github.com/veraison/services/handler" | ||
) | ||
|
||
type EndorsementHandler struct{} | ||
|
||
func (o EndorsementHandler) Init(params handler.EndorsementHandlerParams) error { | ||
return nil // no-op | ||
} | ||
|
||
func (o EndorsementHandler) Close() error { | ||
return nil // no-op | ||
} | ||
|
||
func (o EndorsementHandler) GetName() string { | ||
return "unsigned-corim (CCA realm profile)" | ||
} | ||
|
||
func (o EndorsementHandler) GetAttestationScheme() string { | ||
return SchemeName | ||
} | ||
|
||
func (o EndorsementHandler) GetSupportedMediaTypes() []string { | ||
return EndorsementMediaTypes | ||
} | ||
|
||
func (o EndorsementHandler) Decode(data []byte) (*handler.EndorsementHandlerResponse, error) { | ||
return nil, nil | ||
} |
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,65 @@ | ||
// Copyright 2022-2023 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package cca_realm | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDecoder_GetAttestationScheme(t *testing.T) { | ||
d := &EndorsementHandler{} | ||
|
||
expected := SchemeName | ||
|
||
actual := d.GetAttestationScheme() | ||
|
||
assert.Equal(t, expected, actual) | ||
} | ||
|
||
func TestDecoder_GetSupportedMediaTypes(t *testing.T) { | ||
d := &EndorsementHandler{} | ||
|
||
expected := EndorsementMediaTypes | ||
|
||
actual := d.GetSupportedMediaTypes() | ||
|
||
assert.Equal(t, expected, actual) | ||
} | ||
|
||
func TestDecoder_Init(t *testing.T) { | ||
d := &EndorsementHandler{} | ||
|
||
assert.Nil(t, d.Init(nil)) | ||
} | ||
|
||
func TestDecoder_Close(t *testing.T) { | ||
d := &EndorsementHandler{} | ||
|
||
assert.Nil(t, d.Close()) | ||
} | ||
|
||
func TestDecoder_Decode_empty_data(t *testing.T) { | ||
d := &EndorsementHandler{} | ||
|
||
emptyData := []byte{} | ||
|
||
expectedErr := `empty data` | ||
|
||
_, err := d.Decode(emptyData) | ||
|
||
assert.EqualError(t, err, expectedErr) | ||
} | ||
|
||
func TestDecoder_Decode_invalid_data(t *testing.T) { | ||
d := &EndorsementHandler{} | ||
|
||
invalidCbor := []byte("invalid CBOR") | ||
|
||
expectedErr := `CBOR decoding failed: cbor: cannot unmarshal UTF-8 text string into Go value of type corim.UnsignedCorim` | ||
|
||
_, err := d.Decode(invalidCbor) | ||
|
||
assert.EqualError(t, err, expectedErr) | ||
} |
Oops, something went wrong.