(t *testing.T)
| 1260 | } |
| 1261 | |
| 1262 | func TestRequestReceiveEncrypted(t *testing.T) { |
| 1263 | if testing.Short() { |
| 1264 | t.Skip("skipping on short testing - scrypt is too slow") |
| 1265 | } |
| 1266 | |
| 1267 | w, fcfg := newDefaultCfgWrapper(t) |
| 1268 | tfs := fcfg.Filesystem() |
| 1269 | fcfg.Type = config.FolderTypeReceiveEncrypted |
| 1270 | setFolder(t, w, fcfg) |
| 1271 | |
| 1272 | encToken := protocol.PasswordToken(protocol.NewKeyGenerator(), fcfg.ID, "pw") |
| 1273 | must(t, writeEncryptionToken(encToken, fcfg)) |
| 1274 | |
| 1275 | m := setupModel(t, w) |
| 1276 | defer cleanupModelAndRemoveDir(m, tfs.URI()) |
| 1277 | |
| 1278 | files := genFiles(2) |
| 1279 | files[1].LocalFlags = protocol.FlagLocalReceiveOnly |
| 1280 | m.sdb.Update(fcfg.ID, protocol.LocalDeviceID, files) |
| 1281 | |
| 1282 | indexChan := make(chan []protocol.FileInfo, 10) |
| 1283 | done := make(chan struct{}) |
| 1284 | defer close(done) |
| 1285 | fc := newFakeConnection(device1, m) |
| 1286 | fc.folder = fcfg.ID |
| 1287 | fc.setIndexFn(func(_ context.Context, _ string, fs []protocol.FileInfo) error { |
| 1288 | select { |
| 1289 | case indexChan <- fs: |
| 1290 | case <-done: |
| 1291 | } |
| 1292 | return nil |
| 1293 | }) |
| 1294 | m.AddConnection(fc, protocol.Hello{}) |
| 1295 | m.ClusterConfig(fc, &protocol.ClusterConfig{ |
| 1296 | Folders: []protocol.Folder{ |
| 1297 | { |
| 1298 | ID: "default", |
| 1299 | Devices: []protocol.Device{ |
| 1300 | { |
| 1301 | ID: myID, |
| 1302 | EncryptionPasswordToken: encToken, |
| 1303 | }, |
| 1304 | {ID: device1}, |
| 1305 | }, |
| 1306 | }, |
| 1307 | }, |
| 1308 | }) |
| 1309 | |
| 1310 | select { |
| 1311 | case fs := <-indexChan: |
| 1312 | if len(fs) != 1 { |
| 1313 | t.Error("Expected index with one file, got", fs) |
| 1314 | } |
| 1315 | if got := fs[0].Name; got != files[0].Name { |
| 1316 | t.Errorf("Expected file %v, got %v", got, files[0].Name) |
| 1317 | } |
| 1318 | case <-time.After(5 * time.Second): |
| 1319 | t.Fatal("timed out before receiving index") |
nothing calls this directly
no test coverage detected