github.com/sleungcy/cli@v7.1.0+incompatible/util/clissh/ssh_suite_test.go (about)

     1  package clissh_test
     2  
     3  import (
     4  	"io/ioutil"
     5  	"path/filepath"
     6  	"time"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	log "github.com/sirupsen/logrus"
    11  	"golang.org/x/crypto/ssh"
    12  
    13  	"testing"
    14  )
    15  
    16  var (
    17  	TestHostKey    ssh.Signer
    18  	TestPrivateKey ssh.Signer
    19  )
    20  
    21  func TestCmd(t *testing.T) {
    22  	RegisterFailHandler(Fail)
    23  	RunSpecs(t, "CLI SSH Suite")
    24  }
    25  
    26  var _ = BeforeSuite(func() {
    27  	SetDefaultEventuallyTimeout(3 * time.Second)
    28  
    29  	hostKeyBytes, err := ioutil.ReadFile(filepath.Join("..", "..", "fixtures", "host-key"))
    30  	Expect(err).NotTo(HaveOccurred())
    31  	hostKey, err := ssh.ParsePrivateKey(hostKeyBytes)
    32  	Expect(err).NotTo(HaveOccurred())
    33  
    34  	privateKeyBytes, err := ioutil.ReadFile(filepath.Join("..", "..", "fixtures", "private-key"))
    35  	Expect(err).NotTo(HaveOccurred())
    36  	privateKey, err := ssh.ParsePrivateKey(privateKeyBytes)
    37  	Expect(err).NotTo(HaveOccurred())
    38  
    39  	TestHostKey = hostKey
    40  	TestPrivateKey = privateKey
    41  })
    42  
    43  var _ = BeforeEach(func() {
    44  	log.SetLevel(log.PanicLevel)
    45  })