@@ -179,7 +179,7 @@ class CryptoContainerTest {
179179 private var mockConfigurationRepository: ConfigurationRepository = mock()
180180
181181 private lateinit var context: Context
182-
182+ private lateinit var cdoc2Settings : CDOC2Settings
183183 private lateinit var recipientRepository: RecipientRepository
184184
185185 private lateinit var testFile: File
@@ -246,6 +246,7 @@ class CryptoContainerTest {
246246 fun setup () {
247247 MockitoAnnotations .openMocks(this )
248248 context = InstrumentationRegistry .getInstrumentation().targetContext
249+ cdoc2Settings = CDOC2Settings (context, configurationRepository)
249250 preferences = PreferenceManager .getDefaultSharedPreferences(context)
250251 preferences.edit().clear().commit()
251252 resources = context.resources
@@ -311,7 +312,7 @@ class CryptoContainerTest {
311312
312313 val dataFiles = listOf (testFile)
313314
314- val cdoc2Settings = CDOC2Settings (context)
315+
315316 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
316317
317318 val result = cryptoContainer.file
@@ -332,7 +333,6 @@ class CryptoContainerTest {
332333
333334 val dataFiles = listOf (dataFile1, dataFile2, dataFile3)
334335
335- val cdoc2Settings = CDOC2Settings (context)
336336 val cryptoContainer = openOrCreate(context, dataFile1, dataFiles, cdoc2Settings)
337337
338338 val result = cryptoContainer.file
@@ -353,7 +353,6 @@ class CryptoContainerTest {
353353
354354 val dataFiles = listOf (containerCDOC1)
355355
356- val cdoc2Settings = CDOC2Settings (context)
357356 val cryptoContainer = openOrCreate(context, containerCDOC1, dataFiles, cdoc2Settings, true )
358357
359358 val result = cryptoContainer.file
@@ -376,7 +375,6 @@ class CryptoContainerTest {
376375
377376 val dataFiles = listOf (testFile)
378377
379- val cdoc2Settings = CDOC2Settings (context)
380378 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
381379
382380 val result = cryptoContainer.file
@@ -397,7 +395,6 @@ class CryptoContainerTest {
397395
398396 val dataFiles = listOf (containerCDOC1)
399397
400- val cdoc2Settings = CDOC2Settings (context)
401398 val cryptoContainer = openOrCreate(context, containerCDOC1, dataFiles, cdoc2Settings)
402399
403400 val result = cryptoContainer.file
@@ -418,7 +415,6 @@ class CryptoContainerTest {
418415
419416 val dataFiles = listOf (containerCDOC2)
420417
421- val cdoc2Settings = CDOC2Settings (context)
422418 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
423419
424420 val result = cryptoContainer.file
@@ -439,7 +435,6 @@ class CryptoContainerTest {
439435
440436 val dataFiles = listOf (containerRIACDOC1)
441437
442- val cdoc2Settings = CDOC2Settings (context)
443438 val cryptoContainer = openOrCreate(context, containerRIACDOC1, dataFiles, cdoc2Settings)
444439
445440 val result = cryptoContainer.file
@@ -460,7 +455,6 @@ class CryptoContainerTest {
460455
461456 val dataFiles = listOf (containerRIACDOC2)
462457
463- val cdoc2Settings = CDOC2Settings (context)
464458 val cryptoContainer = openOrCreate(context, containerRIACDOC2, dataFiles, cdoc2Settings)
465459
466460 val result = cryptoContainer.file
@@ -484,21 +478,18 @@ class CryptoContainerTest {
484478
485479 val dataFiles = listOf (containerCDOC2)
486480
487- val cdoc2Settings = CDOC2Settings (context)
488481 openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
489482 }
490483
491484 @Test(expected = DataFilesEmptyException ::class )
492485 fun cryptoContainer_openOrCreate_dataFilesNullExpectException () =
493486 runTest {
494- val cdoc2Settings = CDOC2Settings (context)
495487 openOrCreate(context, testFile, listOf (), cdoc2Settings)
496488 }
497489
498490 @Test(expected = DataFilesEmptyException ::class )
499491 fun cryptoContainer_openOrCreate_dataFilesEmptyExpectException () =
500492 runTest {
501- val cdoc2Settings = CDOC2Settings (context)
502493 openOrCreate(context, testFile, listOf (), cdoc2Settings)
503494 }
504495
@@ -513,7 +504,6 @@ class CryptoContainerTest {
513504 ).apply ()
514505
515506 val dataFiles = listOf (containerCDOC2)
516- val cdoc2Settings = CDOC2Settings (context)
517507 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
518508
519509 val token = mock(Token ::class .java)
@@ -541,7 +531,6 @@ class CryptoContainerTest {
541531 ).apply ()
542532
543533 val dataFiles = listOf (containerCDOC2)
544- val cdoc2Settings = CDOC2Settings (context)
545534 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
546535
547536 val token = mock(Token ::class .java)
@@ -569,7 +558,6 @@ class CryptoContainerTest {
569558 ).apply ()
570559
571560 val dataFiles = listOf (containerCDOC2)
572- val cdoc2Settings = CDOC2Settings (context)
573561 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
574562
575563 val token = mock(Token ::class .java)
@@ -600,7 +588,6 @@ class CryptoContainerTest {
600588 ).apply ()
601589
602590 val dataFiles = listOf (containerCDOC2)
603- val cdoc2Settings = CDOC2Settings (context)
604591 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
605592 val data = " +puuS4wUR3wz+5D3DknZmebWhrP0X7ngQlXiBuPBipow0mDXgixJ7OCwhxx/zkYg"
606593 val token = mock(Token ::class .java)
@@ -661,7 +648,6 @@ class CryptoContainerTest {
661648 ).apply ()
662649
663650 val dataFiles = listOf (containerCDOC2Network)
664- val cdoc2Settings = CDOC2Settings (context)
665651 val cryptoContainer = openOrCreate(context, containerCDOC2Network, dataFiles, cdoc2Settings)
666652 val data = " zumNg86dm4q97avNnIuTGSGvMyKTSPRi0QBG2HSri3HwTm9jVEJKWiGsCUZ1Nudz"
667653 val authData =
@@ -743,7 +729,6 @@ class CryptoContainerTest {
743729 ).apply ()
744730
745731 val dataFiles = listOf (containerCDOC2Network)
746- val cdoc2Settings = CDOC2Settings (context)
747732 val cryptoContainer = openOrCreate(context, containerCDOC2Network, dataFiles, cdoc2Settings)
748733 val data = " zumNg86dm4q97avNnIuTGSGvMyKTSPRi0QBG2HSri3HwTm9jVEJKWiGsCUZ1Nudz"
749734 val authData =
@@ -780,7 +765,6 @@ class CryptoContainerTest {
780765 ).apply ()
781766
782767 val dataFiles = listOf (containerCDOC2)
783- val cdoc2Settings = CDOC2Settings (context)
784768 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
785769 val token = mock(Token ::class .java)
786770
@@ -810,7 +794,6 @@ class CryptoContainerTest {
810794 ).apply ()
811795
812796 val dataFiles = listOf (containerRIACDOC1)
813- val cdoc2Settings = CDOC2Settings (context)
814797 val cryptoContainer = openOrCreate(context, containerRIACDOC1, dataFiles, cdoc2Settings)
815798 val data = " +puuS4wUR3wz+5D3DknZmebWhrP0X7ngQlXiBuPBipow0mDXgixJ7OCwhxx/zkYg"
816799 val token = mock(Token ::class .java)
@@ -839,7 +822,6 @@ class CryptoContainerTest {
839822 ).apply ()
840823
841824 val dataFiles = listOf (containerRIACDOC1)
842- val cdoc2Settings = CDOC2Settings (context)
843825 val cryptoContainer = openOrCreate(context, containerRIACDOC1, dataFiles, cdoc2Settings)
844826 val token = mock(Token ::class .java)
845827 decrypt(
@@ -871,7 +853,6 @@ class CryptoContainerTest {
871853 true ,
872854 ).apply ()
873855
874- val cdoc2Settings = CDOC2Settings (context)
875856 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
876857
877858 val testFiles = listOf (testFile)
@@ -902,7 +883,6 @@ class CryptoContainerTest {
902883 true ,
903884 ).apply ()
904885
905- val cdoc2Settings = CDOC2Settings (context)
906886 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
907887
908888 val testFiles: List <File > = listOf ()
@@ -942,7 +922,6 @@ class CryptoContainerTest {
942922 " https://cdoc2.id.ee:8443" ,
943923 ).apply ()
944924
945- val cdoc2Settings = CDOC2Settings (context)
946925 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
947926
948927 val testFiles = listOf (testFile)
@@ -969,7 +948,6 @@ class CryptoContainerTest {
969948 false ,
970949 ).apply ()
971950
972- val cdoc2Settings = CDOC2Settings (context)
973951 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
974952
975953 val testFiles = listOf (testFile)
@@ -994,7 +972,6 @@ class CryptoContainerTest {
994972 true ,
995973 ).apply ()
996974
997- val cdoc2Settings = CDOC2Settings (context)
998975 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
999976
1000977 val testFiles = listOf (testFile)
@@ -1012,7 +989,6 @@ class CryptoContainerTest {
1012989 true ,
1013990 ).apply ()
1014991
1015- val cdoc2Settings = CDOC2Settings (context)
1016992 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
1017993
1018994 val testFiles = listOf (testFile)
@@ -1030,8 +1006,6 @@ class CryptoContainerTest {
10301006 true ,
10311007 ).apply ()
10321008
1033- val cdoc2Settings = CDOC2Settings (context)
1034-
10351009 val testFiles = listOf (testFile)
10361010 val container = openOrCreate(context, testFile, testFiles, cdoc2Settings)
10371011 encrypt(context, container.file, testFiles, listOf (), cdoc2Settings, configurationRepository)
@@ -1047,8 +1021,6 @@ class CryptoContainerTest {
10471021 true ,
10481022 ).apply ()
10491023
1050- val cdoc2Settings = CDOC2Settings (context)
1051-
10521024 val testFiles = listOf (testFile)
10531025 val container = openOrCreate(context, testFile, testFiles, cdoc2Settings)
10541026 encrypt(context, container.file, testFiles, listOf (), cdoc2Settings, configurationRepository)
@@ -1064,8 +1036,6 @@ class CryptoContainerTest {
10641036 true ,
10651037 ).apply ()
10661038
1067- val cdoc2Settings = CDOC2Settings (context)
1068-
10691039 val testFiles = listOf (testFile)
10701040 val container = openOrCreate(context, testFile, testFiles, cdoc2Settings)
10711041
@@ -1097,8 +1067,6 @@ class CryptoContainerTest {
10971067 true ,
10981068 ).apply ()
10991069
1100- val cdoc2Settings = CDOC2Settings (context)
1101-
11021070 val dataFiles = listOf (containerCDOC2)
11031071 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
11041072 assertEquals(CONTAINER_MIME_TYPE , cryptoContainer.containerMimetype())
@@ -1114,8 +1082,6 @@ class CryptoContainerTest {
11141082 true ,
11151083 ).apply ()
11161084
1117- val cdoc2Settings = CDOC2Settings (context)
1118-
11191085 val dataFiles = listOf (containerCDOC2)
11201086 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
11211087 assertEquals(" example_cdoc2.cdoc2" , cryptoContainer.getName())
@@ -1131,8 +1097,6 @@ class CryptoContainerTest {
11311097 true ,
11321098 ).apply ()
11331099
1134- val cdoc2Settings = CDOC2Settings (context)
1135-
11361100 val dataFiles = listOf (containerCDOC2)
11371101 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
11381102 cryptoContainer.setName(" test_cdoc2.cdoc2" )
@@ -1149,8 +1113,6 @@ class CryptoContainerTest {
11491113 true ,
11501114 ).apply ()
11511115
1152- val cdoc2Settings = CDOC2Settings (context)
1153-
11541116 val dataFiles = listOf (containerCDOC2)
11551117 val cryptoContainer = openOrCreate(context, containerCDOC2, dataFiles, cdoc2Settings)
11561118 assertTrue(cryptoContainer.hasRecipients())
@@ -1166,8 +1128,6 @@ class CryptoContainerTest {
11661128 false ,
11671129 ).apply ()
11681130
1169- val cdoc2Settings = CDOC2Settings (context)
1170-
11711131 val dataFiles = listOf (testFile)
11721132 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
11731133 val tempResourcesDir = Files .createTempDirectory(" test_resources" ).toFile()
@@ -1190,8 +1150,6 @@ class CryptoContainerTest {
11901150 false ,
11911151 ).apply ()
11921152
1193- val cdoc2Settings = CDOC2Settings (context)
1194-
11951153 val dataFiles = listOf (testFile)
11961154 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
11971155 val tempResourcesDir = Files .createTempDirectory(" test_resources" ).toFile()
@@ -1211,7 +1169,6 @@ class CryptoContainerTest {
12111169 true ,
12121170 ).apply ()
12131171
1214- val cdoc2Settings = CDOC2Settings (context)
12151172 val dataFiles = listOf (testFile)
12161173 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
12171174 cryptoContainer.addDataFiles(listOf (dataFile1, dataFile2, dataFile3))
@@ -1228,7 +1185,6 @@ class CryptoContainerTest {
12281185 true ,
12291186 ).apply ()
12301187
1231- val cdoc2Settings = CDOC2Settings (context)
12321188 val dataFiles = listOf (testFile)
12331189 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
12341190 cryptoContainer.addRecipients(listOf (Addressee (Base64 .getDecoder().decode(authCert))))
@@ -1245,7 +1201,6 @@ class CryptoContainerTest {
12451201 true ,
12461202 ).apply ()
12471203
1248- val cdoc2Settings = CDOC2Settings (context)
12491204 val dataFiles = listOf (testFile)
12501205 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
12511206 cryptoContainer.addDataFiles(listOf (dataFile1, dataFile2, dataFile3))
@@ -1263,7 +1218,6 @@ class CryptoContainerTest {
12631218 true ,
12641219 ).apply ()
12651220
1266- val cdoc2Settings = CDOC2Settings (context)
12671221 val dataFiles = listOf (testFile)
12681222 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
12691223 cryptoContainer.removeDataFile(testFile)
@@ -1279,7 +1233,6 @@ class CryptoContainerTest {
12791233 true ,
12801234 ).apply ()
12811235
1282- val cdoc2Settings = CDOC2Settings (context)
12831236 val dataFiles = listOf (testFile)
12841237 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
12851238 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
@@ -1298,7 +1251,6 @@ class CryptoContainerTest {
12981251 true ,
12991252 ).apply ()
13001253
1301- val cdoc2Settings = CDOC2Settings (context)
13021254 val dataFiles = listOf (testFile)
13031255 val cryptoContainer = openOrCreate(context, testFile, dataFiles, cdoc2Settings)
13041256 val recipient = Addressee (Base64 .getDecoder().decode(authCert))
0 commit comments