github.com/rahart/packer@v0.12.2-0.20161229105310-282bb6ad370f/builder/azure/arm/openssh_key_pair_test.go (about)

     1  // Copyright (c) Microsoft Corporation. All rights reserved.
     2  // Licensed under the MIT License. See the LICENSE file in builder/azure for license information.
     3  
     4  package arm
     5  
     6  import (
     7  	"golang.org/x/crypto/ssh"
     8  	"testing"
     9  )
    10  
    11  func TestFart(t *testing.T) {
    12  
    13  }
    14  
    15  func TestAuthorizedKeyShouldParse(t *testing.T) {
    16  	testSubject, err := NewOpenSshKeyPairWithSize(512)
    17  	if err != nil {
    18  		t.Fatalf("Failed to create a new OpenSSH key pair, err=%s.", err)
    19  	}
    20  
    21  	authorizedKey := testSubject.AuthorizedKey()
    22  
    23  	_, _, _, _, err = ssh.ParseAuthorizedKey([]byte(authorizedKey))
    24  	if err != nil {
    25  		t.Fatalf("Failed to parse the authorized key, err=%s", err)
    26  	}
    27  }
    28  
    29  func TestPrivateKeyShouldParse(t *testing.T) {
    30  	testSubject, err := NewOpenSshKeyPairWithSize(512)
    31  	if err != nil {
    32  		t.Fatalf("Failed to create a new OpenSSH key pair, err=%s.", err)
    33  	}
    34  
    35  	_, err = ssh.ParsePrivateKey([]byte(testSubject.PrivateKey()))
    36  	if err != nil {
    37  		t.Fatalf("Failed to parse the private key, err=%s\n", err)
    38  	}
    39  }