~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/ssh/fingerprint_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package ssh_test
 
5
 
 
6
import (
 
7
        "github.com/juju/testing"
 
8
        jc "github.com/juju/testing/checkers"
 
9
        gc "gopkg.in/check.v1"
 
10
 
 
11
        "github.com/juju/utils/ssh"
 
12
        sshtesting "github.com/juju/utils/ssh/testing"
 
13
)
 
14
 
 
15
type FingerprintSuite struct {
 
16
        testing.IsolationSuite
 
17
}
 
18
 
 
19
var _ = gc.Suite(&FingerprintSuite{})
 
20
 
 
21
func (s *FingerprintSuite) TestKeyFingerprint(c *gc.C) {
 
22
        keys := []sshtesting.SSHKey{
 
23
                sshtesting.ValidKeyOne,
 
24
                sshtesting.ValidKeyTwo,
 
25
                sshtesting.ValidKeyThree,
 
26
        }
 
27
        for _, k := range keys {
 
28
                fingerprint, _, err := ssh.KeyFingerprint(k.Key)
 
29
                c.Assert(err, jc.ErrorIsNil)
 
30
                c.Assert(fingerprint, gc.Equals, k.Fingerprint)
 
31
        }
 
32
}
 
33
 
 
34
func (s *FingerprintSuite) TestKeyFingerprintError(c *gc.C) {
 
35
        _, _, err := ssh.KeyFingerprint("invalid key")
 
36
        c.Assert(err, gc.ErrorMatches, `generating key fingerprint: invalid authorized_key "invalid key"`)
 
37
}