You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WalkEncryptionTest.java 37KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. /*
  2. * Copyright (C) 2015, Andrei Pozolotin.
  3. * and other copyright owners as documented in the project's IP log.
  4. *
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Distribution License v1.0 which
  7. * accompanies this distribution, is reproduced below, and is
  8. * available at http://www.eclipse.org/org/documents/edl-v10.php
  9. *
  10. * All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials provided
  22. * with the distribution.
  23. *
  24. * - Neither the name of the Eclipse Foundation, Inc. nor the
  25. * names of its contributors may be used to endorse or promote
  26. * products derived from this software without specific prior
  27. * written permission.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  30. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  31. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  34. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  36. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  37. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  38. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  41. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42. */
  43. package org.eclipse.jgit.transport;
  44. import static java.nio.charset.StandardCharsets.UTF_8;
  45. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListPBE;
  46. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListTrans;
  47. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.folderDelete;
  48. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.permitLongTests;
  49. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.policySetup;
  50. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.product;
  51. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.proxySetup;
  52. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.publicAddress;
  53. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.reportPolicy;
  54. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.securityProviderName;
  55. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.textWrite;
  56. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.transferStream;
  57. import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.verifyFileContent;
  58. import static org.junit.Assert.assertEquals;
  59. import static org.junit.Assert.assertFalse;
  60. import static org.junit.Assert.assertNotNull;
  61. import static org.junit.Assert.assertTrue;
  62. import static org.junit.Assume.assumeTrue;
  63. import java.io.BufferedReader;
  64. import java.io.ByteArrayInputStream;
  65. import java.io.ByteArrayOutputStream;
  66. import java.io.File;
  67. import java.io.FileInputStream;
  68. import java.io.IOException;
  69. import java.io.InputStream;
  70. import java.io.InputStreamReader;
  71. import java.io.OutputStream;
  72. import java.io.PrintWriter;
  73. import java.net.SocketTimeoutException;
  74. import java.net.URL;
  75. import java.net.URLConnection;
  76. import java.net.UnknownHostException;
  77. import java.nio.file.Files;
  78. import java.security.GeneralSecurityException;
  79. import java.security.Provider;
  80. import java.security.Security;
  81. import java.util.ArrayList;
  82. import java.util.Collection;
  83. import java.util.List;
  84. import java.util.Locale;
  85. import java.util.Properties;
  86. import java.util.Set;
  87. import java.util.TreeSet;
  88. import java.util.UUID;
  89. import javax.crypto.SecretKeyFactory;
  90. import org.eclipse.jgit.api.Git;
  91. import org.eclipse.jgit.lib.StoredConfig;
  92. import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
  93. import org.eclipse.jgit.util.FileUtils;
  94. import org.junit.After;
  95. import org.junit.AfterClass;
  96. import org.junit.Before;
  97. import org.junit.BeforeClass;
  98. import org.junit.FixMethodOrder;
  99. import org.junit.Test;
  100. import org.junit.runner.RunWith;
  101. import org.junit.runners.MethodSorters;
  102. import org.junit.runners.Parameterized;
  103. import org.junit.runners.Parameterized.Parameters;
  104. import org.junit.runners.Suite;
  105. import org.slf4j.Logger;
  106. import org.slf4j.LoggerFactory;
  107. /**
  108. * Amazon S3 encryption pipeline test.
  109. *
  110. * See {@link AmazonS3} {@link WalkEncryption}
  111. *
  112. * Note: CI server must provide amazon credentials (access key, secret key,
  113. * bucket name) via one of methods available in {@link Names}.
  114. *
  115. * Note: long running tests are activated by Maven profile "test.long". There is
  116. * also a separate Eclipse m2e launcher for that. See 'pom.xml' and
  117. * 'WalkEncryptionTest.launch'.
  118. */
  119. @RunWith(Suite.class)
  120. @Suite.SuiteClasses({ //
  121. WalkEncryptionTest.Required.class, //
  122. WalkEncryptionTest.MinimalSet.class, //
  123. WalkEncryptionTest.TestablePBE.class, //
  124. WalkEncryptionTest.TestableTransformation.class, //
  125. })
  126. public class WalkEncryptionTest {
  127. /**
  128. * Logger setup: ${project_loc}/tst-rsrc/log4j.properties
  129. */
  130. static final Logger logger = LoggerFactory.getLogger(WalkEncryptionTest.class);
  131. /**
  132. * Property names used in test session.
  133. */
  134. interface Names {
  135. // Names of discovered test properties.
  136. String TEST_BUCKET = "test.bucket";
  137. // Names of test environment variables for CI.
  138. String ENV_ACCESS_KEY = "JGIT_S3_ACCESS_KEY";
  139. String ENV_SECRET_KEY = "JGIT_S3_SECRET_KEY";
  140. String ENV_BUCKET_NAME = "JGIT_S3_BUCKET_NAME";
  141. // Name of test environment variable file path for CI.
  142. String ENV_CONFIG_FILE = "JGIT_S3_CONFIG_FILE";
  143. // Names of test system properties for CI.
  144. String SYS_ACCESS_KEY = "jgit.s3.access.key";
  145. String SYS_SECRET_KEY = "jgit.s3.secret.key";
  146. String SYS_BUCKET_NAME = "jgit.s3.bucket.name";
  147. // Name of test system property file path for CI.
  148. String SYS_CONFIG_FILE = "jgit.s3.config.file";
  149. // Hard coded name of test properties file for CI.
  150. // File format follows AmazonS3.Keys:
  151. // #
  152. // # Required entries:
  153. // #
  154. // accesskey = your-amazon-access-key # default AmazonS3.Keys
  155. // secretkey = your-amazon-secret-key # default AmazonS3.Keys
  156. // test.bucket = your-bucket-for-testing # custom name, for this test
  157. String CONFIG_FILE = "jgit-s3-config.properties";
  158. // Test properties file in [user home] of CI.
  159. String HOME_CONFIG_FILE = System.getProperty("user.home")
  160. + File.separator + CONFIG_FILE;
  161. // Test properties file in [project work directory] of CI.
  162. String WORK_CONFIG_FILE = System.getProperty("user.dir")
  163. + File.separator + CONFIG_FILE;
  164. // Test properties file in [project test source directory] of CI.
  165. String TEST_CONFIG_FILE = System.getProperty("user.dir")
  166. + File.separator + "tst-rsrc" + File.separator + CONFIG_FILE;
  167. }
  168. /**
  169. * Find test properties from various sources in order of priority.
  170. */
  171. static class Props implements WalkEncryptionTest.Names, AmazonS3.Keys {
  172. static boolean haveEnvVar(String name) {
  173. return System.getenv(name) != null;
  174. }
  175. static boolean haveEnvVarFile(String name) {
  176. return haveEnvVar(name) && new File(name).exists();
  177. }
  178. static boolean haveSysProp(String name) {
  179. return System.getProperty(name) != null;
  180. }
  181. static boolean haveSysPropFile(String name) {
  182. return haveSysProp(name) && new File(name).exists();
  183. }
  184. static void loadEnvVar(String source, String target, Properties props) {
  185. props.put(target, System.getenv(source));
  186. }
  187. static void loadSysProp(String source, String target,
  188. Properties props) {
  189. props.put(target, System.getProperty(source));
  190. }
  191. static boolean haveProp(String name, Properties props) {
  192. return props.containsKey(name);
  193. }
  194. static boolean checkTestProps(Properties props) {
  195. return haveProp(ACCESS_KEY, props) && haveProp(SECRET_KEY, props)
  196. && haveProp(TEST_BUCKET, props);
  197. }
  198. static Properties fromEnvVars() {
  199. if (haveEnvVar(ENV_ACCESS_KEY) && haveEnvVar(ENV_SECRET_KEY)
  200. && haveEnvVar(ENV_BUCKET_NAME)) {
  201. Properties props = new Properties();
  202. loadEnvVar(ENV_ACCESS_KEY, ACCESS_KEY, props);
  203. loadEnvVar(ENV_SECRET_KEY, SECRET_KEY, props);
  204. loadEnvVar(ENV_BUCKET_NAME, TEST_BUCKET, props);
  205. return props;
  206. }
  207. return null;
  208. }
  209. static Properties fromEnvFile() throws Exception {
  210. if (haveEnvVarFile(ENV_CONFIG_FILE)) {
  211. Properties props = new Properties();
  212. props.load(new FileInputStream(ENV_CONFIG_FILE));
  213. if (checkTestProps(props)) {
  214. return props;
  215. }
  216. throw new Error("Environment config file is incomplete.");
  217. }
  218. return null;
  219. }
  220. static Properties fromSysProps() {
  221. if (haveSysProp(SYS_ACCESS_KEY) && haveSysProp(SYS_SECRET_KEY)
  222. && haveSysProp(SYS_BUCKET_NAME)) {
  223. Properties props = new Properties();
  224. loadSysProp(SYS_ACCESS_KEY, ACCESS_KEY, props);
  225. loadSysProp(SYS_SECRET_KEY, SECRET_KEY, props);
  226. loadSysProp(SYS_BUCKET_NAME, TEST_BUCKET, props);
  227. return props;
  228. }
  229. return null;
  230. }
  231. static Properties fromSysFile() throws Exception {
  232. if (haveSysPropFile(SYS_CONFIG_FILE)) {
  233. Properties props = new Properties();
  234. props.load(new FileInputStream(SYS_CONFIG_FILE));
  235. if (checkTestProps(props)) {
  236. return props;
  237. }
  238. throw new Error("System props config file is incomplete.");
  239. }
  240. return null;
  241. }
  242. static Properties fromConfigFile(String path) throws Exception {
  243. File file = new File(path);
  244. if (file.exists()) {
  245. Properties props = new Properties();
  246. props.load(new FileInputStream(file));
  247. if (checkTestProps(props)) {
  248. return props;
  249. }
  250. throw new Error("Props config file is incomplete: " + path);
  251. }
  252. return null;
  253. }
  254. /**
  255. * Find test properties from various sources in order of priority.
  256. *
  257. * @return result
  258. * @throws Exception
  259. */
  260. static Properties discover() throws Exception {
  261. Properties props;
  262. if ((props = fromEnvVars()) != null) {
  263. logger.debug(
  264. "Using test properties from environment variables.");
  265. return props;
  266. }
  267. if ((props = fromEnvFile()) != null) {
  268. logger.debug(
  269. "Using test properties from environment variable config file.");
  270. return props;
  271. }
  272. if ((props = fromSysProps()) != null) {
  273. logger.debug("Using test properties from system properties.");
  274. return props;
  275. }
  276. if ((props = fromSysFile()) != null) {
  277. logger.debug(
  278. "Using test properties from system property config file.");
  279. return props;
  280. }
  281. if ((props = fromConfigFile(HOME_CONFIG_FILE)) != null) {
  282. logger.debug(
  283. "Using test properties from hard coded ${user.home} file.");
  284. return props;
  285. }
  286. if ((props = fromConfigFile(WORK_CONFIG_FILE)) != null) {
  287. logger.debug(
  288. "Using test properties from hard coded ${user.dir} file.");
  289. return props;
  290. }
  291. if ((props = fromConfigFile(TEST_CONFIG_FILE)) != null) {
  292. logger.debug(
  293. "Using test properties from hard coded ${project.source} file.");
  294. return props;
  295. }
  296. throw new Error("Can not load test properties form any source.");
  297. }
  298. }
  299. /**
  300. * Collection of test utility methods.
  301. */
  302. static class Util {
  303. /**
  304. * Read UTF-8 encoded text file into string.
  305. *
  306. * @param file
  307. * @return result
  308. * @throws Exception
  309. */
  310. static String textRead(File file) throws Exception {
  311. return new String(Files.readAllBytes(file.toPath()), UTF_8);
  312. }
  313. /**
  314. * Write string into UTF-8 encoded file.
  315. *
  316. * @param file
  317. * @param text
  318. * @throws Exception
  319. */
  320. static void textWrite(File file, String text) throws Exception {
  321. Files.write(file.toPath(), text.getBytes(UTF_8));
  322. }
  323. static void verifyFileContent(File fileOne, File fileTwo)
  324. throws Exception {
  325. assertTrue(fileOne.length() > 0);
  326. assertTrue(fileTwo.length() > 0);
  327. String textOne = textRead(fileOne);
  328. String textTwo = textRead(fileTwo);
  329. assertEquals(textOne, textTwo);
  330. }
  331. /**
  332. * Create local folder.
  333. *
  334. * @param folder
  335. * @throws Exception
  336. */
  337. static void folderCreate(String folder) throws Exception {
  338. File path = new File(folder);
  339. assertTrue(path.mkdirs());
  340. }
  341. /**
  342. * Delete local folder.
  343. *
  344. * @param folder
  345. * @throws Exception
  346. */
  347. static void folderDelete(String folder) throws Exception {
  348. File path = new File(folder);
  349. FileUtils.delete(path,
  350. FileUtils.RECURSIVE | FileUtils.SKIP_MISSING);
  351. }
  352. /**
  353. * Discover public address of CI server.
  354. *
  355. * @return result
  356. * @throws Exception
  357. */
  358. static String publicAddress() throws Exception {
  359. try {
  360. String service = "http://checkip.amazonaws.com";
  361. URL url = new URL(service);
  362. URLConnection c = url.openConnection();
  363. c.setConnectTimeout(500);
  364. c.setReadTimeout(500);
  365. try (BufferedReader reader = new BufferedReader(
  366. new InputStreamReader(c.getInputStream(), UTF_8))) {
  367. return reader.readLine();
  368. }
  369. } catch (UnknownHostException | SocketTimeoutException e) {
  370. return "Can't reach http://checkip.amazonaws.com to"
  371. + " determine public address";
  372. }
  373. }
  374. /**
  375. * Discover Password-Based Encryption (PBE) engines providing both
  376. * [SecretKeyFactory] and [AlgorithmParameters].
  377. *
  378. * @return result
  379. */
  380. // https://www.bouncycastle.org/specifications.html
  381. // https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html
  382. static List<String> cryptoCipherListPBE() {
  383. return cryptoCipherList(WalkEncryption.Vals.REGEX_PBE);
  384. }
  385. // TODO returns inconsistent list.
  386. static List<String> cryptoCipherListTrans() {
  387. return cryptoCipherList(WalkEncryption.Vals.REGEX_TRANS);
  388. }
  389. static String securityProviderName(String algorithm) throws Exception {
  390. return SecretKeyFactory.getInstance(algorithm).getProvider()
  391. .getName();
  392. }
  393. static List<String> cryptoCipherList(String regex) {
  394. Set<String> source = Security.getAlgorithms("Cipher");
  395. Set<String> target = new TreeSet<>();
  396. for (String algo : source) {
  397. algo = algo.toUpperCase(Locale.ROOT);
  398. if (algo.matches(regex)) {
  399. target.add(algo);
  400. }
  401. }
  402. return new ArrayList<>(target);
  403. }
  404. /**
  405. * Stream copy.
  406. *
  407. * @param from
  408. * @param into
  409. * @return count
  410. * @throws IOException
  411. */
  412. static long transferStream(InputStream from, OutputStream into)
  413. throws IOException {
  414. byte[] array = new byte[1 * 1024];
  415. long total = 0;
  416. while (true) {
  417. int count = from.read(array);
  418. if (count == -1) {
  419. break;
  420. }
  421. into.write(array, 0, count);
  422. total += count;
  423. }
  424. return total;
  425. }
  426. /**
  427. * Setup proxy during CI build.
  428. *
  429. * @throws Exception
  430. */
  431. // https://wiki.eclipse.org/Hudson#Accessing_the_Internet_using_Proxy
  432. // http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html
  433. static void proxySetup() throws Exception {
  434. String keyNoProxy = "no_proxy";
  435. String keyHttpProxy = "http_proxy";
  436. String keyHttpsProxy = "https_proxy";
  437. String no_proxy = System.getProperty(keyNoProxy,
  438. System.getenv(keyNoProxy));
  439. if (no_proxy != null) {
  440. System.setProperty("http.nonProxyHosts", no_proxy);
  441. logger.info("Proxy NOT: " + no_proxy);
  442. }
  443. String http_proxy = System.getProperty(keyHttpProxy,
  444. System.getenv(keyHttpProxy));
  445. if (http_proxy != null) {
  446. URL url = new URL(http_proxy);
  447. System.setProperty("http.proxyHost", url.getHost());
  448. System.setProperty("http.proxyPort", "" + url.getPort());
  449. logger.info("Proxy HTTP: " + http_proxy);
  450. }
  451. String https_proxy = System.getProperty(keyHttpsProxy,
  452. System.getenv(keyHttpsProxy));
  453. if (https_proxy != null) {
  454. URL url = new URL(https_proxy);
  455. System.setProperty("https.proxyHost", url.getHost());
  456. System.setProperty("https.proxyPort", "" + url.getPort());
  457. logger.info("Proxy HTTPS: " + https_proxy);
  458. }
  459. if (no_proxy == null && http_proxy == null && https_proxy == null) {
  460. logger.info("Proxy not used.");
  461. }
  462. }
  463. /**
  464. * Permit long tests on CI or with manual activation.
  465. *
  466. * @return result
  467. */
  468. static boolean permitLongTests() {
  469. return isBuildCI() || isProfileActive();
  470. }
  471. /**
  472. * Using Maven profile activation, see pom.xml
  473. *
  474. * @return result
  475. */
  476. static boolean isProfileActive() {
  477. return Boolean.parseBoolean(System.getProperty("jgit.test.long"));
  478. }
  479. /**
  480. * Detect if build is running on CI.
  481. *
  482. * @return result
  483. */
  484. static boolean isBuildCI() {
  485. return System.getenv("HUDSON_HOME") != null;
  486. }
  487. /**
  488. * Setup JCE security policy restrictions. Can remove restrictions when
  489. * restrictions are present, but can not impose them when restrictions
  490. * are missing.
  491. *
  492. * @param restrictedOn
  493. */
  494. // http://www.docjar.com/html/api/javax/crypto/JceSecurity.java.html
  495. static void policySetup(boolean restrictedOn) {
  496. try {
  497. java.lang.reflect.Field isRestricted = Class
  498. .forName("javax.crypto.JceSecurity")
  499. .getDeclaredField("isRestricted");
  500. isRestricted.setAccessible(true);
  501. isRestricted.set(null, Boolean.valueOf(restrictedOn));
  502. } catch (Throwable e) {
  503. logger.info(
  504. "Could not setup JCE security policy restrictions.");
  505. }
  506. }
  507. static void reportPolicy() {
  508. try {
  509. java.lang.reflect.Field isRestricted = Class
  510. .forName("javax.crypto.JceSecurity")
  511. .getDeclaredField("isRestricted");
  512. isRestricted.setAccessible(true);
  513. logger.info("JCE security policy restricted="
  514. + isRestricted.get(null));
  515. } catch (Throwable e) {
  516. logger.info(
  517. "Could not report JCE security policy restrictions.");
  518. }
  519. }
  520. static List<Object[]> product(List<String> one, List<String> two) {
  521. List<Object[]> result = new ArrayList<>();
  522. for (String s1 : one) {
  523. for (String s2 : two) {
  524. result.add(new Object[] { s1, s2 });
  525. }
  526. }
  527. return result;
  528. }
  529. }
  530. /**
  531. * Common base for encryption tests.
  532. */
  533. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  534. public abstract static class Base extends SampleDataRepositoryTestCase {
  535. /**
  536. * S3 URI user used by JGIT to discover connection configuration file.
  537. */
  538. static final String JGIT_USER = "tester-" + System.currentTimeMillis();
  539. /**
  540. * S3 content encoding password used for this test session.
  541. */
  542. static final String JGIT_PASS = "secret-" + System.currentTimeMillis();
  543. /**
  544. * S3 repository configuration file expected by {@link AmazonS3}.
  545. */
  546. static final String JGIT_CONF_FILE = System.getProperty("user.home")
  547. + "/" + JGIT_USER;
  548. /**
  549. * Name representing remote or local JGIT repository.
  550. */
  551. static final String JGIT_REPO_DIR = JGIT_USER + ".jgit";
  552. /**
  553. * Local JGIT repository for this test session.
  554. */
  555. static final String JGIT_LOCAL_DIR = System.getProperty("user.dir")
  556. + "/target/" + JGIT_REPO_DIR;
  557. /**
  558. * Remote JGIT repository for this test session.
  559. */
  560. static final String JGIT_REMOTE_DIR = JGIT_REPO_DIR;
  561. /**
  562. * Generate JGIT S3 connection configuration file.
  563. *
  564. * @param algorithm
  565. * @throws Exception
  566. */
  567. static void configCreate(String algorithm) throws Exception {
  568. Properties props = Props.discover();
  569. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  570. props.put(AmazonS3.Keys.CRYPTO_ALG, algorithm);
  571. try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE,
  572. UTF_8.name())) {
  573. props.store(writer, "JGIT S3 connection configuration file.");
  574. }
  575. }
  576. /**
  577. * Generate JGIT S3 connection configuration file.
  578. *
  579. * @param source
  580. * @throws Exception
  581. */
  582. static void configCreate(Properties source) throws Exception {
  583. Properties target = Props.discover();
  584. target.putAll(source);
  585. try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE,
  586. UTF_8.name())) {
  587. target.store(writer, "JGIT S3 connection configuration file.");
  588. }
  589. }
  590. /**
  591. * Remove JGIT connection configuration file.
  592. *
  593. * @throws Exception
  594. */
  595. static void configDelete() throws Exception {
  596. File path = new File(JGIT_CONF_FILE);
  597. FileUtils.delete(path, FileUtils.SKIP_MISSING);
  598. }
  599. /**
  600. * Generate remote URI for the test session.
  601. *
  602. * @return result
  603. * @throws Exception
  604. */
  605. static String amazonURI() throws Exception {
  606. Properties props = Props.discover();
  607. String bucket = props.getProperty(Names.TEST_BUCKET);
  608. assertNotNull(bucket);
  609. return TransportAmazonS3.S3_SCHEME + "://" + JGIT_USER + "@"
  610. + bucket + "/" + JGIT_REPO_DIR;
  611. }
  612. /**
  613. * Create S3 repository folder.
  614. *
  615. * @throws Exception
  616. */
  617. static void remoteCreate() throws Exception {
  618. Properties props = Props.discover();
  619. props.remove(AmazonS3.Keys.PASSWORD); // Disable encryption.
  620. String bucket = props.getProperty(Names.TEST_BUCKET);
  621. AmazonS3 s3 = new AmazonS3(props);
  622. String path = JGIT_REMOTE_DIR + "/";
  623. s3.put(bucket, path, new byte[0]);
  624. logger.debug("remote create: " + JGIT_REMOTE_DIR);
  625. }
  626. /**
  627. * Delete S3 repository folder.
  628. *
  629. * @throws Exception
  630. */
  631. static void remoteDelete() throws Exception {
  632. Properties props = Props.discover();
  633. props.remove(AmazonS3.Keys.PASSWORD); // Disable encryption.
  634. String bucket = props.getProperty(Names.TEST_BUCKET);
  635. AmazonS3 s3 = new AmazonS3(props);
  636. List<String> list = s3.list(bucket, JGIT_REMOTE_DIR);
  637. for (String path : list) {
  638. path = JGIT_REMOTE_DIR + "/" + path;
  639. s3.delete(bucket, path);
  640. }
  641. logger.debug("remote delete: " + JGIT_REMOTE_DIR);
  642. }
  643. /**
  644. * Verify if we can create/delete remote file.
  645. *
  646. * @throws Exception
  647. */
  648. static void remoteVerify() throws Exception {
  649. Properties props = Props.discover();
  650. String bucket = props.getProperty(Names.TEST_BUCKET);
  651. AmazonS3 s3 = new AmazonS3(props);
  652. String file = JGIT_USER + "-" + UUID.randomUUID().toString();
  653. String path = JGIT_REMOTE_DIR + "/" + file;
  654. s3.put(bucket, path, file.getBytes(UTF_8));
  655. s3.delete(bucket, path);
  656. }
  657. /**
  658. * Verify if any security provider published the algorithm.
  659. *
  660. * @param algorithm
  661. * @return result
  662. */
  663. static boolean isAlgorithmPresent(String algorithm) {
  664. Set<String> cipherSet = Security.getAlgorithms("Cipher");
  665. for (String source : cipherSet) {
  666. // Standard names are not case-sensitive.
  667. // http://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html
  668. String target = algorithm.toUpperCase(Locale.ROOT);
  669. if (source.equalsIgnoreCase(target)) {
  670. return true;
  671. }
  672. }
  673. return false;
  674. }
  675. static boolean isAlgorithmPresent(Properties props) {
  676. String profile = props.getProperty(AmazonS3.Keys.CRYPTO_ALG);
  677. String version = props.getProperty(AmazonS3.Keys.CRYPTO_VER,
  678. WalkEncryption.Vals.DEFAULT_VERS);
  679. String cryptoAlgo;
  680. String keyAlgo;
  681. switch (version) {
  682. case WalkEncryption.Vals.DEFAULT_VERS:
  683. case WalkEncryption.JGitV1.VERSION:
  684. cryptoAlgo = profile;
  685. keyAlgo = profile;
  686. break;
  687. case WalkEncryption.JGitV2.VERSION:
  688. cryptoAlgo = props
  689. .getProperty(profile + WalkEncryption.Keys.X_ALGO);
  690. keyAlgo = props
  691. .getProperty(profile + WalkEncryption.Keys.X_KEY_ALGO);
  692. break;
  693. default:
  694. return false;
  695. }
  696. try {
  697. InsecureCipherFactory.create(cryptoAlgo);
  698. SecretKeyFactory.getInstance(keyAlgo);
  699. return true;
  700. } catch (Throwable e) {
  701. return false;
  702. }
  703. }
  704. /**
  705. * Verify if JRE security policy allows the algorithm.
  706. *
  707. * @param algorithm
  708. * @return result
  709. */
  710. static boolean isAlgorithmAllowed(String algorithm) {
  711. try {
  712. WalkEncryption crypto = new WalkEncryption.JetS3tV2(
  713. algorithm, JGIT_PASS);
  714. verifyCrypto(crypto);
  715. return true;
  716. } catch (IOException e) {
  717. return false; // Encryption failure.
  718. } catch (GeneralSecurityException e) {
  719. throw new Error(e); // Construction failure.
  720. }
  721. }
  722. static boolean isAlgorithmAllowed(Properties props) {
  723. try {
  724. WalkEncryption.instance(props);
  725. return true;
  726. } catch (GeneralSecurityException e) {
  727. return false;
  728. }
  729. }
  730. /**
  731. * Verify round trip encryption.
  732. *
  733. * @param crypto
  734. * @throws IOException
  735. */
  736. static void verifyCrypto(WalkEncryption crypto) throws IOException {
  737. String charset = "UTF-8";
  738. String sourceText = "secret-message Свобода 老子";
  739. String targetText;
  740. byte[] cipherText;
  741. {
  742. byte[] origin = sourceText.getBytes(charset);
  743. ByteArrayOutputStream target = new ByteArrayOutputStream();
  744. try (OutputStream source = crypto.encrypt(target)) {
  745. source.write(origin);
  746. source.flush();
  747. }
  748. cipherText = target.toByteArray();
  749. }
  750. {
  751. InputStream source = new ByteArrayInputStream(cipherText);
  752. InputStream target = crypto.decrypt(source);
  753. ByteArrayOutputStream result = new ByteArrayOutputStream();
  754. transferStream(target, result);
  755. targetText = result.toString(charset);
  756. }
  757. assertEquals(sourceText, targetText);
  758. }
  759. /**
  760. * Algorithm is testable when it is present and allowed by policy.
  761. *
  762. * @param algorithm
  763. * @return result
  764. */
  765. static boolean isAlgorithmTestable(String algorithm) {
  766. return isAlgorithmPresent(algorithm)
  767. && isAlgorithmAllowed(algorithm);
  768. }
  769. static boolean isAlgorithmTestable(Properties props) {
  770. return isAlgorithmPresent(props) && isAlgorithmAllowed(props);
  771. }
  772. /**
  773. * Log algorithm, provider, testability.
  774. *
  775. * @param algorithm
  776. * @throws Exception
  777. */
  778. static void reportAlgorithmStatus(String algorithm) throws Exception {
  779. final boolean present = isAlgorithmPresent(algorithm);
  780. final boolean allowed = present && isAlgorithmAllowed(algorithm);
  781. final String provider = present ? securityProviderName(algorithm)
  782. : "N/A";
  783. String status = "Algorithm: " + algorithm + " @ " + provider + "; "
  784. + "present/allowed : " + present + "/" + allowed;
  785. if (allowed) {
  786. logger.info("Testing " + status);
  787. } else {
  788. logger.warn("Missing " + status);
  789. }
  790. }
  791. static void reportAlgorithmStatus(Properties props) throws Exception {
  792. final boolean present = isAlgorithmPresent(props);
  793. final boolean allowed = present && isAlgorithmAllowed(props);
  794. String profile = props.getProperty(AmazonS3.Keys.CRYPTO_ALG);
  795. String version = props.getProperty(AmazonS3.Keys.CRYPTO_VER);
  796. StringBuilder status = new StringBuilder();
  797. status.append(" Version: " + version);
  798. status.append(" Profile: " + profile);
  799. status.append(" Present: " + present);
  800. status.append(" Allowed: " + allowed);
  801. if (allowed) {
  802. logger.info("Testing " + status);
  803. } else {
  804. logger.warn("Missing " + status);
  805. }
  806. }
  807. /**
  808. * Verify if we can perform remote tests.
  809. *
  810. * @return result
  811. */
  812. static boolean isTestConfigPresent() {
  813. try {
  814. Props.discover();
  815. return true;
  816. } catch (Throwable e) {
  817. return false;
  818. }
  819. }
  820. static void reportTestConfigPresent() {
  821. if (isTestConfigPresent()) {
  822. logger.info("Amazon S3 test configuration is present.");
  823. } else {
  824. logger.error(
  825. "Amazon S3 test configuration is missing, tests will not run.");
  826. }
  827. }
  828. /**
  829. * Log public address of CI.
  830. *
  831. * @throws Exception
  832. */
  833. static void reportPublicAddress() throws Exception {
  834. logger.info("Public address: " + publicAddress());
  835. }
  836. /**
  837. * BouncyCastle provider class.
  838. *
  839. * Needs extra dependency, see pom.xml
  840. */
  841. // http://search.maven.org/#artifactdetails%7Corg.bouncycastle%7Cbcprov-jdk15on%7C1.52%7Cjar
  842. static final String PROVIDER_BC = "org.bouncycastle.jce.provider.BouncyCastleProvider";
  843. /**
  844. * Load BouncyCastle provider if present.
  845. */
  846. static void loadBouncyCastle() {
  847. try {
  848. Class<?> provider = Class.forName(PROVIDER_BC);
  849. Provider instance = (Provider) provider
  850. .getConstructor(new Class[] {})
  851. .newInstance(new Object[] {});
  852. Security.addProvider(instance);
  853. logger.info("Loaded " + PROVIDER_BC);
  854. } catch (Throwable e) {
  855. logger.warn("Failed to load " + PROVIDER_BC);
  856. }
  857. }
  858. static void reportLongTests() {
  859. if (permitLongTests()) {
  860. logger.info("Long running tests are enabled.");
  861. } else {
  862. logger.warn("Long running tests are disabled.");
  863. }
  864. }
  865. /**
  866. * Non-PBE algorithm, for error check.
  867. */
  868. static final String ALGO_ERROR = "PBKDF2WithHmacSHA1";
  869. /**
  870. * Default JetS3t algorithm present in most JRE.
  871. */
  872. static final String ALGO_JETS3T = "PBEWithMD5AndDES";
  873. /**
  874. * Minimal strength AES based algorithm present in most JRE.
  875. */
  876. static final String ALGO_MINIMAL_AES = "PBEWithHmacSHA1AndAES_128";
  877. /**
  878. * Selected non-AES algorithm present in BouncyCastle provider.
  879. */
  880. static final String ALGO_BOUNCY_CASTLE_CBC = "PBEWithSHAAndTwofish-CBC";
  881. //////////////////////////////////////////////////
  882. @BeforeClass
  883. public static void initialize() throws Exception {
  884. Transport.register(TransportAmazonS3.PROTO_S3);
  885. proxySetup();
  886. reportPolicy();
  887. reportLongTests();
  888. reportPublicAddress();
  889. reportTestConfigPresent();
  890. loadBouncyCastle();
  891. if (isTestConfigPresent()) {
  892. remoteCreate();
  893. }
  894. }
  895. @AfterClass
  896. public static void terminate() throws Exception {
  897. configDelete();
  898. folderDelete(JGIT_LOCAL_DIR);
  899. if (isTestConfigPresent()) {
  900. remoteDelete();
  901. }
  902. }
  903. @Before
  904. @Override
  905. public void setUp() throws Exception {
  906. super.setUp();
  907. }
  908. @After
  909. @Override
  910. public void tearDown() throws Exception {
  911. super.tearDown();
  912. }
  913. /**
  914. * Optional encrypted amazon remote JGIT life cycle test.
  915. *
  916. * @param props
  917. * @throws Exception
  918. */
  919. void cryptoTestIfCan(Properties props) throws Exception {
  920. reportAlgorithmStatus(props);
  921. assumeTrue(isTestConfigPresent());
  922. assumeTrue(isAlgorithmTestable(props));
  923. cryptoTest(props);
  924. }
  925. /**
  926. * Required encrypted amazon remote JGIT life cycle test.
  927. *
  928. * @param props
  929. * @throws Exception
  930. */
  931. void cryptoTest(Properties props) throws Exception {
  932. remoteDelete();
  933. configCreate(props);
  934. folderDelete(JGIT_LOCAL_DIR);
  935. String uri = amazonURI();
  936. // Local repositories.
  937. File dirOne = db.getWorkTree(); // Provided by setup.
  938. File dirTwo = new File(JGIT_LOCAL_DIR);
  939. // Local verification files.
  940. String nameStatic = "master.txt"; // Provided by setup.
  941. String nameDynamic = JGIT_USER + "-" + UUID.randomUUID().toString();
  942. String remote = "remote";
  943. RefSpec specs = new RefSpec("refs/heads/master:refs/heads/master");
  944. { // Push into remote from local one.
  945. StoredConfig config = db.getConfig();
  946. RemoteConfig remoteConfig = new RemoteConfig(config, remote);
  947. remoteConfig.addURI(new URIish(uri));
  948. remoteConfig.update(config);
  949. config.save();
  950. try (Git git = Git.open(dirOne)) {
  951. git.checkout().setName("master").call();
  952. git.push().setRemote(remote).setRefSpecs(specs).call();
  953. }
  954. File fileStatic = new File(dirOne, nameStatic);
  955. assertTrue("Provided by setup", fileStatic.exists());
  956. }
  957. { // Clone from remote into local two.
  958. File fileStatic = new File(dirTwo, nameStatic);
  959. assertFalse("Not Provided by setup", fileStatic.exists());
  960. try (Git git = Git.cloneRepository().setURI(uri)
  961. .setDirectory(dirTwo).call()) {
  962. assertTrue("Provided by clone", fileStatic.exists());
  963. }
  964. }
  965. { // Verify static file content.
  966. File fileOne = new File(dirOne, nameStatic);
  967. File fileTwo = new File(dirTwo, nameStatic);
  968. verifyFileContent(fileOne, fileTwo);
  969. }
  970. { // Verify new file commit and push from local one.
  971. File fileDynamic = new File(dirOne, nameDynamic);
  972. assertFalse("Not Provided by setup", fileDynamic.exists());
  973. FileUtils.createNewFile(fileDynamic);
  974. textWrite(fileDynamic, nameDynamic);
  975. assertTrue("Provided by create", fileDynamic.exists());
  976. assertTrue("Need content to encrypt", fileDynamic.length() > 0);
  977. try (Git git = Git.open(dirOne)) {
  978. git.add().addFilepattern(nameDynamic).call();
  979. git.commit().setMessage(nameDynamic).call();
  980. git.push().setRemote(remote).setRefSpecs(specs).call();
  981. }
  982. }
  983. { // Verify new file pull from remote into local two.
  984. File fileDynamic = new File(dirTwo, nameDynamic);
  985. assertFalse("Not Provided by setup", fileDynamic.exists());
  986. try (Git git = Git.open(dirTwo)) {
  987. git.pull().call();
  988. }
  989. assertTrue("Provided by pull", fileDynamic.exists());
  990. }
  991. { // Verify dynamic file content.
  992. File fileOne = new File(dirOne, nameDynamic);
  993. File fileTwo = new File(dirTwo, nameDynamic);
  994. verifyFileContent(fileOne, fileTwo);
  995. }
  996. }
  997. }
  998. /**
  999. * Verify prerequisites.
  1000. */
  1001. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1002. public static class Required extends Base {
  1003. @Test
  1004. public void test_A1_ValidURI() throws Exception {
  1005. assumeTrue(isTestConfigPresent());
  1006. URIish uri = new URIish(amazonURI());
  1007. assertTrue("uri=" + uri, TransportAmazonS3.PROTO_S3.canHandle(uri));
  1008. }
  1009. @Test(expected = Exception.class)
  1010. public void test_A2_CryptoError() throws Exception {
  1011. assumeTrue(isTestConfigPresent());
  1012. Properties props = new Properties();
  1013. props.put(AmazonS3.Keys.CRYPTO_ALG, ALGO_ERROR);
  1014. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1015. cryptoTest(props);
  1016. }
  1017. }
  1018. /**
  1019. * Test minimal set of algorithms.
  1020. */
  1021. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1022. public static class MinimalSet extends Base {
  1023. @Test
  1024. public void test_V0_Java7_JET() throws Exception {
  1025. assumeTrue(isTestConfigPresent());
  1026. Properties props = new Properties();
  1027. props.put(AmazonS3.Keys.CRYPTO_ALG, ALGO_JETS3T);
  1028. // Do not set version.
  1029. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1030. cryptoTestIfCan(props);
  1031. }
  1032. @Test
  1033. public void test_V1_Java7_GIT() throws Exception {
  1034. assumeTrue(isTestConfigPresent());
  1035. Properties props = new Properties();
  1036. props.put(AmazonS3.Keys.CRYPTO_ALG, ALGO_JETS3T);
  1037. props.put(AmazonS3.Keys.CRYPTO_VER, "1");
  1038. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1039. cryptoTestIfCan(props);
  1040. }
  1041. @Test
  1042. public void test_V2_Java7_AES() throws Exception {
  1043. assumeTrue(isTestConfigPresent());
  1044. // String profile = "default";
  1045. String profile = "AES/CBC/PKCS5Padding+PBKDF2WithHmacSHA1";
  1046. Properties props = new Properties();
  1047. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1048. props.put(AmazonS3.Keys.CRYPTO_VER, "2");
  1049. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1050. props.put(profile + WalkEncryption.Keys.X_ALGO, "AES/CBC/PKCS5Padding");
  1051. props.put(profile + WalkEncryption.Keys.X_KEY_ALGO, "PBKDF2WithHmacSHA1");
  1052. props.put(profile + WalkEncryption.Keys.X_KEY_SIZE, "128");
  1053. props.put(profile + WalkEncryption.Keys.X_KEY_ITER, "10000");
  1054. props.put(profile + WalkEncryption.Keys.X_KEY_SALT, "e2 55 89 67 8e 8d e8 4c");
  1055. cryptoTestIfCan(props);
  1056. }
  1057. @Test
  1058. public void test_V2_Java8_PBE_AES() throws Exception {
  1059. assumeTrue(isTestConfigPresent());
  1060. String profile = "PBEWithHmacSHA512AndAES_256";
  1061. Properties props = new Properties();
  1062. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1063. props.put(AmazonS3.Keys.CRYPTO_VER, "2");
  1064. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1065. props.put(profile + WalkEncryption.Keys.X_ALGO, "PBEWithHmacSHA512AndAES_256");
  1066. props.put(profile + WalkEncryption.Keys.X_KEY_ALGO, "PBEWithHmacSHA512AndAES_256");
  1067. props.put(profile + WalkEncryption.Keys.X_KEY_SIZE, "256");
  1068. props.put(profile + WalkEncryption.Keys.X_KEY_ITER, "10000");
  1069. props.put(profile + WalkEncryption.Keys.X_KEY_SALT, "e2 55 89 67 8e 8d e8 4c");
  1070. policySetup(false);
  1071. cryptoTestIfCan(props);
  1072. }
  1073. }
  1074. /**
  1075. * Test all present and allowed PBE algorithms.
  1076. */
  1077. // https://github.com/junit-team/junit/wiki/Parameterized-tests
  1078. @RunWith(Parameterized.class)
  1079. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1080. public static class TestablePBE extends Base {
  1081. @Parameters(name = "Profile: {0} Version: {1}")
  1082. public static Collection<Object[]> argsList() {
  1083. List<String> algorithmList = new ArrayList<>();
  1084. algorithmList.addAll(cryptoCipherListPBE());
  1085. List<String> versionList = new ArrayList<>();
  1086. versionList.add("0");
  1087. versionList.add("1");
  1088. return product(algorithmList, versionList);
  1089. }
  1090. final String profile;
  1091. final String version;
  1092. final String password = JGIT_PASS;
  1093. public TestablePBE(String profile, String version) {
  1094. this.profile = profile;
  1095. this.version = version;
  1096. }
  1097. @Test
  1098. public void testCrypto() throws Exception {
  1099. assumeTrue(permitLongTests());
  1100. Properties props = new Properties();
  1101. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1102. props.put(AmazonS3.Keys.CRYPTO_VER, version);
  1103. props.put(AmazonS3.Keys.PASSWORD, password);
  1104. cryptoTestIfCan(props);
  1105. }
  1106. }
  1107. /**
  1108. * Test all present and allowed transformation algorithms.
  1109. */
  1110. // https://github.com/junit-team/junit/wiki/Parameterized-tests
  1111. @RunWith(Parameterized.class)
  1112. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1113. public static class TestableTransformation extends Base {
  1114. @Parameters(name = "Profile: {0} Version: {1}")
  1115. public static Collection<Object[]> argsList() {
  1116. List<String> algorithmList = new ArrayList<>();
  1117. algorithmList.addAll(cryptoCipherListTrans());
  1118. List<String> versionList = new ArrayList<>();
  1119. versionList.add("1");
  1120. return product(algorithmList, versionList);
  1121. }
  1122. final String profile;
  1123. final String version;
  1124. final String password = JGIT_PASS;
  1125. public TestableTransformation(String profile, String version) {
  1126. this.profile = profile;
  1127. this.version = version;
  1128. }
  1129. @Test
  1130. public void testCrypto() throws Exception {
  1131. assumeTrue(permitLongTests());
  1132. Properties props = new Properties();
  1133. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1134. props.put(AmazonS3.Keys.CRYPTO_VER, version);
  1135. props.put(AmazonS3.Keys.PASSWORD, password);
  1136. cryptoTestIfCan(props);
  1137. }
  1138. }
  1139. }