github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/libkb/api_stub.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 //go:build !production 5 // +build !production 6 7 package libkb 8 9 import ( 10 "strings" 11 12 "github.com/PuerkitoBio/goquery" 13 ) 14 15 type StubAPIEngine struct { 16 *ExternalAPIEngine 17 } 18 19 func NewStubAPIEngine(g *GlobalContext) *StubAPIEngine { 20 return &StubAPIEngine{ 21 ExternalAPIEngine: &ExternalAPIEngine{BaseAPIEngine{Contextified: NewContextified(g), clients: make(map[int]*Client)}}, 22 } 23 } 24 25 func (e *StubAPIEngine) Get(m MetaContext, arg APIArg) (res *ExternalAPIRes, err error) { 26 return e.ExternalAPIEngine.Get(m, arg) 27 } 28 29 func (e *StubAPIEngine) GetHTML(m MetaContext, arg APIArg) (res *ExternalHTMLRes, err error) { 30 if body, ok := htmlAPIStubs[arg.Endpoint]; ok { 31 doc, err := goquery.NewDocumentFromReader(strings.NewReader(body)) 32 if err != nil { 33 return nil, err 34 } 35 return &ExternalHTMLRes{ 36 GoQuery: doc, 37 HTTPStatus: 200, 38 }, nil 39 } 40 return e.ExternalAPIEngine.GetHTML(m, arg) 41 } 42 43 func (e *StubAPIEngine) GetText(m MetaContext, arg APIArg) (*ExternalTextRes, error) { 44 if body, ok := apiStubs[arg.Endpoint]; ok { 45 return &ExternalTextRes{Body: body, HTTPStatus: 200}, nil 46 } 47 return e.ExternalAPIEngine.GetText(m, arg) 48 } 49 50 var apiStubs = map[string]string{ 51 "https://gist.githubusercontent.com/kbtester1/9f6c0787825f4fcc81f7/raw/1ec930037d05bbd2496e862a023d69ae6cc4c215/keybase.md": `### Keybase proof 52 53 I hereby claim: 54 55 * I am kbtester1 on github. 56 * I am t_bob (https://keybase.io/t_bob) on keybase. 57 * I have a public key whose fingerprint is 91FE 9B24 EF67 06B1 F789 8F20 59A2 A43F 8B73 1F29 58 59 To claim this, I am signing this object: 60 61 json 62 { 63 "body": { 64 "client": { 65 "name": "keybase.io node.js client", 66 "version": "0.7.5" 67 }, 68 "key": { 69 "fingerprint": "91fe9b24ef6706b1f7898f2059a2a43f8b731f29", 70 "host": "keybase.io", 71 "key_id": "59A2A43F8B731F29", 72 "uid": "afb5eda3154bc13c1df0189ce93ba119", 73 "username": "t_bob" 74 }, 75 "merkle_root": { 76 "ctime": 1424293533, 77 "hash": "976e2bd970e1375d2a4c906ddef53e015e4bcbee8d87f7d1992e0344abe36f3d2e622efa9d2715d3350b7be5e981357d7e9c93db84c041210df98a3747c84073", 78 "seqno": 5 79 }, 80 "service": { 81 "name": "github", 82 "username": "kbtester1" 83 }, 84 "type": "web_service_binding", 85 "version": 1 86 }, 87 "ctime": 1424293535, 88 "expire_in": 157680000, 89 "prev": "4364d76671c1a7cc4d4597aee4c534ea4086e3831e867010ae0509832608c1d0", 90 "seqno": 2, 91 "tag": "signature" 92 } 93 94 95 with the key [91FE 9B24 EF67 06B1 F789 8F20 59A2 A43F 8B73 1F29](https://keybase.io/t_bob), yielding the signature: 96 97 98 -----BEGIN PGP MESSAGE----- 99 Version: GnuPG/MacGPG2 v2 100 101 owFdUltsFVUUvb3YgmgDojGiVcuA0YTbm/OcM6etFTRp/OJDjD9qrufM2XPvtHTm 102 OjOtlJsGH1Hsj8EHvhptaEET8AMlPAwtGnkUQ2orwWiCjcRACNEYw4cBNMaZmxrB 103 87Wz99prr3X23tq8IJdviJ5ov9T15URrw8mLOvf4ub9Ha5YOzaDVXrPcDT4ESRYF 104 qg+sdqsXBrWKoeiHrUFooNgTt85jCtYARLEfBikKFUWRW0OFDJ41e35Qhqga+RmX 105 JbEHUhMGni2QrbEnHOl4BHGpiGLUc7Sg2CMypayEcXLdVKvOWfJNmuVyLVnLaLfz 106 cIrvruP76wXlaQ5GUcyZdjF1sfEQdqQLkmqFcR0YQzRvKSnpUGdi+yDq3QClKAzr 107 jt3Ez+qYEUYk5ZSmclRcyQwIG4g2UiDAVHCTqnYlso0Bj1NAmEM6VwM4xhGeMFhK 108 AogypjRQ26OGgE0IeEoaIjA3lHKkhQYO0sGUCyNAupIa7TAXMUwwMp50FBVMuA5D 109 gqb6Y3g2CK12PpSF0YDvwjVLKvtJpV9f77JXJxAnEOHMaTJYzXLPgS7Nd5e0Hxg/ 110 GC1fu0ecQv//C7xgwcaqH0HJzxBc2A5KX8GqRjCQcjJqMyNsW2AXK+G6zDAuhQJg 111 LqcMFEOODdShGJx0+xgpQBxJhxIbOemi0H/eSKpTlVPK2C8HKumPwBoabmi5IdeQ 112 zzU15rNDzS2+cem/17vn1UW5mdnOw317u/atXL3wIPrrapM1Jtcc3o4fqu76oXLi 113 44svfLPgzEenu34abxv+896Ryzuu7Hn0tml993vrF0c/Tk183vlmcNPkp9M7F47d 114 9eLZn99vemvm2zeO/fp0bQJdngrWL227OnhhE8R/3HrifMfrIx073jkw9ciTMz2F 115 VeXKpfOdq3p63hWj418s23pqfNvIgQ+OzW3e+N2hJS/lT52+0la6ffjcTMuuoOOZ 116 LWvQfV/3rXtwUfMts3P3HM0Xx/Yf2j7dff/yWuOR/trumxuf33cwv2Xg9xXo5BJy 117 58hTHx59eXb5Z78dSTZ/9djq/IXJ45/sbd55R7Ltte7Zt385/sqmydaWeP/cimX8 118 zAPf187+Aw== 119 =Zpkd 120 -----END PGP MESSAGE----- 121 122 123 124 And finally, I am proving ownership of the github account by posting this as a gist. 125 126 ### My publicly-auditable identity: 127 128 https://keybase.io/t_bob 129 130 ### From the command line: 131 132 Consider the [keybase command line program](https://keybase.io/docs/command_line). 133 134 bash 135 # look me up 136 keybase id t_bob 137 138 # encrypt a message to me 139 keybase encrypt t_bob -m 'a secret message...' 140 141 # ...and more... 142 `, 143 "https://gist.githubusercontent.com/kbtester2/3cbaad55bfae3ed948d9/raw/0c5a148629e3f405ed8d640b8fa432a073da56c8/keybase.md": `### Keybase proof 144 145 I hereby claim: 146 147 * I am kbtester2 on github. 148 * I am t_alice (https://keybase.io/t_alice) on keybase. 149 * I have a public key whose fingerprint is 2373 FD08 9F28 F328 916B 88F9 9C79 27C0 BDFD ADF9 150 151 To claim this, I am signing this object: 152 153 json 154 { 155 "body": { 156 "client": { 157 "name": "keybase.io node.js client", 158 "version": "0.7.5" 159 }, 160 "key": { 161 "fingerprint": "2373fd089f28f328916b88f99c7927c0bdfdadf9", 162 "host": "keybase.io", 163 "key_id": "9C7927C0BDFDADF9", 164 "uid": "295a7eea607af32040647123732bc819", 165 "username": "t_alice" 166 }, 167 "merkle_root": { 168 "ctime": 1424293518, 169 "hash": "fd557b6743f705d3672e919102a78b2a2371af34735bff33db524c5baecda8fd61c6c625ecc1ce1f7a2ed435e1c82c9a6c2ff861782daf86a9dd6594c278ac1e", 170 "seqno": 2 171 }, 172 "service": { 173 "name": "github", 174 "username": "kbtester2" 175 }, 176 "type": "web_service_binding", 177 "version": 1 178 }, 179 "ctime": 1424293523, 180 "expire_in": 157680000, 181 "prev": "68700c8bf6c727934f126c5dcc5ef4dacfe450663435065e7930f1f87d3b5333", 182 "seqno": 2, 183 "tag": "signature" 184 } 185 186 with the key [2373 FD08 9F28 F328 916B 88F9 9C79 27C0 BDFD ADF9](https://keybase.io/t_alice), yielding the signature: 187 188 -----BEGIN PGP MESSAGE----- 189 Version: GnuPG/MacGPG2 v2 190 191 owFdkm9oVWUcx++uzlhcIUTsRV6yUy8mXOZ5nuc8f840y3ZRYhAhijrIw3OeP/ee 192 dnfv3Tlnm3NbRJYRWRg6wvLFpmDBpmVBBHNhL0yimDBZkqKBhJbppg2j8LJ6zlik 193 nVc/nufz+35/3/N79i9dlErXTc86qPPR/R/Uffern9ry89yBPsuvyF6ruc8SpUCV 194 46Qq8w5lNVvtqtfnkWoKKqvKFamaXo5WLTA5q1uFUVApG8puok3YGsgleNKsg3JB 195 hdUwSLQsiCjS0mauhkwjyFxAfMa06wrqQipsX2rJpXaNZLESxQ+4WvOaXiDNqduS 196 8C32c/mN+Q35jQnfNX8BXcypUpzYlBsD27GJQ0FiC33BwDwYqXAhUuzxUiBUMm6H 197 CttLygsrlfnMIg4SAjjQgS7CgJmBeFQ0PVpiTH1CHaSpjSUiFCoXuMCGnDIfcuMF 198 jLVDEfa1Rkj6GDoC+1wJyZmWBAgiCMRKCCAU0JRDJR2EFRAMCpcTAbVmBFAGJTcF 199 d6Uk2HUEpIwLoEyCSHWWK1YzHEjKsDtJ8N+aCkFc7PIfzNnuxyqKVQiTpHFvNTnr 200 Ub630O35QVkOm0Xdv0lg0P/9BYhyltpVDULlBQmBKWG2+XJWNVTdRpMwatuC+ZoI 201 CqmLHA0gEVgKgZV2JBdaOdgmBJm8NsHKILYGmlGJfIwQui+bmZMXjGQUFMo87grN 202 kt6qW7k4VZdOLalPJ0819XDDI/++X/7CQ7WlrbWpzGOTlz8+8ea13MVNeydfv/Ph 203 6GBrJnP87HDIhnpq3/+GXnp/6pWx5fJptXd8x4YxOFK4UF8cLA4suz15cfWz3/yx 204 fOhUfnDdjWNP7s7woYls6VBf6/aZZ1ZeQPtevf5R7fq3vxxbll39++5NnZfW1cb+ 205 yoxca+sfLJ3sp2/frd/ZcqTh9KWZT7YcfWpf40TwxOiajPf3RGPH5htz711d3//V 206 3PFd538C09s/XZudGfV+PPfDi4fHv5je4VWH2+6VXkuPzKzI3zxzSH82e+XLq1MH 207 Fr2x9Wv4zvptYE999vK7Vw5Otjyfnv3zVOPpe+MN9pm2xztOznahW9lbny8uumfv 208 nj+3p+dg+h8= 209 =iePR 210 -----END PGP MESSAGE----- 211 212 213 And finally, I am proving ownership of the github account by posting this as a gist. 214 215 ### My publicly-auditable identity: 216 217 https://keybase.io/t_alice 218 219 ### From the command line: 220 221 Consider the [keybase command line program](https://keybase.io/docs/command_line). 222 223 bash 224 # look me up 225 keybase id t_alice 226 227 # encrypt a message to me 228 keybase encrypt t_alice -m 'a secret message...' 229 230 # ...and more... 231 232 `, 233 "https://gist.githubusercontent.com/tacoplusplus/d21a10f2d7f6447dba7d/raw/cfeb4ffbec5f555bddf4ce23ea43bcb7613c6577/keybase.md": `### Keybase proof 234 235 I hereby claim: 236 237 * I am tacoplusplus on github. 238 * I am t_charlie (https://keybase.io/t_charlie) on keybase. 239 * I have a public key whose fingerprint is 6FB9 1F01 1D89 542A C1C0 947D DE0F 9384 9129 7B7F 240 241 To claim this, I am signing this object: 242 243 json 244 { 245 "body": { 246 "client": { 247 "name": "keybase.io node.js client", 248 "version": "0.7.5" 249 }, 250 "key": { 251 "fingerprint": "6fb91f011d89542ac1c0947dde0f938491297b7f", 252 "host": "keybase.io", 253 "key_id": "DE0F938491297B7F", 254 "uid": "9d56bd0c02ac2711e142faf484ea9519", 255 "username": "t_charlie" 256 }, 257 "merkle_root": { 258 "ctime": 1424293546, 259 "hash": "ad25d6ffda2195229175f7199e6fca799b36ca03523c2fb8030f9b81bb185ea7a4babfdbf7650e80a0ecb015a0bfd6382fe42b11b4914aff5812d3667cb4cd33", 260 "seqno": 8 261 }, 262 "service": { 263 "name": "github", 264 "username": "tacoplusplus" 265 }, 266 "type": "web_service_binding", 267 "version": 1 268 }, 269 "ctime": 1424293548, 270 "expire_in": 157680000, 271 "prev": "1dd32ec2e951f642d6f88ac93f07c69b1195d63d9011cfe5ff14a889c8af3d54", 272 "seqno": 2, 273 "tag": "signature" 274 } 275 276 with the key [6FB9 1F01 1D89 542A C1C0 947D DE0F 9384 9129 7B7F](https://keybase.io/t_charlie), yielding the signature: 277 278 -----BEGIN PGP MESSAGE----- 279 Version: GnuPG/MacGPG2 v2 280 281 owFdkl1sFUUUx+9toUJFPpWibQJsUnngWmZmd3ZnClIw5SakxgipNJCY2/m83dK7 282 e9m9t7aBykdoCA986AMoJCQaEaKGNEQrFF54oMYYDOGjDSRqNTURDST0wfigjbNN 283 QWSTTSZn/uc/53fOOfpcZaoifX9ieI/c/XFd+rt7PNU6PvnFTouHstdq3GmJLl8F 284 peQUsIKyGq3tqpezWDX44bIglKqhM142rclY3SqK/TAwKtDgNWCrL5PIk2TtB3kV 285 FSM/8bJczSnUAEJJKHYQE1AA6nhSKqCpTRwKEfW4p41lRxiX/veqNeWZ86WJNm8A 286 2cf617ysuStPXVCJXS6BAMYbeRAq6CDNtEMcxSiGNBHGKppGKuVEB4sMRFJwQUXb 287 u1QuCsMpalHyE43JdxC1seOakljcYbKYRFi6WkuGIMUIUehh7UFKlasF8yjltisY 288 sDGyBdKcANvAcQI5hwQr5jGHM64l156LgSKAASU4gJgBE3VtgrRyEIeQGzyHaY0J 289 RNJ2XU9wR0jbNgyx2hGEViPpS45Rty/UE4PK+6WOMn+KlImw2FWOkz+BLfUWk/A7 290 iuemDT7NcT+QZlpPjhMa6dONIBlL9RT9SOX8RIE9lwDzZaxipLqNJ5TSRkogZfqt 291 XQeZVhHCBLU18IRLDRg17bMlNWsgtMJaG0pCqCBM2xI7/+EhUyfLG8vYzwesVI7M 292 nA6m62ak0hWpqpkVyb6mqmfPf7TE2bnP/FNz6spoW/7MxuuvV+vdnx/tuzerOavb 293 g9biX5fw0E+1mwuHXm4Zrf96zeaNrcOF5z8cz/YvvDv77Ok7P3feHx+67v+2ItP+ 294 +yJn4tZ7uPrNW6uWDsVNY3VvjO36oVo9e7vml4UvTdSom1fPozX9n51/9/hg+81D 295 cwdvvFA70Pnwx5P5lauvztk0NnCjJ1y9b337g7Y5k3fK9VVbwbxX/i5UfZk+S/9Y 296 UR5+66MXt7wfq707vs83rxu5fKLlYH3TmV8Hl3z7Dd6S3fPBCDs2/8SBnrUXYRXa 297 9ueS28sPj26r3Ftb2XVh17zl15oefvWgtaXtWt3xFq/n7YHT5z65sKB568j+/iPr 298 XhUbGicXV/4L 299 =2qH+ 300 -----END PGP MESSAGE----- 301 302 303 And finally, I am proving ownership of the github account by posting this as a gist. 304 305 ### My publicly-auditable identity: 306 307 https://keybase.io/t_charlie 308 309 ### From the command line: 310 311 Consider the [keybase command line program](https://keybase.io/docs/command_line). 312 313 bash 314 # look me up 315 keybase id t_charlie 316 317 # encrypt a message to me 318 keybase encrypt t_charlie -m 'a secret message...' 319 320 # ...and more...`, 321 }