Skip to content

Commit

Permalink
fix(test): hardcode ECDSA key in test
Browse files Browse the repository at this point in the history
Fix #37

Signed-off-by: Thomas Fossati <[email protected]>
  • Loading branch information
thomas-fossati committed Sep 5, 2024
1 parent 6dc8e80 commit 481cbc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
14 changes: 8 additions & 6 deletions ear_appraisal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@ package ear
import (
"crypto/ecdsa"
"crypto/elliptic"
"math/big"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestAppraisalExtensions_SetGetKeyAttestation_ok(t *testing.T) {
expected := AppraisalExtensions{
VeraisonKeyAttestation: &map[string]interface{}{
"akpub": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg9KE5RdiYwpZP40Li_hp_m47n60p8D54WK84zV2sxXs7LtkBoN79R9Q",
"akpub": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEb_A7lJJBzh2t1DUZ5pYOCoW0GmmgXDKBA6orzhWUyhY8T3U6Vb8B3FP2wLDH7ueLQMb_fSWpbiKCuYnO9xwUSg",
},
}

kp, err := ecdsa.GenerateKey(elliptic.P256(), new(zeroSource))
require.NoError(t, err)
tv := kp.Public()
x, y := new(big.Int), new(big.Int)
x.SetString("50631180696798613978298281067436158137915100161810154046459014669202204445206", 10)
y.SetString("27279160910143077479535430864293552757342796444793851632003786495367057249354", 10)

tv := &ecdsa.PublicKey{Curve: elliptic.P256(), X: x, Y: y}

actual := AppraisalExtensions{}

err = actual.SetKeyAttestation(tv)
err := actual.SetKeyAttestation(tv)
assert.NoError(t, err)
assert.Equal(t, expected, actual)

Expand Down
15 changes: 0 additions & 15 deletions test_utils.go

This file was deleted.

0 comments on commit 481cbc3

Please sign in to comment.