Exemplo n.º 1
0
package cmd_test

import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/cmd"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/app"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/app/app_fakes"

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

var _ = Describe("DisableSsh", func() {
	var fakeAppFactory *app_fakes.FakeAppFactory
	var myApp app.App

	BeforeEach(func() {
		fakeAppFactory = &app_fakes.FakeAppFactory{}
		myApp = app.App{Guid: "myguid"}
	})

	Context("validation", func() {
		It("requires an application name", func() {
			err := cmd.DisableSSH([]string{"disable-ssh"}, fakeAppFactory)

			Expect(err).To(MatchError("Invalid usage\n" + cmd.DisableSSHUsage))
		})

		It("validates the command name", func() {
			err := cmd.DisableSSH([]string{"disable-ss", "app"}, fakeAppFactory)
Exemplo 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
Exemplo n.º 3
0
package cmd_test

import (
	"bytes"
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/cmd"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/app"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/app/app_fakes"

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

var _ = Describe("SSHEnabled", func() {
	var fakeAppFactory *app_fakes.FakeAppFactory
	var myApp app.App

	BeforeEach(func() {
		fakeAppFactory = &app_fakes.FakeAppFactory{}
		myApp = app.App{Guid: "myguid"}
	})

	Context("validation", func() {
		It("requires an application name", func() {
			err := cmd.SSHEnabled([]string{"ssh-enabled"}, fakeAppFactory, nil)

			Expect(err).To(MatchError("Invalid usage\n" + cmd.SSHEnabledUsage))
		})

		It("validates the command name", func() {