github.phpd.cn/hashicorp/packer@v1.3.2/builder/azure/arm/openssh_key_pair_test.go (about)

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