test_sqlcipher.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. # -*- coding: utf-8 -*-
  2. # Import python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. # Import Salt Libs
  5. import salt.pillar.sqlcipher as sqlcipher
  6. # Import Salt Testing libs
  7. from tests.support.unit import TestCase
  8. class SQLCipherPillarTestCase(TestCase):
  9. maxDiff = None
  10. def test_001_extract_queries_list(self):
  11. return_data = sqlcipher.SQLCipherExtPillar()
  12. args, kwargs = (
  13. [
  14. "SELECT blah",
  15. "SELECT blah2",
  16. ("SELECT blah3",),
  17. ("SELECT blah4", 2),
  18. {"query": "SELECT blah5"},
  19. {"query": "SELECT blah6", "depth": 2},
  20. {"query": "SELECT blah7", "as_list": True},
  21. {"query": "SELECT blah8", "with_lists": "1"},
  22. {"query": "SELECT blah9", "with_lists": "1,2"},
  23. ],
  24. {},
  25. )
  26. qbuffer = return_data.extract_queries(args, kwargs)
  27. self.assertEqual(
  28. [
  29. [
  30. None,
  31. {
  32. "query": "SELECT blah",
  33. "depth": 0,
  34. "as_list": False,
  35. "with_lists": None,
  36. "ignore_null": False,
  37. },
  38. ],
  39. [
  40. None,
  41. {
  42. "query": "SELECT blah2",
  43. "depth": 0,
  44. "as_list": False,
  45. "with_lists": None,
  46. "ignore_null": False,
  47. },
  48. ],
  49. [
  50. None,
  51. {
  52. "query": "SELECT blah3",
  53. "depth": 0,
  54. "as_list": False,
  55. "with_lists": None,
  56. "ignore_null": False,
  57. },
  58. ],
  59. [
  60. None,
  61. {
  62. "query": "SELECT blah4",
  63. "depth": 2,
  64. "as_list": False,
  65. "with_lists": None,
  66. "ignore_null": False,
  67. },
  68. ],
  69. [
  70. None,
  71. {
  72. "query": "SELECT blah5",
  73. "depth": 0,
  74. "as_list": False,
  75. "with_lists": None,
  76. "ignore_null": False,
  77. },
  78. ],
  79. [
  80. None,
  81. {
  82. "query": "SELECT blah6",
  83. "depth": 2,
  84. "as_list": False,
  85. "with_lists": None,
  86. "ignore_null": False,
  87. },
  88. ],
  89. [
  90. None,
  91. {
  92. "query": "SELECT blah7",
  93. "depth": 0,
  94. "as_list": True,
  95. "with_lists": None,
  96. "ignore_null": False,
  97. },
  98. ],
  99. [
  100. None,
  101. {
  102. "query": "SELECT blah8",
  103. "depth": 0,
  104. "as_list": False,
  105. "with_lists": [1],
  106. "ignore_null": False,
  107. },
  108. ],
  109. [
  110. None,
  111. {
  112. "query": "SELECT blah9",
  113. "depth": 0,
  114. "as_list": False,
  115. "with_lists": [1, 2],
  116. "ignore_null": False,
  117. },
  118. ],
  119. ],
  120. qbuffer,
  121. )
  122. def test_002_extract_queries_kwarg(self):
  123. return_data = sqlcipher.SQLCipherExtPillar()
  124. args, kwargs = (
  125. [],
  126. {
  127. "1": "SELECT blah",
  128. "2": "SELECT blah2",
  129. "3": ("SELECT blah3",),
  130. "4": ("SELECT blah4", 2),
  131. "5": {"query": "SELECT blah5"},
  132. "6": {"query": "SELECT blah6", "depth": 2},
  133. "7": {"query": "SELECT blah7", "as_list": True},
  134. },
  135. )
  136. qbuffer = return_data.extract_queries(args, kwargs)
  137. self.assertEqual(
  138. [
  139. [
  140. "1",
  141. {
  142. "query": "SELECT blah",
  143. "depth": 0,
  144. "as_list": False,
  145. "with_lists": None,
  146. "ignore_null": False,
  147. },
  148. ],
  149. [
  150. "2",
  151. {
  152. "query": "SELECT blah2",
  153. "depth": 0,
  154. "as_list": False,
  155. "with_lists": None,
  156. "ignore_null": False,
  157. },
  158. ],
  159. [
  160. "3",
  161. {
  162. "query": "SELECT blah3",
  163. "depth": 0,
  164. "as_list": False,
  165. "with_lists": None,
  166. "ignore_null": False,
  167. },
  168. ],
  169. [
  170. "4",
  171. {
  172. "query": "SELECT blah4",
  173. "depth": 2,
  174. "as_list": False,
  175. "with_lists": None,
  176. "ignore_null": False,
  177. },
  178. ],
  179. [
  180. "5",
  181. {
  182. "query": "SELECT blah5",
  183. "depth": 0,
  184. "as_list": False,
  185. "with_lists": None,
  186. "ignore_null": False,
  187. },
  188. ],
  189. [
  190. "6",
  191. {
  192. "query": "SELECT blah6",
  193. "depth": 2,
  194. "as_list": False,
  195. "with_lists": None,
  196. "ignore_null": False,
  197. },
  198. ],
  199. [
  200. "7",
  201. {
  202. "query": "SELECT blah7",
  203. "depth": 0,
  204. "as_list": True,
  205. "with_lists": None,
  206. "ignore_null": False,
  207. },
  208. ],
  209. ],
  210. qbuffer,
  211. )
  212. def test_003_extract_queries_mixed(self):
  213. return_data = sqlcipher.SQLCipherExtPillar()
  214. args, kwargs = (
  215. [
  216. "SELECT blah1",
  217. ("SELECT blah2", 2),
  218. {"query": "SELECT blah3", "as_list": True},
  219. ],
  220. {
  221. "1": "SELECT blah1",
  222. "2": ("SELECT blah2", 2),
  223. "3": {"query": "SELECT blah3", "as_list": True},
  224. },
  225. )
  226. qbuffer = return_data.extract_queries(args, kwargs)
  227. self.assertEqual(
  228. [
  229. [
  230. None,
  231. {
  232. "query": "SELECT blah1",
  233. "depth": 0,
  234. "as_list": False,
  235. "with_lists": None,
  236. "ignore_null": False,
  237. },
  238. ],
  239. [
  240. None,
  241. {
  242. "query": "SELECT blah2",
  243. "depth": 2,
  244. "as_list": False,
  245. "with_lists": None,
  246. "ignore_null": False,
  247. },
  248. ],
  249. [
  250. None,
  251. {
  252. "query": "SELECT blah3",
  253. "depth": 0,
  254. "as_list": True,
  255. "with_lists": None,
  256. "ignore_null": False,
  257. },
  258. ],
  259. [
  260. "1",
  261. {
  262. "query": "SELECT blah1",
  263. "depth": 0,
  264. "as_list": False,
  265. "with_lists": None,
  266. "ignore_null": False,
  267. },
  268. ],
  269. [
  270. "2",
  271. {
  272. "query": "SELECT blah2",
  273. "depth": 2,
  274. "as_list": False,
  275. "with_lists": None,
  276. "ignore_null": False,
  277. },
  278. ],
  279. [
  280. "3",
  281. {
  282. "query": "SELECT blah3",
  283. "depth": 0,
  284. "as_list": True,
  285. "with_lists": None,
  286. "ignore_null": False,
  287. },
  288. ],
  289. ],
  290. qbuffer,
  291. )
  292. def test_004_extract_queries_bogus_list(self):
  293. # This test is specifically checking that empty queries are dropped
  294. return_data = sqlcipher.SQLCipherExtPillar()
  295. args, kwargs = (
  296. [
  297. "SELECT blah",
  298. "",
  299. "SELECT blah2",
  300. ("SELECT blah3",),
  301. ("",),
  302. ("SELECT blah4", 2),
  303. tuple(),
  304. ("SELECT blah5",),
  305. {"query": "SELECT blah6"},
  306. {"query": ""},
  307. {"query": "SELECT blah7", "depth": 2},
  308. {"not_a_query": "in sight!"},
  309. {"query": "SELECT blah8", "as_list": True},
  310. ],
  311. {},
  312. )
  313. qbuffer = return_data.extract_queries(args, kwargs)
  314. self.assertEqual(
  315. [
  316. [
  317. None,
  318. {
  319. "query": "SELECT blah",
  320. "depth": 0,
  321. "as_list": False,
  322. "with_lists": None,
  323. "ignore_null": False,
  324. },
  325. ],
  326. [
  327. None,
  328. {
  329. "query": "SELECT blah2",
  330. "depth": 0,
  331. "as_list": False,
  332. "with_lists": None,
  333. "ignore_null": False,
  334. },
  335. ],
  336. [
  337. None,
  338. {
  339. "query": "SELECT blah3",
  340. "depth": 0,
  341. "as_list": False,
  342. "with_lists": None,
  343. "ignore_null": False,
  344. },
  345. ],
  346. [
  347. None,
  348. {
  349. "query": "SELECT blah4",
  350. "depth": 2,
  351. "as_list": False,
  352. "with_lists": None,
  353. "ignore_null": False,
  354. },
  355. ],
  356. [
  357. None,
  358. {
  359. "query": "SELECT blah5",
  360. "depth": 0,
  361. "as_list": False,
  362. "with_lists": None,
  363. "ignore_null": False,
  364. },
  365. ],
  366. [
  367. None,
  368. {
  369. "query": "SELECT blah6",
  370. "depth": 0,
  371. "as_list": False,
  372. "with_lists": None,
  373. "ignore_null": False,
  374. },
  375. ],
  376. [
  377. None,
  378. {
  379. "query": "SELECT blah7",
  380. "depth": 2,
  381. "as_list": False,
  382. "with_lists": None,
  383. "ignore_null": False,
  384. },
  385. ],
  386. [
  387. None,
  388. {
  389. "query": "SELECT blah8",
  390. "depth": 0,
  391. "as_list": True,
  392. "with_lists": None,
  393. "ignore_null": False,
  394. },
  395. ],
  396. ],
  397. qbuffer,
  398. )
  399. def test_005_extract_queries_bogus_kwargs(self):
  400. # this test is cut down as most of the path matches test_*_bogus_list
  401. return_data = sqlcipher.SQLCipherExtPillar()
  402. args, kwargs = [], {"1": "SELECT blah", "2": "", "3": "SELECT blah2"}
  403. qbuffer = return_data.extract_queries(args, kwargs)
  404. self.assertEqual(
  405. [
  406. [
  407. "1",
  408. {
  409. "query": "SELECT blah",
  410. "depth": 0,
  411. "as_list": False,
  412. "with_lists": None,
  413. "ignore_null": False,
  414. },
  415. ],
  416. [
  417. "3",
  418. {
  419. "query": "SELECT blah2",
  420. "depth": 0,
  421. "as_list": False,
  422. "with_lists": None,
  423. "ignore_null": False,
  424. },
  425. ],
  426. ],
  427. qbuffer,
  428. )
  429. def test_011_enter_root(self):
  430. return_data = sqlcipher.SQLCipherExtPillar()
  431. return_data.enter_root("test")
  432. self.assertEqual(return_data.result["test"], return_data.focus)
  433. return_data.enter_root(None)
  434. self.assertEqual(return_data.result, return_data.focus)
  435. def test_021_process_fields(self):
  436. return_data = sqlcipher.SQLCipherExtPillar()
  437. return_data.process_fields(["a", "b"], 0)
  438. self.assertEqual(return_data.num_fields, 2)
  439. self.assertEqual(return_data.depth, 1)
  440. return_data.process_fields(["a", "b"], 2)
  441. self.assertEqual(return_data.num_fields, 2)
  442. self.assertEqual(return_data.depth, 1)
  443. return_data.process_fields(["a", "b", "c", "d"], 0)
  444. self.assertEqual(return_data.num_fields, 4)
  445. self.assertEqual(return_data.depth, 3)
  446. return_data.process_fields(["a", "b", "c", "d"], 1)
  447. self.assertEqual(return_data.num_fields, 4)
  448. self.assertEqual(return_data.depth, 1)
  449. return_data.process_fields(["a", "b", "c", "d"], 2)
  450. self.assertEqual(return_data.num_fields, 4)
  451. self.assertEqual(return_data.depth, 2)
  452. return_data.process_fields(["a", "b", "c", "d"], 3)
  453. self.assertEqual(return_data.num_fields, 4)
  454. self.assertEqual(return_data.depth, 3)
  455. return_data.process_fields(["a", "b", "c", "d"], 4)
  456. self.assertEqual(return_data.num_fields, 4)
  457. self.assertEqual(return_data.depth, 3)
  458. def test_111_process_results_legacy(self):
  459. return_data = sqlcipher.SQLCipherExtPillar()
  460. return_data.process_fields(["a", "b"], 0)
  461. return_data.with_lists = []
  462. return_data.process_results([[1, 2]])
  463. self.assertEqual({1: 2}, return_data.result)
  464. def test_112_process_results_legacy_multiple(self):
  465. return_data = sqlcipher.SQLCipherExtPillar()
  466. return_data.process_fields(["a", "b"], 0)
  467. return_data.with_lists = []
  468. return_data.process_results([[1, 2], [3, 4], [5, 6]])
  469. self.assertEqual({1: 2, 3: 4, 5: 6}, return_data.result)
  470. def test_121_process_results_depth_0(self):
  471. return_data = sqlcipher.SQLCipherExtPillar()
  472. return_data.process_fields(["a", "b", "c", "d"], 0)
  473. return_data.with_lists = []
  474. return_data.enter_root(None)
  475. return_data.process_results([[1, 2, 3, 4], [5, 6, 7, 8]])
  476. self.assertEqual({1: {2: {3: 4}}, 5: {6: {7: 8}}}, return_data.result)
  477. def test_122_process_results_depth_1(self):
  478. return_data = sqlcipher.SQLCipherExtPillar()
  479. return_data.process_fields(["a", "b", "c", "d"], 1)
  480. return_data.with_lists = []
  481. return_data.enter_root(None)
  482. return_data.process_results([[1, 2, 3, 4], [5, 6, 7, 8]])
  483. self.assertEqual(
  484. {1: {"b": 2, "c": 3, "d": 4}, 5: {"b": 6, "c": 7, "d": 8}},
  485. return_data.result,
  486. )
  487. def test_123_process_results_depth_2(self):
  488. return_data = sqlcipher.SQLCipherExtPillar()
  489. return_data.process_fields(["a", "b", "c", "d"], 2)
  490. return_data.with_lists = []
  491. return_data.enter_root(None)
  492. return_data.process_results([[1, 2, 3, 4], [5, 6, 7, 8]])
  493. self.assertEqual(
  494. {1: {2: {"c": 3, "d": 4}}, 5: {6: {"c": 7, "d": 8}}}, return_data.result
  495. )
  496. def test_124_process_results_depth_3(self):
  497. return_data = sqlcipher.SQLCipherExtPillar()
  498. return_data.process_fields(["a", "b", "c", "d"], 3)
  499. return_data.with_lists = []
  500. return_data.enter_root(None)
  501. return_data.process_results([[1, 2, 3, 4], [5, 6, 7, 8]])
  502. self.assertEqual({1: {2: {3: 4}}, 5: {6: {7: 8}}}, return_data.result)
  503. def test_125_process_results_depth_4(self):
  504. return_data = sqlcipher.SQLCipherExtPillar()
  505. return_data.process_fields(["a", "b", "c", "d"], 4)
  506. return_data.with_lists = []
  507. return_data.enter_root(None)
  508. return_data.process_results([[1, 2, 3, 4], [5, 6, 7, 8]])
  509. self.assertEqual({1: {2: {3: 4}}, 5: {6: {7: 8}}}, return_data.result)
  510. def test_131_process_results_overwrite_legacy_multiple(self):
  511. return_data = sqlcipher.SQLCipherExtPillar()
  512. return_data.process_fields(["a", "b"], 0)
  513. return_data.with_lists = []
  514. return_data.process_results([[1, 2], [3, 4], [1, 6]])
  515. self.assertEqual({1: 6, 3: 4}, return_data.result)
  516. def test_132_process_results_merge_depth_0(self):
  517. return_data = sqlcipher.SQLCipherExtPillar()
  518. return_data.process_fields(["a", "b", "c", "d"], 0)
  519. return_data.with_lists = []
  520. return_data.enter_root(None)
  521. return_data.process_results([[1, 2, 3, 4], [1, 6, 7, 8]])
  522. self.assertEqual({1: {2: {3: 4}, 6: {7: 8}}}, return_data.result)
  523. def test_133_process_results_overwrite_depth_0(self):
  524. return_data = sqlcipher.SQLCipherExtPillar()
  525. return_data.process_fields(["a", "b", "c", "d"], 0)
  526. return_data.with_lists = []
  527. return_data.enter_root(None)
  528. return_data.process_results([[1, 2, 3, 4], [1, 2, 3, 8]])
  529. self.assertEqual({1: {2: {3: 8}}}, return_data.result)
  530. def test_134_process_results_deepmerge_depth_0(self):
  531. return_data = sqlcipher.SQLCipherExtPillar()
  532. return_data.process_fields(["a", "b", "c", "d"], 0)
  533. return_data.with_lists = []
  534. return_data.enter_root(None)
  535. return_data.process_results([[1, 2, 3, 4], [1, 2, 7, 8]])
  536. self.assertEqual({1: {2: {3: 4, 7: 8}}}, return_data.result)
  537. def test_135_process_results_overwrite_depth_1(self):
  538. return_data = sqlcipher.SQLCipherExtPillar()
  539. return_data.process_fields(["a", "b", "c", "d"], 1)
  540. return_data.with_lists = []
  541. return_data.enter_root(None)
  542. return_data.process_results([[1, 2, 3, 4], [1, 6, 7, 8]])
  543. self.assertEqual({1: {"b": 6, "c": 7, "d": 8}}, return_data.result)
  544. def test_136_process_results_merge_depth_2(self):
  545. return_data = sqlcipher.SQLCipherExtPillar()
  546. return_data.process_fields(["a", "b", "c", "d"], 2)
  547. return_data.with_lists = []
  548. return_data.enter_root(None)
  549. return_data.process_results([[1, 2, 3, 4], [1, 6, 7, 8]])
  550. self.assertEqual(
  551. {1: {2: {"c": 3, "d": 4}, 6: {"c": 7, "d": 8}}}, return_data.result
  552. )
  553. def test_137_process_results_overwrite_depth_2(self):
  554. return_data = sqlcipher.SQLCipherExtPillar()
  555. return_data.process_fields(["a", "b", "c", "d"], 2)
  556. return_data.with_lists = []
  557. return_data.enter_root(None)
  558. return_data.process_results([[1, 2, 3, 4], [1, 2, 7, 8]])
  559. self.assertEqual({1: {2: {"c": 7, "d": 8}}}, return_data.result)
  560. def test_201_process_results_complexity_multiresults(self):
  561. return_data = sqlcipher.SQLCipherExtPillar()
  562. return_data.process_fields(["a", "b", "c", "d"], 2)
  563. return_data.with_lists = []
  564. return_data.enter_root(None)
  565. return_data.process_results([[1, 2, 3, 4]])
  566. return_data.process_results([[1, 2, 7, 8]])
  567. self.assertEqual({1: {2: {"c": 7, "d": 8}}}, return_data.result)
  568. def test_202_process_results_complexity_as_list(self):
  569. return_data = sqlcipher.SQLCipherExtPillar()
  570. return_data.process_fields(["a", "b", "c", "d"], 2)
  571. return_data.with_lists = []
  572. return_data.enter_root(None)
  573. return_data.as_list = True
  574. return_data.process_results([[1, 2, 3, 4]])
  575. return_data.process_results([[1, 2, 7, 8]])
  576. self.assertEqual({1: {2: {"c": [3, 7], "d": [4, 8]}}}, return_data.result)
  577. def test_203_process_results_complexity_as_list_deeper(self):
  578. return_data = sqlcipher.SQLCipherExtPillar()
  579. return_data.process_fields(["a", "b", "c", "d"], 0)
  580. return_data.with_lists = []
  581. return_data.enter_root(None)
  582. return_data.as_list = True
  583. return_data.process_results([[1, 2, 3, 4]])
  584. return_data.process_results([[1, 2, 3, 8]])
  585. self.assertEqual({1: {2: {3: [4, 8]}}}, return_data.result)
  586. def test_204_process_results_complexity_as_list_mismatch_depth(self):
  587. return_data = sqlcipher.SQLCipherExtPillar()
  588. return_data.as_list = True
  589. return_data.with_lists = []
  590. return_data.enter_root(None)
  591. return_data.process_fields(["a", "b", "c", "d"], 0)
  592. return_data.process_results([[1, 2, 3, 4]])
  593. return_data.process_results([[1, 2, 3, 5]])
  594. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  595. return_data.process_results([[1, 2, 3, 6, 7]])
  596. self.assertEqual({1: {2: {3: [4, 5, {6: 7}]}}}, return_data.result)
  597. def test_205_process_results_complexity_as_list_mismatch_depth_reversed(self):
  598. return_data = sqlcipher.SQLCipherExtPillar()
  599. return_data.as_list = True
  600. return_data.with_lists = []
  601. return_data.enter_root(None)
  602. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  603. return_data.process_results([[1, 2, 3, 6, 7]])
  604. return_data.process_results([[1, 2, 3, 8, 9]])
  605. return_data.process_fields(["a", "b", "c", "d"], 0)
  606. return_data.process_results([[1, 2, 3, 4]])
  607. return_data.process_results([[1, 2, 3, 5]])
  608. self.assertEqual({1: {2: {3: [{6: 7, 8: 9}, 4, 5]}}}, return_data.result)
  609. def test_206_process_results_complexity_as_list_mismatch_depth_weird_order(self):
  610. return_data = sqlcipher.SQLCipherExtPillar()
  611. return_data.as_list = True
  612. return_data.with_lists = []
  613. return_data.enter_root(None)
  614. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  615. return_data.process_results([[1, 2, 3, 6, 7]])
  616. return_data.process_fields(["a", "b", "c", "d"], 0)
  617. return_data.process_results([[1, 2, 3, 4]])
  618. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  619. return_data.process_results([[1, 2, 3, 8, 9]])
  620. return_data.process_fields(["a", "b", "c", "d"], 0)
  621. return_data.process_results([[1, 2, 3, 5]])
  622. self.assertEqual({1: {2: {3: [{6: 7}, 4, {8: 9}, 5]}}}, return_data.result)
  623. def test_207_process_results_complexity_collision_mismatch_depth(self):
  624. return_data = sqlcipher.SQLCipherExtPillar()
  625. return_data.as_list = False
  626. return_data.with_lists = []
  627. return_data.enter_root(None)
  628. return_data.process_fields(["a", "b", "c", "d"], 0)
  629. return_data.process_results([[1, 2, 3, 4]])
  630. return_data.process_results([[1, 2, 3, 5]])
  631. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  632. return_data.process_results([[1, 2, 3, 6, 7]])
  633. self.assertEqual({1: {2: {3: {6: 7}}}}, return_data.result)
  634. def test_208_process_results_complexity_collision_mismatch_depth_reversed(self):
  635. return_data = sqlcipher.SQLCipherExtPillar()
  636. return_data.as_list = False
  637. return_data.with_lists = []
  638. return_data.enter_root(None)
  639. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  640. return_data.process_results([[1, 2, 3, 6, 7]])
  641. return_data.process_results([[1, 2, 3, 8, 9]])
  642. return_data.process_fields(["a", "b", "c", "d"], 0)
  643. return_data.process_results([[1, 2, 3, 4]])
  644. return_data.process_results([[1, 2, 3, 5]])
  645. self.assertEqual({1: {2: {3: 5}}}, return_data.result)
  646. def test_209_process_results_complexity_collision_mismatch_depth_weird_order(self):
  647. return_data = sqlcipher.SQLCipherExtPillar()
  648. return_data.as_list = False
  649. return_data.with_lists = []
  650. return_data.enter_root(None)
  651. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  652. return_data.process_results([[1, 2, 3, 6, 7]])
  653. return_data.process_fields(["a", "b", "c", "d"], 0)
  654. return_data.process_results([[1, 2, 3, 4]])
  655. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  656. return_data.process_results([[1, 2, 3, 8, 9]])
  657. return_data.process_fields(["a", "b", "c", "d"], 0)
  658. return_data.process_results([[1, 2, 3, 5]])
  659. self.assertEqual({1: {2: {3: 5}}}, return_data.result)
  660. def test_20A_process_results_complexity_as_list_vary(self):
  661. return_data = sqlcipher.SQLCipherExtPillar()
  662. return_data.as_list = True
  663. return_data.with_lists = []
  664. return_data.enter_root(None)
  665. return_data.process_fields(["a", "b", "c", "d", "e"], 0)
  666. return_data.process_results([[1, 2, 3, 6, 7]])
  667. return_data.process_results([[1, 2, 3, 8, 9]])
  668. return_data.process_fields(["a", "b", "c", "d"], 0)
  669. return_data.process_results([[1, 2, 3, 4]])
  670. return_data.as_list = False
  671. return_data.process_results([[1, 2, 3, 5]])
  672. self.assertEqual({1: {2: {3: 5}}}, return_data.result)
  673. def test_207_process_results_complexity_roots_collision(self):
  674. return_data = sqlcipher.SQLCipherExtPillar()
  675. return_data.as_list = False
  676. return_data.with_lists = []
  677. return_data.enter_root(None)
  678. return_data.process_fields(["a", "b", "c", "d"], 0)
  679. return_data.process_results([[1, 2, 3, 4]])
  680. return_data.enter_root(1)
  681. return_data.process_results([[5, 6, 7, 8]])
  682. self.assertEqual({1: {5: {6: {7: 8}}}}, return_data.result)
  683. def test_301_process_results_with_lists(self):
  684. return_data = sqlcipher.SQLCipherExtPillar()
  685. return_data.as_list = False
  686. return_data.with_lists = [1, 3]
  687. return_data.enter_root(None)
  688. return_data.process_fields(["a", "b", "c", "d", "e", "v"], 0)
  689. return_data.process_results(
  690. [
  691. ["a", "b", "c", "d", "e", 1],
  692. ["a", "b", "c", "f", "g", 2],
  693. ["a", "z", "h", "y", "j", 3],
  694. ["a", "z", "h", "y", "k", 4],
  695. ]
  696. )
  697. self.assertEqual(
  698. sorted({"a": [{"c": [{"e": 1}, {"g": 2}]}, {"h": [{"j": 3, "k": 4}]}]}),
  699. sorted(return_data.result),
  700. )
  701. def test_302_process_results_with_lists_consecutive(self):
  702. return_data = sqlcipher.SQLCipherExtPillar()
  703. return_data.as_list = False
  704. return_data.with_lists = [1, 2, 3]
  705. return_data.enter_root(None)
  706. return_data.process_fields(["a", "b", "c", "d", "e", "v"], 0)
  707. return_data.process_results(
  708. [
  709. ["a", "b", "c", "d", "e", 1],
  710. ["a", "b", "c", "f", "g", 2],
  711. ["a", "z", "h", "y", "j", 3],
  712. ["a", "z", "h", "y", "k", 4],
  713. ]
  714. )
  715. self.assertEqual(
  716. sorted({"a": [[[{"e": 1}, {"g": 2}]], [[{"j": 3, "k": 4}]]]}),
  717. sorted(return_data.result),
  718. )