Ejemplo n.º 1
0
package cmd_test

import (
	"bytes"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/cmd"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/credential/credential_fakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("GetSSHCode", func() {
	var fakeCredFactory *credential_fakes.FakeCredentialFactory

	BeforeEach(func() {
		fakeCredFactory = &credential_fakes.FakeCredentialFactory{}
	})

	It("validates the command name", func() {
		err := cmd.GetSSHCode([]string{"bogus-name"}, fakeCredFactory, nil)
		Expect(err).To(MatchError("Invalid usage\n" + cmd.GetSSHCodeUsage))
	})

	It("does not accept any arugments", func() {
		err := cmd.GetSSHCode([]string{"get-ssh-code", "bogus-argument"}, fakeCredFactory, nil)
		Expect(err).To(MatchError("Invalid usage\n" + cmd.GetSSHCodeUsage))
	})

	It("gets the authorization code from the credential factory", func() {
		fakeCredFactory.AuthorizationCodeReturns("xyxpdq", nil)
Ejemplo n.º 2
0
	"golang.org/x/crypto/ssh"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Diego SSH Plugin", func() {
	var (
		fakeTerminalHelper  *terminal_helper_fakes.FakeTerminalHelper
		fakeListenerFactory *fakes.FakeListenerFactory
		fakeAppFactory      *app_fakes.FakeAppFactory
		fakeInfoFactory     *info_fakes.FakeInfoFactory
		fakeCredFactory     *credential_fakes.FakeCredentialFactory

		fakeConnection    *fake_ssh.FakeConn
		fakeSecureClient  *fakes.FakeSecureClient
		fakeSecureDialer  *fakes.FakeSecureDialer
		fakeSecureSession *fakes.FakeSecureSession

		terminalHelper    terminal.TerminalHelper
		keepAliveDuration time.Duration
		secureShell       cmd.SecureShell

		stdinPipe *fake_io.FakeWriteCloser
	)

	BeforeEach(func() {
		fakeTerminalHelper = &terminal_helper_fakes.FakeTerminalHelper{}
		terminalHelper = terminal.DefaultHelper()

		fakeListenerFactory = &fakes.FakeListenerFactory{}
		fakeListenerFactory.ListenStub = net.Listen
Ejemplo n.º 3
0
	"golang.org/x/crypto/ssh"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Diego SSH Plugin", func() {
	var (
		fakeTerminalHelper  *terminal_helper_fakes.FakeTerminalHelper
		fakeListenerFactory *fakes.FakeListenerFactory
		fakeAppFactory      *app_fakes.FakeAppFactory
		fakeInfoFactory     *info_fakes.FakeInfoFactory
		fakeCredFactory     *credential_fakes.FakeCredentialFactory

		fakeConnection    *fake_ssh.FakeConn
		fakeSecureClient  *fakes.FakeSecureClient
		fakeSecureDialer  *fakes.FakeSecureDialer
		fakeSecureSession *fakes.FakeSecureSession

		terminalHelper    terminal.TerminalHelper
		keepAliveDuration time.Duration
		secureShell       cmd.SecureShell

		stdinPipe *fake_io.FakeWriteCloser
	)

	BeforeEach(func() {
		fakeTerminalHelper = &terminal_helper_fakes.FakeTerminalHelper{}
		terminalHelper = terminal.DefaultHelper()

		fakeListenerFactory = &fakes.FakeListenerFactory{}
		fakeListenerFactory.ListenStub = net.Listen