github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/ssh/sshfakes/fake_secure_client.go (about) 1 // This file was generated by counterfeiter 2 package sshfakes 3 4 import ( 5 "net" 6 "sync" 7 8 "code.cloudfoundry.org/cli/cf/ssh" 9 "golang.org/x/crypto/ssh" 10 ) 11 12 type FakeSecureClient struct { 13 NewSessionStub func() (sshCmd.SecureSession, error) 14 newSessionMutex sync.RWMutex 15 newSessionArgsForCall []struct{} 16 newSessionReturns struct { 17 result1 sshCmd.SecureSession 18 result2 error 19 } 20 ConnStub func() ssh.Conn 21 connMutex sync.RWMutex 22 connArgsForCall []struct{} 23 connReturns struct { 24 result1 ssh.Conn 25 } 26 DialStub func(network, address string) (net.Conn, error) 27 dialMutex sync.RWMutex 28 dialArgsForCall []struct { 29 network string 30 address string 31 } 32 dialReturns struct { 33 result1 net.Conn 34 result2 error 35 } 36 WaitStub func() error 37 waitMutex sync.RWMutex 38 waitArgsForCall []struct{} 39 waitReturns struct { 40 result1 error 41 } 42 CloseStub func() error 43 closeMutex sync.RWMutex 44 closeArgsForCall []struct{} 45 closeReturns struct { 46 result1 error 47 } 48 invocations map[string][][]interface{} 49 invocationsMutex sync.RWMutex 50 } 51 52 func (fake *FakeSecureClient) NewSession() (sshCmd.SecureSession, error) { 53 fake.newSessionMutex.Lock() 54 fake.newSessionArgsForCall = append(fake.newSessionArgsForCall, struct{}{}) 55 fake.recordInvocation("NewSession", []interface{}{}) 56 fake.newSessionMutex.Unlock() 57 if fake.NewSessionStub != nil { 58 return fake.NewSessionStub() 59 } else { 60 return fake.newSessionReturns.result1, fake.newSessionReturns.result2 61 } 62 } 63 64 func (fake *FakeSecureClient) NewSessionCallCount() int { 65 fake.newSessionMutex.RLock() 66 defer fake.newSessionMutex.RUnlock() 67 return len(fake.newSessionArgsForCall) 68 } 69 70 func (fake *FakeSecureClient) NewSessionReturns(result1 sshCmd.SecureSession, result2 error) { 71 fake.NewSessionStub = nil 72 fake.newSessionReturns = struct { 73 result1 sshCmd.SecureSession 74 result2 error 75 }{result1, result2} 76 } 77 78 func (fake *FakeSecureClient) Conn() ssh.Conn { 79 fake.connMutex.Lock() 80 fake.connArgsForCall = append(fake.connArgsForCall, struct{}{}) 81 fake.recordInvocation("Conn", []interface{}{}) 82 fake.connMutex.Unlock() 83 if fake.ConnStub != nil { 84 return fake.ConnStub() 85 } else { 86 return fake.connReturns.result1 87 } 88 } 89 90 func (fake *FakeSecureClient) ConnCallCount() int { 91 fake.connMutex.RLock() 92 defer fake.connMutex.RUnlock() 93 return len(fake.connArgsForCall) 94 } 95 96 func (fake *FakeSecureClient) ConnReturns(result1 ssh.Conn) { 97 fake.ConnStub = nil 98 fake.connReturns = struct { 99 result1 ssh.Conn 100 }{result1} 101 } 102 103 func (fake *FakeSecureClient) Dial(network string, address string) (net.Conn, error) { 104 fake.dialMutex.Lock() 105 fake.dialArgsForCall = append(fake.dialArgsForCall, struct { 106 network string 107 address string 108 }{network, address}) 109 fake.recordInvocation("Dial", []interface{}{network, address}) 110 fake.dialMutex.Unlock() 111 if fake.DialStub != nil { 112 return fake.DialStub(network, address) 113 } else { 114 return fake.dialReturns.result1, fake.dialReturns.result2 115 } 116 } 117 118 func (fake *FakeSecureClient) DialCallCount() int { 119 fake.dialMutex.RLock() 120 defer fake.dialMutex.RUnlock() 121 return len(fake.dialArgsForCall) 122 } 123 124 func (fake *FakeSecureClient) DialArgsForCall(i int) (string, string) { 125 fake.dialMutex.RLock() 126 defer fake.dialMutex.RUnlock() 127 return fake.dialArgsForCall[i].network, fake.dialArgsForCall[i].address 128 } 129 130 func (fake *FakeSecureClient) DialReturns(result1 net.Conn, result2 error) { 131 fake.DialStub = nil 132 fake.dialReturns = struct { 133 result1 net.Conn 134 result2 error 135 }{result1, result2} 136 } 137 138 func (fake *FakeSecureClient) Wait() error { 139 fake.waitMutex.Lock() 140 fake.waitArgsForCall = append(fake.waitArgsForCall, struct{}{}) 141 fake.recordInvocation("Wait", []interface{}{}) 142 fake.waitMutex.Unlock() 143 if fake.WaitStub != nil { 144 return fake.WaitStub() 145 } else { 146 return fake.waitReturns.result1 147 } 148 } 149 150 func (fake *FakeSecureClient) WaitCallCount() int { 151 fake.waitMutex.RLock() 152 defer fake.waitMutex.RUnlock() 153 return len(fake.waitArgsForCall) 154 } 155 156 func (fake *FakeSecureClient) WaitReturns(result1 error) { 157 fake.WaitStub = nil 158 fake.waitReturns = struct { 159 result1 error 160 }{result1} 161 } 162 163 func (fake *FakeSecureClient) Close() error { 164 fake.closeMutex.Lock() 165 fake.closeArgsForCall = append(fake.closeArgsForCall, struct{}{}) 166 fake.recordInvocation("Close", []interface{}{}) 167 fake.closeMutex.Unlock() 168 if fake.CloseStub != nil { 169 return fake.CloseStub() 170 } else { 171 return fake.closeReturns.result1 172 } 173 } 174 175 func (fake *FakeSecureClient) CloseCallCount() int { 176 fake.closeMutex.RLock() 177 defer fake.closeMutex.RUnlock() 178 return len(fake.closeArgsForCall) 179 } 180 181 func (fake *FakeSecureClient) CloseReturns(result1 error) { 182 fake.CloseStub = nil 183 fake.closeReturns = struct { 184 result1 error 185 }{result1} 186 } 187 188 func (fake *FakeSecureClient) Invocations() map[string][][]interface{} { 189 fake.invocationsMutex.RLock() 190 defer fake.invocationsMutex.RUnlock() 191 fake.newSessionMutex.RLock() 192 defer fake.newSessionMutex.RUnlock() 193 fake.connMutex.RLock() 194 defer fake.connMutex.RUnlock() 195 fake.dialMutex.RLock() 196 defer fake.dialMutex.RUnlock() 197 fake.waitMutex.RLock() 198 defer fake.waitMutex.RUnlock() 199 fake.closeMutex.RLock() 200 defer fake.closeMutex.RUnlock() 201 return fake.invocations 202 } 203 204 func (fake *FakeSecureClient) recordInvocation(key string, args []interface{}) { 205 fake.invocationsMutex.Lock() 206 defer fake.invocationsMutex.Unlock() 207 if fake.invocations == nil { 208 fake.invocations = map[string][][]interface{}{} 209 } 210 if fake.invocations[key] == nil { 211 fake.invocations[key] = [][]interface{}{} 212 } 213 fake.invocations[key] = append(fake.invocations[key], args) 214 } 215 216 var _ sshCmd.SecureClient = new(FakeSecureClient)