summaryrefslogtreecommitdiff
path: root/vendor/github.com/mitchellh/packer/builder/azure/arm/openssh_key_pair_test.go
blob: 7e2f69573f97502a3bc481cdfdd6757b3617ddbd (plain)
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See the LICENSE file in builder/azure for license information.

package arm

import (
	"golang.org/x/crypto/ssh"
	"testing"
)

func TestFart(t *testing.T) {

}

func TestAuthorizedKeyShouldParse(t *testing.T) {
	testSubject, err := NewOpenSshKeyPairWithSize(512)
	if err != nil {
		t.Fatalf("Failed to create a new OpenSSH key pair, err=%s.", err)
	}

	authorizedKey := testSubject.AuthorizedKey()

	_, _, _, _, err = ssh.ParseAuthorizedKey([]byte(authorizedKey))
	if err != nil {
		t.Fatalf("Failed to parse the authorized key, err=%s", err)
	}
}

func TestPrivateKeyShouldParse(t *testing.T) {
	testSubject, err := NewOpenSshKeyPairWithSize(512)
	if err != nil {
		t.Fatalf("Failed to create a new OpenSSH key pair, err=%s.", err)
	}

	_, err = ssh.ParsePrivateKey([]byte(testSubject.PrivateKey()))
	if err != nil {
		t.Fatalf("Failed to parse the private key, err=%s\n", err)
	}
}