Debian Codegraph @

sasquatch_test.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package sasquatchscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.14 bytes/"
5 "io/ioutilscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/"
6 "testingscip-go gomod github.com/golang/go/src go1.14 testing/"
7
8 "github.com/mitchellh/go-homedirscip-go gomod github.com/mitchellh/go-homedir v1.1.0 `github.com/mitchellh/go-homedir`/"
9 )
10
11 func TestFindSSHKeysscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestFindSSHKeys().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•12 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
13 keys, err := FindSSHKeysscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/FindSSHKeys().()
14 if err != nil {
15 t.Errorscip-go gomod github.com/golang/go/src go1.14 testing/common#Error().(err)
16 }
17
18 if len(keys) == 0 {
19 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().("no keys found")
20 }
21 // fmt.Println(keys)
22 }
23
24 func TestFindSSHAgentSignersscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestFindSSHAgentSigners().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•25 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
26 signers, err := SSHAgentSignersscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/SSHAgentSigners().()
27 if err != nil {
28 t.Errorscip-go gomod github.com/golang/go/src go1.14 testing/common#Error().(err)
29 }
30
31 if len(signers) == 0 {
32 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().("no signers found")
33 }
34
35 /*
36 for _, k := range signers {
37 s := EncodeToString(k.PublicKey().Marshal())
38 fmt.Println(s)
39 }
40 */
41 }
42
43 func TestFindRecipientsscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestFindRecipients().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•44 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
45 rcp := FindRecipientsscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/FindRecipients().()
46
47 if len(rcp) == 0 {
48 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().("no recipients found")
49 }
50 }
51
52 func TestFindIdentitiesscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestFindIdentities().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•53 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
54 identities := FindIdentitiesscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/FindIdentities().()
55
56 if len(identities) == 0 {
57 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().("no identities found")
58 }
59 }
60
61 func TestIdentityFromFilescip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestIdentityFromFile().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•62 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
63 key, _ := homedirscip-go gomod github.com/mitchellh/go-homedir v1.1.0 `github.com/mitchellh/go-homedir`/.Expandscip-go gomod github.com/mitchellh/go-homedir v1.1.0 `github.com/mitchellh/go-homedir`/Expand().("~/.ssh/id_rsa")
64 i, err := ParseIdentitiesFilescip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/ParseIdentitiesFile().(key)
65 if err != nil {
66 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
67 }
68
69 if len(i) == 0 {
70 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().("no key found")
71 }
72 }
73
74 func TestRecipientFromPubKeyscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestRecipientFromPubKey().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
75 pubkey := `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCnpGXlDvHC7YbQTBhxYnQVFlPjhG9NJzJA+DvucLjyEhoFZT7FRd1Zpy1vX3asswolBW+BkfI7y0opamhWoJbUKZFXsQnymfLknqMZ10FcXBpkbGj/wE9NdDu36CORb9W9mItwhqrIY5eAhktMmVnqaq3bqRW08y8BiTzbt17ulxr81/OFymKPnX5qKfGErKXkT8L8umuGcNknpumyDHvxDHWQ8El4KmLDHFb7UsZxY272dMuFXXGVCN90V5aEzXNklPhkHcQnaCvGhPmBwQBCjaBYc+0oQFLO7+s1mXkS92pt4hiX1Srui+VYtTN6Laqcu/HIwFjKC65EmNCW/6t9XzP+lZbu9U5gRPLS3tDEUkp5j3yMyM/E28fdsGvYnb8Fyj7ifV6fCcWvCkEfj+vDK4iJn9NmkPfsQvt4Hi4p5voPyCZw6PvCyQZW1jpIDDBBtGZxOxAn9aVQicJ34ZIusbCgygLonkgZ/C67Kd9ewIsNLGYjtKvo8k6l6vqWjqt5HmQCIT6SPMEhlh9hitcLbUh7EvcpqfMpClSpEDwnbh7k1g4Izv073ky16ACT0IA2ocGXnZGcjUYNiPhYry4hzajSTCveJJrOWi0j13BSSZJa9j0EsVSGHzln+H/Oz8V4QqOOnlw8Kuud9FPnOgA6e7+jRAk3aSpulNosUtsMUw==`
76 _, err := ParseRecipientscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/ParseRecipient().(pubkey)
77 if err != nil {
78 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
79 }
80
81 pubkey = `ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBEpRrRQBpDXgGZqrUUEHN2U0phczPsnJGJgllvTZMH2`
82 _, err = ParseRecipientscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/ParseRecipient().(pubkey)
83 if err != nil {
84 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
85 }
86 }
87
88 func TestSSHRSAEncryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestSSHRSAEncrypt().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•89 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
90 buf := bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.14 bytes/NewBuffer().(nil)
91
92 key, _ := homedirscip-go gomod github.com/mitchellh/go-homedir v1.1.0 `github.com/mitchellh/go-homedir`/.Expandscip-go gomod github.com/mitchellh/go-homedir v1.1.0 `github.com/mitchellh/go-homedir`/Expand().("~/.ssh/id_rsa.pub")
93 c, err := ioutilscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/.ReadFilescip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/ReadFile().(key)
94 if err != nil {
95 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
96 }
97
98 r, err := ParseRecipientscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/ParseRecipient().(string(c))
99 if err != nil {
100 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
101 }
102
103 w, err := Encryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Encrypt().(buf, r)
104 if err != nil {
105 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
106 }
107
108 data := []byte("Hello World!")
109 _, err = w.Writescip-go gomod github.com/golang/go/src go1.14 io/Writer#Write().(data)
110 if err != nil {
111 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
112 }
113 err = w.Closescip-go gomod github.com/golang/go/src go1.14 io/Closer#Close().()
114 if err != nil {
115 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
116 }
117
118 // _ = ioutil.WriteFile("/tmp/sasquatch.crypted.rsa", buf.Bytes(), 0644)
119
120 ids := FindIdentitiesscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/FindIdentities().()
121 dr, err := Decryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Decrypt().(buf, ids...)
122 if err != nil {
123 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
124 }
125
126 dbuf, _ := ioutilscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/ReadAll().(dr)
127 if !bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.Equalscip-go gomod github.com/golang/go/src go1.14 bytes/Equal().(dbuf, data) {
128 t.Fatalfscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatalf().("Decrypted data does not match!")
129 }
130 }
131
132 func TestSSHEd25519Encryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestSSHEd25519Encrypt().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•133 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
134 buf := bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.14 bytes/NewBuffer().(nil)
135
136 key, _ := homedirscip-go gomod github.com/mitchellh/go-homedir v1.1.0 `github.com/mitchellh/go-homedir`/.Expandscip-go gomod github.com/mitchellh/go-homedir v1.1.0 `github.com/mitchellh/go-homedir`/Expand().("~/.ssh/id_ed25519.pub")
137 c, err := ioutilscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/.ReadFilescip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/ReadFile().(key)
138 if err != nil {
139 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
140 }
141
142 r, err := ParseRecipientscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/ParseRecipient().(string(c))
143 if err != nil {
144 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
145 }
146
147 w, err := Encryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Encrypt().(buf, r)
148 if err != nil {
149 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
150 }
151
152 data := []byte("Hello World!")
153 _, err = w.Writescip-go gomod github.com/golang/go/src go1.14 io/Writer#Write().(data)
154 if err != nil {
155 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
156 }
157 err = w.Closescip-go gomod github.com/golang/go/src go1.14 io/Closer#Close().()
158 if err != nil {
159 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
160 }
161
162 // _ = ioutil.WriteFile("/tmp/sasquatch.crypted.ed25519", buf.Bytes(), 0644)
163
164 ids := FindIdentitiesscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/FindIdentities().()
165 dr, err := Decryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Decrypt().(buf, ids...)
166 if err != nil {
167 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
168 }
169
170 dbuf, _ := ioutilscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/ReadAll().(dr)
171 if !bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.Equalscip-go gomod github.com/golang/go/src go1.14 bytes/Equal().(dbuf, data) {
172 t.Fatalfscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatalf().("Decrypted data does not match!")
173 }
174 }
175
176 func TestChallengeEncryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestChallengeEncrypt().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
•177 t.Skipscip-go gomod github.com/golang/go/src go1.14 testing/common#Skip().("test requires SSH key, skipping")
178 buf := bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.14 bytes/NewBuffer().(nil)
179
180 signers, err := SSHAgentSignersscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/SSHAgentSigners().()
181 if err != nil {
182 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
183 }
184
185 r, err := NewChallengeRecipientscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/NewChallengeRecipient().(signers[0])
186 if err != nil {
187 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
188 }
189
190 w, err := Encryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Encrypt().(buf, r)
191 if err != nil {
192 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
193 }
194
195 data := []byte("Hello World!")
196 _, err = w.Writescip-go gomod github.com/golang/go/src go1.14 io/Writer#Write().(data)
197 if err != nil {
198 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
199 }
200 err = w.Closescip-go gomod github.com/golang/go/src go1.14 io/Closer#Close().()
201 if err != nil {
202 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
203 }
204
205 // _ = ioutil.WriteFile("/tmp/sasquatch.crypted.agent", buf.Bytes(), 0644)
206
207 ids := FindIdentitiesscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/FindIdentities().()
208 dr, err := Decryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Decrypt().(buf, ids...)
209 if err != nil {
210 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
211 }
212
213 dbuf, _ := ioutilscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/ReadAll().(dr)
214 if !bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.Equalscip-go gomod github.com/golang/go/src go1.14 bytes/Equal().(dbuf, data) {
215 t.Fatalfscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatalf().("Decrypted data does not match!")
216 }
217 }
218
219 func TestScryptEncryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/TestScryptEncrypt().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
220 buf := bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.14 bytes/NewBuffer().(nil)
221
222 r, err := NewScryptRecipientscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/NewScryptRecipient().("password")
223 if err != nil {
224 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
225 }
226
227 w, err := Encryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Encrypt().(buf, r)
228 if err != nil {
229 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
230 }
231
232 data := []byte("Hello World!")
233 _, err = w.Writescip-go gomod github.com/golang/go/src go1.14 io/Writer#Write().(data)
234 if err != nil {
235 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
236 }
237 err = w.Closescip-go gomod github.com/golang/go/src go1.14 io/Closer#Close().()
238 if err != nil {
239 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
240 }
241
242 id, err := NewScryptIdentityscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/NewScryptIdentity().("password")
243 if err != nil {
244 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
245 }
246
247 dr, err := Decryptscip-go gomod github.com/muesli/sasquatch . `github.com/muesli/sasquatch`/Decrypt().(buf, id)
248 if err != nil {
249 t.Fatalscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatal().(err)
250 }
251
252 dbuf, _ := ioutilscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.14 `io/ioutil`/ReadAll().(dr)
253 if !bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.Equalscip-go gomod github.com/golang/go/src go1.14 bytes/Equal().(dbuf, data) {
254 t.Fatalfscip-go gomod github.com/golang/go/src go1.14 testing/common#Fatalf().("Decrypted data does not match!")
255 }
256 }