forked from go-ctap/winhello
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwinhello_test.go
More file actions
63 lines (53 loc) · 1.24 KB
/
winhello_test.go
File metadata and controls
63 lines (53 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//go:build windows
package winhello
import (
"os"
"testing"
"github.com/go-ctap/ctaphid/pkg/webauthntypes"
"github.com/go-ctap/winhello/window"
"github.com/goforj/godump"
"github.com/stretchr/testify/require"
"golang.org/x/sys/windows"
)
var (
hWnd windows.HWND
)
func runWinHelloTests() bool {
env := os.Getenv("WINHELLO_TESTS")
return env == "true" || env == "1"
}
func TestMain(m *testing.M) {
if !runWinHelloTests() {
m.Run()
} else {
wnd, err := window.GetForegroundWindow()
if err != nil {
panic(err)
}
hWnd = wnd
m.Run()
}
}
func TestGetPlatformAssertion(t *testing.T) {
if !runWinHelloTests() {
t.Skip("Skipping test because WINHELLO_TESTS is not set")
}
assertion, err := GetAssertion(
hWnd,
"example.org",
[]byte("{}"),
nil,
nil,
&AuthenticatorGetAssertionOptions{
AuthenticatorAttachment: WinHelloAuthenticatorAttachmentPlatform,
UserVerificationRequirement: WinHelloUserVerificationRequirementDiscouraged,
CredentialHints: []webauthntypes.PublicKeyCredentialHint{
webauthntypes.PublicKeyCredentialHintClientDevice,
webauthntypes.PublicKeyCredentialHintSecurityKey,
webauthntypes.PublicKeyCredentialHintHybrid,
},
},
)
require.NoError(t, err)
godump.Dump(assertion)
}