mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-05 20:32:57 +02:00
webauthnutil: add helpers for webauthn (#2686)
* devices: add device protobuf types * webauthnutil: add helpers for webauthn
This commit is contained in:
parent
961bc8abb4
commit
1c445c426d
13 changed files with 872 additions and 2 deletions
48
pkg/webauthnutil/user_test.go
Normal file
48
pkg/webauthnutil/user_test.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package webauthnutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/grpc/user"
|
||||
)
|
||||
|
||||
func TestGetUserEntity(t *testing.T) {
|
||||
t.Run("name as email", func(t *testing.T) {
|
||||
ue := GetUserEntity(&user.User{
|
||||
Id: "test",
|
||||
Email: "test@example.com",
|
||||
})
|
||||
assert.Equal(t, "test@example.com", ue.Name)
|
||||
})
|
||||
t.Run("name as id", func(t *testing.T) {
|
||||
ue := GetUserEntity(&user.User{
|
||||
Id: "test",
|
||||
})
|
||||
assert.Equal(t, "test", ue.Name)
|
||||
})
|
||||
t.Run("displayName as name", func(t *testing.T) {
|
||||
ue := GetUserEntity(&user.User{
|
||||
Id: "test",
|
||||
Name: "Test User",
|
||||
})
|
||||
assert.Equal(t, "Test User", ue.DisplayName)
|
||||
})
|
||||
t.Run("displayName as email", func(t *testing.T) {
|
||||
ue := GetUserEntity(&user.User{
|
||||
Id: "test",
|
||||
Email: "test@example.com",
|
||||
})
|
||||
assert.Equal(t, "test@example.com", ue.DisplayName)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetUserEntityID(t *testing.T) {
|
||||
userID := "test@example.com"
|
||||
rawUserEntityID := GetUserEntityID(userID)
|
||||
userEntityUUID, err := uuid.FromBytes(rawUserEntityID)
|
||||
assert.NoError(t, err, "should return a UUID")
|
||||
assert.Equal(t, "8c0ac353-406f-5c08-845d-b72779779a42", userEntityUUID.String())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue