github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/cf/ssh/sshfakes/fake_secure_session.go (about)

     1  // This file was generated by counterfeiter
     2  package sshfakes
     3  
     4  import (
     5  	"io"
     6  	"sync"
     7  
     8  	"code.cloudfoundry.org/cli/cf/ssh"
     9  	"golang.org/x/crypto/ssh"
    10  )
    11  
    12  type FakeSecureSession struct {
    13  	RequestPtyStub        func(term string, height, width int, termModes ssh.TerminalModes) error
    14  	requestPtyMutex       sync.RWMutex
    15  	requestPtyArgsForCall []struct {
    16  		term      string
    17  		height    int
    18  		width     int
    19  		termModes ssh.TerminalModes
    20  	}
    21  	requestPtyReturns struct {
    22  		result1 error
    23  	}
    24  	SendRequestStub        func(name string, wantReply bool, payload []byte) (bool, error)
    25  	sendRequestMutex       sync.RWMutex
    26  	sendRequestArgsForCall []struct {
    27  		name      string
    28  		wantReply bool
    29  		payload   []byte
    30  	}
    31  	sendRequestReturns struct {
    32  		result1 bool
    33  		result2 error
    34  	}
    35  	StdinPipeStub        func() (io.WriteCloser, error)
    36  	stdinPipeMutex       sync.RWMutex
    37  	stdinPipeArgsForCall []struct{}
    38  	stdinPipeReturns     struct {
    39  		result1 io.WriteCloser
    40  		result2 error
    41  	}
    42  	StdoutPipeStub        func() (io.Reader, error)
    43  	stdoutPipeMutex       sync.RWMutex
    44  	stdoutPipeArgsForCall []struct{}
    45  	stdoutPipeReturns     struct {
    46  		result1 io.Reader
    47  		result2 error
    48  	}
    49  	StderrPipeStub        func() (io.Reader, error)
    50  	stderrPipeMutex       sync.RWMutex
    51  	stderrPipeArgsForCall []struct{}
    52  	stderrPipeReturns     struct {
    53  		result1 io.Reader
    54  		result2 error
    55  	}
    56  	StartStub        func(command string) error
    57  	startMutex       sync.RWMutex
    58  	startArgsForCall []struct {
    59  		command string
    60  	}
    61  	startReturns struct {
    62  		result1 error
    63  	}
    64  	ShellStub        func() error
    65  	shellMutex       sync.RWMutex
    66  	shellArgsForCall []struct{}
    67  	shellReturns     struct {
    68  		result1 error
    69  	}
    70  	WaitStub        func() error
    71  	waitMutex       sync.RWMutex
    72  	waitArgsForCall []struct{}
    73  	waitReturns     struct {
    74  		result1 error
    75  	}
    76  	CloseStub        func() error
    77  	closeMutex       sync.RWMutex
    78  	closeArgsForCall []struct{}
    79  	closeReturns     struct {
    80  		result1 error
    81  	}
    82  	invocations      map[string][][]interface{}
    83  	invocationsMutex sync.RWMutex
    84  }
    85  
    86  func (fake *FakeSecureSession) RequestPty(term string, height int, width int, termModes ssh.TerminalModes) error {
    87  	fake.requestPtyMutex.Lock()
    88  	fake.requestPtyArgsForCall = append(fake.requestPtyArgsForCall, struct {
    89  		term      string
    90  		height    int
    91  		width     int
    92  		termModes ssh.TerminalModes
    93  	}{term, height, width, termModes})
    94  	fake.recordInvocation("RequestPty", []interface{}{term, height, width, termModes})
    95  	fake.requestPtyMutex.Unlock()
    96  	if fake.RequestPtyStub != nil {
    97  		return fake.RequestPtyStub(term, height, width, termModes)
    98  	} else {
    99  		return fake.requestPtyReturns.result1
   100  	}
   101  }
   102  
   103  func (fake *FakeSecureSession) RequestPtyCallCount() int {
   104  	fake.requestPtyMutex.RLock()
   105  	defer fake.requestPtyMutex.RUnlock()
   106  	return len(fake.requestPtyArgsForCall)
   107  }
   108  
   109  func (fake *FakeSecureSession) RequestPtyArgsForCall(i int) (string, int, int, ssh.TerminalModes) {
   110  	fake.requestPtyMutex.RLock()
   111  	defer fake.requestPtyMutex.RUnlock()
   112  	return fake.requestPtyArgsForCall[i].term, fake.requestPtyArgsForCall[i].height, fake.requestPtyArgsForCall[i].width, fake.requestPtyArgsForCall[i].termModes
   113  }
   114  
   115  func (fake *FakeSecureSession) RequestPtyReturns(result1 error) {
   116  	fake.RequestPtyStub = nil
   117  	fake.requestPtyReturns = struct {
   118  		result1 error
   119  	}{result1}
   120  }
   121  
   122  func (fake *FakeSecureSession) SendRequest(name string, wantReply bool, payload []byte) (bool, error) {
   123  	var payloadCopy []byte
   124  	if payload != nil {
   125  		payloadCopy = make([]byte, len(payload))
   126  		copy(payloadCopy, payload)
   127  	}
   128  	fake.sendRequestMutex.Lock()
   129  	fake.sendRequestArgsForCall = append(fake.sendRequestArgsForCall, struct {
   130  		name      string
   131  		wantReply bool
   132  		payload   []byte
   133  	}{name, wantReply, payloadCopy})
   134  	fake.recordInvocation("SendRequest", []interface{}{name, wantReply, payloadCopy})
   135  	fake.sendRequestMutex.Unlock()
   136  	if fake.SendRequestStub != nil {
   137  		return fake.SendRequestStub(name, wantReply, payload)
   138  	} else {
   139  		return fake.sendRequestReturns.result1, fake.sendRequestReturns.result2
   140  	}
   141  }
   142  
   143  func (fake *FakeSecureSession) SendRequestCallCount() int {
   144  	fake.sendRequestMutex.RLock()
   145  	defer fake.sendRequestMutex.RUnlock()
   146  	return len(fake.sendRequestArgsForCall)
   147  }
   148  
   149  func (fake *FakeSecureSession) SendRequestArgsForCall(i int) (string, bool, []byte) {
   150  	fake.sendRequestMutex.RLock()
   151  	defer fake.sendRequestMutex.RUnlock()
   152  	return fake.sendRequestArgsForCall[i].name, fake.sendRequestArgsForCall[i].wantReply, fake.sendRequestArgsForCall[i].payload
   153  }
   154  
   155  func (fake *FakeSecureSession) SendRequestReturns(result1 bool, result2 error) {
   156  	fake.SendRequestStub = nil
   157  	fake.sendRequestReturns = struct {
   158  		result1 bool
   159  		result2 error
   160  	}{result1, result2}
   161  }
   162  
   163  func (fake *FakeSecureSession) StdinPipe() (io.WriteCloser, error) {
   164  	fake.stdinPipeMutex.Lock()
   165  	fake.stdinPipeArgsForCall = append(fake.stdinPipeArgsForCall, struct{}{})
   166  	fake.recordInvocation("StdinPipe", []interface{}{})
   167  	fake.stdinPipeMutex.Unlock()
   168  	if fake.StdinPipeStub != nil {
   169  		return fake.StdinPipeStub()
   170  	} else {
   171  		return fake.stdinPipeReturns.result1, fake.stdinPipeReturns.result2
   172  	}
   173  }
   174  
   175  func (fake *FakeSecureSession) StdinPipeCallCount() int {
   176  	fake.stdinPipeMutex.RLock()
   177  	defer fake.stdinPipeMutex.RUnlock()
   178  	return len(fake.stdinPipeArgsForCall)
   179  }
   180  
   181  func (fake *FakeSecureSession) StdinPipeReturns(result1 io.WriteCloser, result2 error) {
   182  	fake.StdinPipeStub = nil
   183  	fake.stdinPipeReturns = struct {
   184  		result1 io.WriteCloser
   185  		result2 error
   186  	}{result1, result2}
   187  }
   188  
   189  func (fake *FakeSecureSession) StdoutPipe() (io.Reader, error) {
   190  	fake.stdoutPipeMutex.Lock()
   191  	fake.stdoutPipeArgsForCall = append(fake.stdoutPipeArgsForCall, struct{}{})
   192  	fake.recordInvocation("StdoutPipe", []interface{}{})
   193  	fake.stdoutPipeMutex.Unlock()
   194  	if fake.StdoutPipeStub != nil {
   195  		return fake.StdoutPipeStub()
   196  	} else {
   197  		return fake.stdoutPipeReturns.result1, fake.stdoutPipeReturns.result2
   198  	}
   199  }
   200  
   201  func (fake *FakeSecureSession) StdoutPipeCallCount() int {
   202  	fake.stdoutPipeMutex.RLock()
   203  	defer fake.stdoutPipeMutex.RUnlock()
   204  	return len(fake.stdoutPipeArgsForCall)
   205  }
   206  
   207  func (fake *FakeSecureSession) StdoutPipeReturns(result1 io.Reader, result2 error) {
   208  	fake.StdoutPipeStub = nil
   209  	fake.stdoutPipeReturns = struct {
   210  		result1 io.Reader
   211  		result2 error
   212  	}{result1, result2}
   213  }
   214  
   215  func (fake *FakeSecureSession) StderrPipe() (io.Reader, error) {
   216  	fake.stderrPipeMutex.Lock()
   217  	fake.stderrPipeArgsForCall = append(fake.stderrPipeArgsForCall, struct{}{})
   218  	fake.recordInvocation("StderrPipe", []interface{}{})
   219  	fake.stderrPipeMutex.Unlock()
   220  	if fake.StderrPipeStub != nil {
   221  		return fake.StderrPipeStub()
   222  	} else {
   223  		return fake.stderrPipeReturns.result1, fake.stderrPipeReturns.result2
   224  	}
   225  }
   226  
   227  func (fake *FakeSecureSession) StderrPipeCallCount() int {
   228  	fake.stderrPipeMutex.RLock()
   229  	defer fake.stderrPipeMutex.RUnlock()
   230  	return len(fake.stderrPipeArgsForCall)
   231  }
   232  
   233  func (fake *FakeSecureSession) StderrPipeReturns(result1 io.Reader, result2 error) {
   234  	fake.StderrPipeStub = nil
   235  	fake.stderrPipeReturns = struct {
   236  		result1 io.Reader
   237  		result2 error
   238  	}{result1, result2}
   239  }
   240  
   241  func (fake *FakeSecureSession) Start(command string) error {
   242  	fake.startMutex.Lock()
   243  	fake.startArgsForCall = append(fake.startArgsForCall, struct {
   244  		command string
   245  	}{command})
   246  	fake.recordInvocation("Start", []interface{}{command})
   247  	fake.startMutex.Unlock()
   248  	if fake.StartStub != nil {
   249  		return fake.StartStub(command)
   250  	} else {
   251  		return fake.startReturns.result1
   252  	}
   253  }
   254  
   255  func (fake *FakeSecureSession) StartCallCount() int {
   256  	fake.startMutex.RLock()
   257  	defer fake.startMutex.RUnlock()
   258  	return len(fake.startArgsForCall)
   259  }
   260  
   261  func (fake *FakeSecureSession) StartArgsForCall(i int) string {
   262  	fake.startMutex.RLock()
   263  	defer fake.startMutex.RUnlock()
   264  	return fake.startArgsForCall[i].command
   265  }
   266  
   267  func (fake *FakeSecureSession) StartReturns(result1 error) {
   268  	fake.StartStub = nil
   269  	fake.startReturns = struct {
   270  		result1 error
   271  	}{result1}
   272  }
   273  
   274  func (fake *FakeSecureSession) Shell() error {
   275  	fake.shellMutex.Lock()
   276  	fake.shellArgsForCall = append(fake.shellArgsForCall, struct{}{})
   277  	fake.recordInvocation("Shell", []interface{}{})
   278  	fake.shellMutex.Unlock()
   279  	if fake.ShellStub != nil {
   280  		return fake.ShellStub()
   281  	} else {
   282  		return fake.shellReturns.result1
   283  	}
   284  }
   285  
   286  func (fake *FakeSecureSession) ShellCallCount() int {
   287  	fake.shellMutex.RLock()
   288  	defer fake.shellMutex.RUnlock()
   289  	return len(fake.shellArgsForCall)
   290  }
   291  
   292  func (fake *FakeSecureSession) ShellReturns(result1 error) {
   293  	fake.ShellStub = nil
   294  	fake.shellReturns = struct {
   295  		result1 error
   296  	}{result1}
   297  }
   298  
   299  func (fake *FakeSecureSession) Wait() error {
   300  	fake.waitMutex.Lock()
   301  	fake.waitArgsForCall = append(fake.waitArgsForCall, struct{}{})
   302  	fake.recordInvocation("Wait", []interface{}{})
   303  	fake.waitMutex.Unlock()
   304  	if fake.WaitStub != nil {
   305  		return fake.WaitStub()
   306  	} else {
   307  		return fake.waitReturns.result1
   308  	}
   309  }
   310  
   311  func (fake *FakeSecureSession) WaitCallCount() int {
   312  	fake.waitMutex.RLock()
   313  	defer fake.waitMutex.RUnlock()
   314  	return len(fake.waitArgsForCall)
   315  }
   316  
   317  func (fake *FakeSecureSession) WaitReturns(result1 error) {
   318  	fake.WaitStub = nil
   319  	fake.waitReturns = struct {
   320  		result1 error
   321  	}{result1}
   322  }
   323  
   324  func (fake *FakeSecureSession) Close() error {
   325  	fake.closeMutex.Lock()
   326  	fake.closeArgsForCall = append(fake.closeArgsForCall, struct{}{})
   327  	fake.recordInvocation("Close", []interface{}{})
   328  	fake.closeMutex.Unlock()
   329  	if fake.CloseStub != nil {
   330  		return fake.CloseStub()
   331  	} else {
   332  		return fake.closeReturns.result1
   333  	}
   334  }
   335  
   336  func (fake *FakeSecureSession) CloseCallCount() int {
   337  	fake.closeMutex.RLock()
   338  	defer fake.closeMutex.RUnlock()
   339  	return len(fake.closeArgsForCall)
   340  }
   341  
   342  func (fake *FakeSecureSession) CloseReturns(result1 error) {
   343  	fake.CloseStub = nil
   344  	fake.closeReturns = struct {
   345  		result1 error
   346  	}{result1}
   347  }
   348  
   349  func (fake *FakeSecureSession) Invocations() map[string][][]interface{} {
   350  	fake.invocationsMutex.RLock()
   351  	defer fake.invocationsMutex.RUnlock()
   352  	fake.requestPtyMutex.RLock()
   353  	defer fake.requestPtyMutex.RUnlock()
   354  	fake.sendRequestMutex.RLock()
   355  	defer fake.sendRequestMutex.RUnlock()
   356  	fake.stdinPipeMutex.RLock()
   357  	defer fake.stdinPipeMutex.RUnlock()
   358  	fake.stdoutPipeMutex.RLock()
   359  	defer fake.stdoutPipeMutex.RUnlock()
   360  	fake.stderrPipeMutex.RLock()
   361  	defer fake.stderrPipeMutex.RUnlock()
   362  	fake.startMutex.RLock()
   363  	defer fake.startMutex.RUnlock()
   364  	fake.shellMutex.RLock()
   365  	defer fake.shellMutex.RUnlock()
   366  	fake.waitMutex.RLock()
   367  	defer fake.waitMutex.RUnlock()
   368  	fake.closeMutex.RLock()
   369  	defer fake.closeMutex.RUnlock()
   370  	return fake.invocations
   371  }
   372  
   373  func (fake *FakeSecureSession) recordInvocation(key string, args []interface{}) {
   374  	fake.invocationsMutex.Lock()
   375  	defer fake.invocationsMutex.Unlock()
   376  	if fake.invocations == nil {
   377  		fake.invocations = map[string][][]interface{}{}
   378  	}
   379  	if fake.invocations[key] == nil {
   380  		fake.invocations[key] = [][]interface{}{}
   381  	}
   382  	fake.invocations[key] = append(fake.invocations[key], args)
   383  }
   384  
   385  var _ sshCmd.SecureSession = new(FakeSecureSession)