summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/golang.org/x/crypto/ssh/agent/testdata_test.go
diff options
context:
space:
mode:
authorDavid Golden <xdg@xdg.me>2018-11-30 09:50:32 -0500
committerDavid Golden <xdg@xdg.me>2018-12-07 12:46:44 -0500
commit00bf03c454e7796d507ad2e1ee80c5d75e270879 (patch)
treef6bf7c57163802cb0eb44c77bc161c2bfe778cf4 /src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/golang.org/x/crypto/ssh/agent/testdata_test.go
parent4b967bc68b65afd145b8b0a98c4868fd217bd14e (diff)
downloadmongo-00bf03c454e7796d507ad2e1ee80c5d75e270879.tar.gz
Import tools: c1d0d6967c84c62b5b578f7b18a82226b5c76526 from branch v3.6
ref: 7e7a3acf2b..c1d0d6967c for: 3.6.10 TOOLS-1566 Should not include "ssl" tag for Linux 64 build TOOLS-1709 Set build version and git revision using -ldflags TOOLS-1742 import cycle between util and testutil TOOLS-1996 Allow building tools from inside an ordinary GOPATH TOOLS-2099 Tools jstests failing on replica set shutdown TOOLS-2149 Configure build outside Evergreen
Diffstat (limited to 'src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/golang.org/x/crypto/ssh/agent/testdata_test.go')
-rw-r--r--src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/golang.org/x/crypto/ssh/agent/testdata_test.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/golang.org/x/crypto/ssh/agent/testdata_test.go b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/golang.org/x/crypto/ssh/agent/testdata_test.go
new file mode 100644
index 00000000000..b7a8781e1a5
--- /dev/null
+++ b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/golang.org/x/crypto/ssh/agent/testdata_test.go
@@ -0,0 +1,64 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// IMPLEMENTOR NOTE: To avoid a package loop, this file is in three places:
+// ssh/, ssh/agent, and ssh/test/. It should be kept in sync across all three
+// instances.
+
+package agent
+
+import (
+ "crypto/rand"
+ "fmt"
+
+ "golang.org/x/crypto/ssh"
+ "golang.org/x/crypto/ssh/testdata"
+)
+
+var (
+ testPrivateKeys map[string]interface{}
+ testSigners map[string]ssh.Signer
+ testPublicKeys map[string]ssh.PublicKey
+)
+
+func init() {
+ var err error
+
+ n := len(testdata.PEMBytes)
+ testPrivateKeys = make(map[string]interface{}, n)
+ testSigners = make(map[string]ssh.Signer, n)
+ testPublicKeys = make(map[string]ssh.PublicKey, n)
+ for t, k := range testdata.PEMBytes {
+ testPrivateKeys[t], err = ssh.ParseRawPrivateKey(k)
+ if err != nil {
+ panic(fmt.Sprintf("Unable to parse test key %s: %v", t, err))
+ }
+ testSigners[t], err = ssh.NewSignerFromKey(testPrivateKeys[t])
+ if err != nil {
+ panic(fmt.Sprintf("Unable to create signer for test key %s: %v", t, err))
+ }
+ testPublicKeys[t] = testSigners[t].PublicKey()
+ }
+
+ // Create a cert and sign it for use in tests.
+ testCert := &ssh.Certificate{
+ Nonce: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil
+ ValidPrincipals: []string{"gopher1", "gopher2"}, // increases test coverage
+ ValidAfter: 0, // unix epoch
+ ValidBefore: ssh.CertTimeInfinity, // The end of currently representable time.
+ Reserved: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil
+ Key: testPublicKeys["ecdsa"],
+ SignatureKey: testPublicKeys["rsa"],
+ Permissions: ssh.Permissions{
+ CriticalOptions: map[string]string{},
+ Extensions: map[string]string{},
+ },
+ }
+ testCert.SignCert(rand.Reader, testSigners["rsa"])
+ testPrivateKeys["cert"] = testPrivateKeys["ecdsa"]
+ testSigners["cert"], err = ssh.NewCertSigner(testCert, testSigners["ecdsa"])
+ if err != nil {
+ panic(fmt.Sprintf("Unable to create certificate signer: %v", err))
+ }
+}