webauthnutil: add helpers for webauthn (#2686)

* devices: add device protobuf types

* webauthnutil: add helpers for webauthn
This commit is contained in:
Caleb Doxsey 2021-10-19 13:39:01 -06:00 committed by GitHub
parent 961bc8abb4
commit 1c445c426d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 872 additions and 2 deletions

View file

@ -0,0 +1,18 @@
package webauthnutil
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestEnrollmentToken(t *testing.T) {
key := []byte{1, 2, 3}
deviceEnrollmentID := "19be0131-184e-4873-acab-2be79321c30b"
token, err := NewEnrollmentToken(key, time.Second*30, deviceEnrollmentID)
assert.NoError(t, err)
id, err := ParseAndVerifyEnrollmentToken(key, token)
assert.NoError(t, err)
assert.Equal(t, deviceEnrollmentID, id)
}