-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresolver_test.go
34 lines (26 loc) · 947 Bytes
/
resolver_test.go
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
// Copyright 2018 sshfp authors. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package sshfp
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestResolverPrefilledCache(t *testing.T) {
entries := testParseZone(t, "example.sshfp.xor-gate.org.zone")
assert.Len(t, entries, 8)
mc, err := NewMemoryCache()
require.Nil(t, err)
require.Nil(t, mc.Add(entries...))
require.Len(t, mc.c["example.sshfp.xor-gate.org"], 8)
res, err := NewResolver(WithCache(mc))
require.Nil(t, err)
require.NotNil(t, res)
pubKey := testParseAuthorizedKey(t, "ssh_host_rsa_key.pub")
err = res.HostKeyCallback("example.sshfp.xor-gate.org", nil, pubKey)
assert.Nil(t, err)
pubKey = testParseAuthorizedKey(t, "ssh_host_ed25519_key.pub")
err = res.HostKeyCallback("example.sshfp.xor-gate.org", nil, pubKey)
assert.Nil(t, err)
}