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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  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. } else {
  207. return null;
  208. }
  209. }
  210. static Properties fromEnvFile() throws Exception {
  211. if (haveEnvVarFile(ENV_CONFIG_FILE)) {
  212. Properties props = new Properties();
  213. props.load(new FileInputStream(ENV_CONFIG_FILE));
  214. if (checkTestProps(props)) {
  215. return props;
  216. } else {
  217. throw new Error("Environment config file is incomplete.");
  218. }
  219. } else {
  220. return null;
  221. }
  222. }
  223. static Properties fromSysProps() {
  224. if (haveSysProp(SYS_ACCESS_KEY) && haveSysProp(SYS_SECRET_KEY)
  225. && haveSysProp(SYS_BUCKET_NAME)) {
  226. Properties props = new Properties();
  227. loadSysProp(SYS_ACCESS_KEY, ACCESS_KEY, props);
  228. loadSysProp(SYS_SECRET_KEY, SECRET_KEY, props);
  229. loadSysProp(SYS_BUCKET_NAME, TEST_BUCKET, props);
  230. return props;
  231. } else {
  232. return null;
  233. }
  234. }
  235. static Properties fromSysFile() throws Exception {
  236. if (haveSysPropFile(SYS_CONFIG_FILE)) {
  237. Properties props = new Properties();
  238. props.load(new FileInputStream(SYS_CONFIG_FILE));
  239. if (checkTestProps(props)) {
  240. return props;
  241. } else {
  242. throw new Error("System props config file is incomplete.");
  243. }
  244. } else {
  245. return null;
  246. }
  247. }
  248. static Properties fromConfigFile(String path) throws Exception {
  249. File file = new File(path);
  250. if (file.exists()) {
  251. Properties props = new Properties();
  252. props.load(new FileInputStream(file));
  253. if (checkTestProps(props)) {
  254. return props;
  255. } else {
  256. throw new Error("Props config file is incomplete: " + path);
  257. }
  258. } else {
  259. return null;
  260. }
  261. }
  262. /**
  263. * Find test properties from various sources in order of priority.
  264. *
  265. * @return result
  266. * @throws Exception
  267. */
  268. static Properties discover() throws Exception {
  269. Properties props;
  270. if ((props = fromEnvVars()) != null) {
  271. logger.debug(
  272. "Using test properties from environment variables.");
  273. return props;
  274. }
  275. if ((props = fromEnvFile()) != null) {
  276. logger.debug(
  277. "Using test properties from environment variable config file.");
  278. return props;
  279. }
  280. if ((props = fromSysProps()) != null) {
  281. logger.debug("Using test properties from system properties.");
  282. return props;
  283. }
  284. if ((props = fromSysFile()) != null) {
  285. logger.debug(
  286. "Using test properties from system property config file.");
  287. return props;
  288. }
  289. if ((props = fromConfigFile(HOME_CONFIG_FILE)) != null) {
  290. logger.debug(
  291. "Using test properties from hard coded ${user.home} file.");
  292. return props;
  293. }
  294. if ((props = fromConfigFile(WORK_CONFIG_FILE)) != null) {
  295. logger.debug(
  296. "Using test properties from hard coded ${user.dir} file.");
  297. return props;
  298. }
  299. if ((props = fromConfigFile(TEST_CONFIG_FILE)) != null) {
  300. logger.debug(
  301. "Using test properties from hard coded ${project.source} file.");
  302. return props;
  303. }
  304. throw new Error("Can not load test properties form any source.");
  305. }
  306. }
  307. /**
  308. * Collection of test utility methods.
  309. */
  310. static class Util {
  311. /**
  312. * Read UTF-8 encoded text file into string.
  313. *
  314. * @param file
  315. * @return result
  316. * @throws Exception
  317. */
  318. static String textRead(File file) throws Exception {
  319. return new String(Files.readAllBytes(file.toPath()), UTF_8);
  320. }
  321. /**
  322. * Write string into UTF-8 encoded file.
  323. *
  324. * @param file
  325. * @param text
  326. * @throws Exception
  327. */
  328. static void textWrite(File file, String text) throws Exception {
  329. Files.write(file.toPath(), text.getBytes(UTF_8));
  330. }
  331. static void verifyFileContent(File fileOne, File fileTwo)
  332. throws Exception {
  333. assertTrue(fileOne.length() > 0);
  334. assertTrue(fileTwo.length() > 0);
  335. String textOne = textRead(fileOne);
  336. String textTwo = textRead(fileTwo);
  337. assertEquals(textOne, textTwo);
  338. }
  339. /**
  340. * Create local folder.
  341. *
  342. * @param folder
  343. * @throws Exception
  344. */
  345. static void folderCreate(String folder) throws Exception {
  346. File path = new File(folder);
  347. assertTrue(path.mkdirs());
  348. }
  349. /**
  350. * Delete local folder.
  351. *
  352. * @param folder
  353. * @throws Exception
  354. */
  355. static void folderDelete(String folder) throws Exception {
  356. File path = new File(folder);
  357. FileUtils.delete(path,
  358. FileUtils.RECURSIVE | FileUtils.SKIP_MISSING);
  359. }
  360. /**
  361. * Discover public address of CI server.
  362. *
  363. * @return result
  364. * @throws Exception
  365. */
  366. static String publicAddress() throws Exception {
  367. try {
  368. String service = "http://checkip.amazonaws.com";
  369. URL url = new URL(service);
  370. URLConnection c = url.openConnection();
  371. c.setConnectTimeout(500);
  372. c.setReadTimeout(500);
  373. try (BufferedReader reader = new BufferedReader(
  374. new InputStreamReader(c.getInputStream(), UTF_8))) {
  375. return reader.readLine();
  376. }
  377. } catch (UnknownHostException | SocketTimeoutException e) {
  378. return "Can't reach http://checkip.amazonaws.com to"
  379. + " determine public address";
  380. }
  381. }
  382. /**
  383. * Discover Password-Based Encryption (PBE) engines providing both
  384. * [SecretKeyFactory] and [AlgorithmParameters].
  385. *
  386. * @return result
  387. */
  388. // https://www.bouncycastle.org/specifications.html
  389. // https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html
  390. static List<String> cryptoCipherListPBE() {
  391. return cryptoCipherList(WalkEncryption.Vals.REGEX_PBE);
  392. }
  393. // TODO returns inconsistent list.
  394. static List<String> cryptoCipherListTrans() {
  395. return cryptoCipherList(WalkEncryption.Vals.REGEX_TRANS);
  396. }
  397. static String securityProviderName(String algorithm) throws Exception {
  398. return SecretKeyFactory.getInstance(algorithm).getProvider()
  399. .getName();
  400. }
  401. static List<String> cryptoCipherList(String regex) {
  402. Set<String> source = Security.getAlgorithms("Cipher");
  403. Set<String> target = new TreeSet<>();
  404. for (String algo : source) {
  405. algo = algo.toUpperCase(Locale.ROOT);
  406. if (algo.matches(regex)) {
  407. target.add(algo);
  408. }
  409. }
  410. return new ArrayList<>(target);
  411. }
  412. /**
  413. * Stream copy.
  414. *
  415. * @param from
  416. * @param into
  417. * @return count
  418. * @throws IOException
  419. */
  420. static long transferStream(InputStream from, OutputStream into)
  421. throws IOException {
  422. byte[] array = new byte[1 * 1024];
  423. long total = 0;
  424. while (true) {
  425. int count = from.read(array);
  426. if (count == -1) {
  427. break;
  428. }
  429. into.write(array, 0, count);
  430. total += count;
  431. }
  432. return total;
  433. }
  434. /**
  435. * Setup proxy during CI build.
  436. *
  437. * @throws Exception
  438. */
  439. // https://wiki.eclipse.org/Hudson#Accessing_the_Internet_using_Proxy
  440. // http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html
  441. static void proxySetup() throws Exception {
  442. String keyNoProxy = "no_proxy";
  443. String keyHttpProxy = "http_proxy";
  444. String keyHttpsProxy = "https_proxy";
  445. String no_proxy = System.getProperty(keyNoProxy,
  446. System.getenv(keyNoProxy));
  447. if (no_proxy != null) {
  448. System.setProperty("http.nonProxyHosts", no_proxy);
  449. logger.info("Proxy NOT: " + no_proxy);
  450. }
  451. String http_proxy = System.getProperty(keyHttpProxy,
  452. System.getenv(keyHttpProxy));
  453. if (http_proxy != null) {
  454. URL url = new URL(http_proxy);
  455. System.setProperty("http.proxyHost", url.getHost());
  456. System.setProperty("http.proxyPort", "" + url.getPort());
  457. logger.info("Proxy HTTP: " + http_proxy);
  458. }
  459. String https_proxy = System.getProperty(keyHttpsProxy,
  460. System.getenv(keyHttpsProxy));
  461. if (https_proxy != null) {
  462. URL url = new URL(https_proxy);
  463. System.setProperty("https.proxyHost", url.getHost());
  464. System.setProperty("https.proxyPort", "" + url.getPort());
  465. logger.info("Proxy HTTPS: " + https_proxy);
  466. }
  467. if (no_proxy == null && http_proxy == null && https_proxy == null) {
  468. logger.info("Proxy not used.");
  469. }
  470. }
  471. /**
  472. * Permit long tests on CI or with manual activation.
  473. *
  474. * @return result
  475. */
  476. static boolean permitLongTests() {
  477. return isBuildCI() || isProfileActive();
  478. }
  479. /**
  480. * Using Maven profile activation, see pom.xml
  481. *
  482. * @return result
  483. */
  484. static boolean isProfileActive() {
  485. return Boolean.parseBoolean(System.getProperty("jgit.test.long"));
  486. }
  487. /**
  488. * Detect if build is running on CI.
  489. *
  490. * @return result
  491. */
  492. static boolean isBuildCI() {
  493. return System.getenv("HUDSON_HOME") != null;
  494. }
  495. /**
  496. * Setup JCE security policy restrictions. Can remove restrictions when
  497. * restrictions are present, but can not impose them when restrictions
  498. * are missing.
  499. *
  500. * @param restrictedOn
  501. */
  502. // http://www.docjar.com/html/api/javax/crypto/JceSecurity.java.html
  503. static void policySetup(boolean restrictedOn) {
  504. try {
  505. java.lang.reflect.Field isRestricted = Class
  506. .forName("javax.crypto.JceSecurity")
  507. .getDeclaredField("isRestricted");
  508. isRestricted.setAccessible(true);
  509. isRestricted.set(null, Boolean.valueOf(restrictedOn));
  510. } catch (Throwable e) {
  511. logger.info(
  512. "Could not setup JCE security policy restrictions.");
  513. }
  514. }
  515. static void reportPolicy() {
  516. try {
  517. java.lang.reflect.Field isRestricted = Class
  518. .forName("javax.crypto.JceSecurity")
  519. .getDeclaredField("isRestricted");
  520. isRestricted.setAccessible(true);
  521. logger.info("JCE security policy restricted="
  522. + isRestricted.get(null));
  523. } catch (Throwable e) {
  524. logger.info(
  525. "Could not report JCE security policy restrictions.");
  526. }
  527. }
  528. static List<Object[]> product(List<String> one, List<String> two) {
  529. List<Object[]> result = new ArrayList<>();
  530. for (String s1 : one) {
  531. for (String s2 : two) {
  532. result.add(new Object[] { s1, s2 });
  533. }
  534. }
  535. return result;
  536. }
  537. }
  538. /**
  539. * Common base for encryption tests.
  540. */
  541. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  542. public abstract static class Base extends SampleDataRepositoryTestCase {
  543. /**
  544. * S3 URI user used by JGIT to discover connection configuration file.
  545. */
  546. static final String JGIT_USER = "tester-" + System.currentTimeMillis();
  547. /**
  548. * S3 content encoding password used for this test session.
  549. */
  550. static final String JGIT_PASS = "secret-" + System.currentTimeMillis();
  551. /**
  552. * S3 repository configuration file expected by {@link AmazonS3}.
  553. */
  554. static final String JGIT_CONF_FILE = System.getProperty("user.home")
  555. + "/" + JGIT_USER;
  556. /**
  557. * Name representing remote or local JGIT repository.
  558. */
  559. static final String JGIT_REPO_DIR = JGIT_USER + ".jgit";
  560. /**
  561. * Local JGIT repository for this test session.
  562. */
  563. static final String JGIT_LOCAL_DIR = System.getProperty("user.dir")
  564. + "/target/" + JGIT_REPO_DIR;
  565. /**
  566. * Remote JGIT repository for this test session.
  567. */
  568. static final String JGIT_REMOTE_DIR = JGIT_REPO_DIR;
  569. /**
  570. * Generate JGIT S3 connection configuration file.
  571. *
  572. * @param algorithm
  573. * @throws Exception
  574. */
  575. static void configCreate(String algorithm) throws Exception {
  576. Properties props = Props.discover();
  577. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  578. props.put(AmazonS3.Keys.CRYPTO_ALG, algorithm);
  579. try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE)) {
  580. props.store(writer, "JGIT S3 connection configuration file.");
  581. }
  582. }
  583. /**
  584. * Generate JGIT S3 connection configuration file.
  585. *
  586. * @param source
  587. * @throws Exception
  588. */
  589. static void configCreate(Properties source) throws Exception {
  590. Properties target = Props.discover();
  591. target.putAll(source);
  592. try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE)) {
  593. target.store(writer, "JGIT S3 connection configuration file.");
  594. }
  595. }
  596. /**
  597. * Remove JGIT connection configuration file.
  598. *
  599. * @throws Exception
  600. */
  601. static void configDelete() throws Exception {
  602. File path = new File(JGIT_CONF_FILE);
  603. FileUtils.delete(path, FileUtils.SKIP_MISSING);
  604. }
  605. /**
  606. * Generate remote URI for the test session.
  607. *
  608. * @return result
  609. * @throws Exception
  610. */
  611. static String amazonURI() throws Exception {
  612. Properties props = Props.discover();
  613. String bucket = props.getProperty(Names.TEST_BUCKET);
  614. assertNotNull(bucket);
  615. return TransportAmazonS3.S3_SCHEME + "://" + JGIT_USER + "@"
  616. + bucket + "/" + JGIT_REPO_DIR;
  617. }
  618. /**
  619. * Create S3 repository folder.
  620. *
  621. * @throws Exception
  622. */
  623. static void remoteCreate() throws Exception {
  624. Properties props = Props.discover();
  625. props.remove(AmazonS3.Keys.PASSWORD); // Disable encryption.
  626. String bucket = props.getProperty(Names.TEST_BUCKET);
  627. AmazonS3 s3 = new AmazonS3(props);
  628. String path = JGIT_REMOTE_DIR + "/";
  629. s3.put(bucket, path, new byte[0]);
  630. logger.debug("remote create: " + JGIT_REMOTE_DIR);
  631. }
  632. /**
  633. * Delete S3 repository folder.
  634. *
  635. * @throws Exception
  636. */
  637. static void remoteDelete() throws Exception {
  638. Properties props = Props.discover();
  639. props.remove(AmazonS3.Keys.PASSWORD); // Disable encryption.
  640. String bucket = props.getProperty(Names.TEST_BUCKET);
  641. AmazonS3 s3 = new AmazonS3(props);
  642. List<String> list = s3.list(bucket, JGIT_REMOTE_DIR);
  643. for (String path : list) {
  644. path = JGIT_REMOTE_DIR + "/" + path;
  645. s3.delete(bucket, path);
  646. }
  647. logger.debug("remote delete: " + JGIT_REMOTE_DIR);
  648. }
  649. /**
  650. * Verify if we can create/delete remote file.
  651. *
  652. * @throws Exception
  653. */
  654. static void remoteVerify() throws Exception {
  655. Properties props = Props.discover();
  656. String bucket = props.getProperty(Names.TEST_BUCKET);
  657. AmazonS3 s3 = new AmazonS3(props);
  658. String file = JGIT_USER + "-" + UUID.randomUUID().toString();
  659. String path = JGIT_REMOTE_DIR + "/" + file;
  660. s3.put(bucket, path, file.getBytes(UTF_8));
  661. s3.delete(bucket, path);
  662. }
  663. /**
  664. * Verify if any security provider published the algorithm.
  665. *
  666. * @param algorithm
  667. * @return result
  668. */
  669. static boolean isAlgorithmPresent(String algorithm) {
  670. Set<String> cipherSet = Security.getAlgorithms("Cipher");
  671. for (String source : cipherSet) {
  672. // Standard names are not case-sensitive.
  673. // http://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html
  674. String target = algorithm.toUpperCase(Locale.ROOT);
  675. if (source.equalsIgnoreCase(target)) {
  676. return true;
  677. }
  678. }
  679. return false;
  680. }
  681. static boolean isAlgorithmPresent(Properties props) {
  682. String profile = props.getProperty(AmazonS3.Keys.CRYPTO_ALG);
  683. String version = props.getProperty(AmazonS3.Keys.CRYPTO_VER,
  684. WalkEncryption.Vals.DEFAULT_VERS);
  685. String cryptoAlgo;
  686. String keyAlgo;
  687. switch (version) {
  688. case WalkEncryption.Vals.DEFAULT_VERS:
  689. case WalkEncryption.JGitV1.VERSION:
  690. cryptoAlgo = profile;
  691. keyAlgo = profile;
  692. break;
  693. case WalkEncryption.JGitV2.VERSION:
  694. cryptoAlgo = props
  695. .getProperty(profile + WalkEncryption.Keys.X_ALGO);
  696. keyAlgo = props
  697. .getProperty(profile + WalkEncryption.Keys.X_KEY_ALGO);
  698. break;
  699. default:
  700. return false;
  701. }
  702. try {
  703. InsecureCipherFactory.create(cryptoAlgo);
  704. SecretKeyFactory.getInstance(keyAlgo);
  705. return true;
  706. } catch (Throwable e) {
  707. return false;
  708. }
  709. }
  710. /**
  711. * Verify if JRE security policy allows the algorithm.
  712. *
  713. * @param algorithm
  714. * @return result
  715. */
  716. static boolean isAlgorithmAllowed(String algorithm) {
  717. try {
  718. WalkEncryption crypto = new WalkEncryption.JetS3tV2(
  719. algorithm, JGIT_PASS);
  720. verifyCrypto(crypto);
  721. return true;
  722. } catch (IOException e) {
  723. return false; // Encryption failure.
  724. } catch (GeneralSecurityException e) {
  725. throw new Error(e); // Construction failure.
  726. }
  727. }
  728. static boolean isAlgorithmAllowed(Properties props) {
  729. try {
  730. WalkEncryption.instance(props);
  731. return true;
  732. } catch (GeneralSecurityException e) {
  733. return false;
  734. }
  735. }
  736. /**
  737. * Verify round trip encryption.
  738. *
  739. * @param crypto
  740. * @throws IOException
  741. */
  742. static void verifyCrypto(WalkEncryption crypto) throws IOException {
  743. String charset = "UTF-8";
  744. String sourceText = "secret-message Свобода 老子";
  745. String targetText;
  746. byte[] cipherText;
  747. {
  748. byte[] origin = sourceText.getBytes(charset);
  749. ByteArrayOutputStream target = new ByteArrayOutputStream();
  750. try (OutputStream source = crypto.encrypt(target)) {
  751. source.write(origin);
  752. source.flush();
  753. }
  754. cipherText = target.toByteArray();
  755. }
  756. {
  757. InputStream source = new ByteArrayInputStream(cipherText);
  758. InputStream target = crypto.decrypt(source);
  759. ByteArrayOutputStream result = new ByteArrayOutputStream();
  760. transferStream(target, result);
  761. targetText = result.toString(charset);
  762. }
  763. assertEquals(sourceText, targetText);
  764. }
  765. /**
  766. * Algorithm is testable when it is present and allowed by policy.
  767. *
  768. * @param algorithm
  769. * @return result
  770. */
  771. static boolean isAlgorithmTestable(String algorithm) {
  772. return isAlgorithmPresent(algorithm)
  773. && isAlgorithmAllowed(algorithm);
  774. }
  775. static boolean isAlgorithmTestable(Properties props) {
  776. return isAlgorithmPresent(props) && isAlgorithmAllowed(props);
  777. }
  778. /**
  779. * Log algorithm, provider, testability.
  780. *
  781. * @param algorithm
  782. * @throws Exception
  783. */
  784. static void reportAlgorithmStatus(String algorithm) throws Exception {
  785. final boolean present = isAlgorithmPresent(algorithm);
  786. final boolean allowed = present && isAlgorithmAllowed(algorithm);
  787. final String provider = present ? securityProviderName(algorithm)
  788. : "N/A";
  789. String status = "Algorithm: " + algorithm + " @ " + provider + "; "
  790. + "present/allowed : " + present + "/" + allowed;
  791. if (allowed) {
  792. logger.info("Testing " + status);
  793. } else {
  794. logger.warn("Missing " + status);
  795. }
  796. }
  797. static void reportAlgorithmStatus(Properties props) throws Exception {
  798. final boolean present = isAlgorithmPresent(props);
  799. final boolean allowed = present && isAlgorithmAllowed(props);
  800. String profile = props.getProperty(AmazonS3.Keys.CRYPTO_ALG);
  801. String version = props.getProperty(AmazonS3.Keys.CRYPTO_VER);
  802. StringBuilder status = new StringBuilder();
  803. status.append(" Version: " + version);
  804. status.append(" Profile: " + profile);
  805. status.append(" Present: " + present);
  806. status.append(" Allowed: " + allowed);
  807. if (allowed) {
  808. logger.info("Testing " + status);
  809. } else {
  810. logger.warn("Missing " + status);
  811. }
  812. }
  813. /**
  814. * Verify if we can perform remote tests.
  815. *
  816. * @return result
  817. */
  818. static boolean isTestConfigPresent() {
  819. try {
  820. Props.discover();
  821. return true;
  822. } catch (Throwable e) {
  823. return false;
  824. }
  825. }
  826. static void reportTestConfigPresent() {
  827. if (isTestConfigPresent()) {
  828. logger.info("Amazon S3 test configuration is present.");
  829. } else {
  830. logger.error(
  831. "Amazon S3 test configuration is missing, tests will not run.");
  832. }
  833. }
  834. /**
  835. * Log public address of CI.
  836. *
  837. * @throws Exception
  838. */
  839. static void reportPublicAddress() throws Exception {
  840. logger.info("Public address: " + publicAddress());
  841. }
  842. /**
  843. * BouncyCastle provider class.
  844. *
  845. * Needs extra dependency, see pom.xml
  846. */
  847. // http://search.maven.org/#artifactdetails%7Corg.bouncycastle%7Cbcprov-jdk15on%7C1.52%7Cjar
  848. static final String PROVIDER_BC = "org.bouncycastle.jce.provider.BouncyCastleProvider";
  849. /**
  850. * Load BouncyCastle provider if present.
  851. */
  852. static void loadBouncyCastle() {
  853. try {
  854. Class<?> provider = Class.forName(PROVIDER_BC);
  855. Provider instance = (Provider) provider
  856. .getConstructor(new Class[] {})
  857. .newInstance(new Object[] {});
  858. Security.addProvider(instance);
  859. logger.info("Loaded " + PROVIDER_BC);
  860. } catch (Throwable e) {
  861. logger.warn("Failed to load " + PROVIDER_BC);
  862. }
  863. }
  864. static void reportLongTests() {
  865. if (permitLongTests()) {
  866. logger.info("Long running tests are enabled.");
  867. } else {
  868. logger.warn("Long running tests are disabled.");
  869. }
  870. }
  871. /**
  872. * Non-PBE algorithm, for error check.
  873. */
  874. static final String ALGO_ERROR = "PBKDF2WithHmacSHA1";
  875. /**
  876. * Default JetS3t algorithm present in most JRE.
  877. */
  878. static final String ALGO_JETS3T = "PBEWithMD5AndDES";
  879. /**
  880. * Minimal strength AES based algorithm present in most JRE.
  881. */
  882. static final String ALGO_MINIMAL_AES = "PBEWithHmacSHA1AndAES_128";
  883. /**
  884. * Selected non-AES algorithm present in BouncyCastle provider.
  885. */
  886. static final String ALGO_BOUNCY_CASTLE_CBC = "PBEWithSHAAndTwofish-CBC";
  887. //////////////////////////////////////////////////
  888. @BeforeClass
  889. public static void initialize() throws Exception {
  890. Transport.register(TransportAmazonS3.PROTO_S3);
  891. proxySetup();
  892. reportPolicy();
  893. reportLongTests();
  894. reportPublicAddress();
  895. reportTestConfigPresent();
  896. loadBouncyCastle();
  897. if (isTestConfigPresent()) {
  898. remoteCreate();
  899. }
  900. }
  901. @AfterClass
  902. public static void terminate() throws Exception {
  903. configDelete();
  904. folderDelete(JGIT_LOCAL_DIR);
  905. if (isTestConfigPresent()) {
  906. remoteDelete();
  907. }
  908. }
  909. @Before
  910. @Override
  911. public void setUp() throws Exception {
  912. super.setUp();
  913. }
  914. @After
  915. @Override
  916. public void tearDown() throws Exception {
  917. super.tearDown();
  918. }
  919. /**
  920. * Optional encrypted amazon remote JGIT life cycle test.
  921. *
  922. * @param props
  923. * @throws Exception
  924. */
  925. void cryptoTestIfCan(Properties props) throws Exception {
  926. reportAlgorithmStatus(props);
  927. assumeTrue(isTestConfigPresent());
  928. assumeTrue(isAlgorithmTestable(props));
  929. cryptoTest(props);
  930. }
  931. /**
  932. * Required encrypted amazon remote JGIT life cycle test.
  933. *
  934. * @param props
  935. * @throws Exception
  936. */
  937. void cryptoTest(Properties props) throws Exception {
  938. remoteDelete();
  939. configCreate(props);
  940. folderDelete(JGIT_LOCAL_DIR);
  941. String uri = amazonURI();
  942. // Local repositories.
  943. File dirOne = db.getWorkTree(); // Provided by setup.
  944. File dirTwo = new File(JGIT_LOCAL_DIR);
  945. // Local verification files.
  946. String nameStatic = "master.txt"; // Provided by setup.
  947. String nameDynamic = JGIT_USER + "-" + UUID.randomUUID().toString();
  948. String remote = "remote";
  949. RefSpec specs = new RefSpec("refs/heads/master:refs/heads/master");
  950. { // Push into remote from local one.
  951. StoredConfig config = db.getConfig();
  952. RemoteConfig remoteConfig = new RemoteConfig(config, remote);
  953. remoteConfig.addURI(new URIish(uri));
  954. remoteConfig.update(config);
  955. config.save();
  956. try (Git git = Git.open(dirOne)) {
  957. git.checkout().setName("master").call();
  958. git.push().setRemote(remote).setRefSpecs(specs).call();
  959. }
  960. File fileStatic = new File(dirOne, nameStatic);
  961. assertTrue("Provided by setup", fileStatic.exists());
  962. }
  963. { // Clone from remote into local two.
  964. File fileStatic = new File(dirTwo, nameStatic);
  965. assertFalse("Not Provided by setup", fileStatic.exists());
  966. try (Git git = Git.cloneRepository().setURI(uri)
  967. .setDirectory(dirTwo).call()) {
  968. assertTrue("Provided by clone", fileStatic.exists());
  969. }
  970. }
  971. { // Verify static file content.
  972. File fileOne = new File(dirOne, nameStatic);
  973. File fileTwo = new File(dirTwo, nameStatic);
  974. verifyFileContent(fileOne, fileTwo);
  975. }
  976. { // Verify new file commit and push from local one.
  977. File fileDynamic = new File(dirOne, nameDynamic);
  978. assertFalse("Not Provided by setup", fileDynamic.exists());
  979. FileUtils.createNewFile(fileDynamic);
  980. textWrite(fileDynamic, nameDynamic);
  981. assertTrue("Provided by create", fileDynamic.exists());
  982. assertTrue("Need content to encrypt", fileDynamic.length() > 0);
  983. try (Git git = Git.open(dirOne)) {
  984. git.add().addFilepattern(nameDynamic).call();
  985. git.commit().setMessage(nameDynamic).call();
  986. git.push().setRemote(remote).setRefSpecs(specs).call();
  987. }
  988. }
  989. { // Verify new file pull from remote into local two.
  990. File fileDynamic = new File(dirTwo, nameDynamic);
  991. assertFalse("Not Provided by setup", fileDynamic.exists());
  992. try (Git git = Git.open(dirTwo)) {
  993. git.pull().call();
  994. }
  995. assertTrue("Provided by pull", fileDynamic.exists());
  996. }
  997. { // Verify dynamic file content.
  998. File fileOne = new File(dirOne, nameDynamic);
  999. File fileTwo = new File(dirTwo, nameDynamic);
  1000. verifyFileContent(fileOne, fileTwo);
  1001. }
  1002. }
  1003. }
  1004. /**
  1005. * Verify prerequisites.
  1006. */
  1007. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1008. public static class Required extends Base {
  1009. @Test
  1010. public void test_A1_ValidURI() throws Exception {
  1011. assumeTrue(isTestConfigPresent());
  1012. URIish uri = new URIish(amazonURI());
  1013. assertTrue("uri=" + uri, TransportAmazonS3.PROTO_S3.canHandle(uri));
  1014. }
  1015. @Test(expected = Exception.class)
  1016. public void test_A2_CryptoError() throws Exception {
  1017. assumeTrue(isTestConfigPresent());
  1018. Properties props = new Properties();
  1019. props.put(AmazonS3.Keys.CRYPTO_ALG, ALGO_ERROR);
  1020. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1021. cryptoTest(props);
  1022. }
  1023. }
  1024. /**
  1025. * Test minimal set of algorithms.
  1026. */
  1027. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1028. public static class MinimalSet extends Base {
  1029. @Test
  1030. public void test_V0_Java7_JET() throws Exception {
  1031. assumeTrue(isTestConfigPresent());
  1032. Properties props = new Properties();
  1033. props.put(AmazonS3.Keys.CRYPTO_ALG, ALGO_JETS3T);
  1034. // Do not set version.
  1035. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1036. cryptoTestIfCan(props);
  1037. }
  1038. @Test
  1039. public void test_V1_Java7_GIT() throws Exception {
  1040. assumeTrue(isTestConfigPresent());
  1041. Properties props = new Properties();
  1042. props.put(AmazonS3.Keys.CRYPTO_ALG, ALGO_JETS3T);
  1043. props.put(AmazonS3.Keys.CRYPTO_VER, "1");
  1044. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1045. cryptoTestIfCan(props);
  1046. }
  1047. @Test
  1048. public void test_V2_Java7_AES() throws Exception {
  1049. assumeTrue(isTestConfigPresent());
  1050. // String profile = "default";
  1051. String profile = "AES/CBC/PKCS5Padding+PBKDF2WithHmacSHA1";
  1052. Properties props = new Properties();
  1053. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1054. props.put(AmazonS3.Keys.CRYPTO_VER, "2");
  1055. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1056. props.put(profile + WalkEncryption.Keys.X_ALGO, "AES/CBC/PKCS5Padding");
  1057. props.put(profile + WalkEncryption.Keys.X_KEY_ALGO, "PBKDF2WithHmacSHA1");
  1058. props.put(profile + WalkEncryption.Keys.X_KEY_SIZE, "128");
  1059. props.put(profile + WalkEncryption.Keys.X_KEY_ITER, "10000");
  1060. props.put(profile + WalkEncryption.Keys.X_KEY_SALT, "e2 55 89 67 8e 8d e8 4c");
  1061. cryptoTestIfCan(props);
  1062. }
  1063. @Test
  1064. public void test_V2_Java8_PBE_AES() throws Exception {
  1065. assumeTrue(isTestConfigPresent());
  1066. String profile = "PBEWithHmacSHA512AndAES_256";
  1067. Properties props = new Properties();
  1068. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1069. props.put(AmazonS3.Keys.CRYPTO_VER, "2");
  1070. props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS);
  1071. props.put(profile + WalkEncryption.Keys.X_ALGO, "PBEWithHmacSHA512AndAES_256");
  1072. props.put(profile + WalkEncryption.Keys.X_KEY_ALGO, "PBEWithHmacSHA512AndAES_256");
  1073. props.put(profile + WalkEncryption.Keys.X_KEY_SIZE, "256");
  1074. props.put(profile + WalkEncryption.Keys.X_KEY_ITER, "10000");
  1075. props.put(profile + WalkEncryption.Keys.X_KEY_SALT, "e2 55 89 67 8e 8d e8 4c");
  1076. policySetup(false);
  1077. cryptoTestIfCan(props);
  1078. }
  1079. }
  1080. /**
  1081. * Test all present and allowed PBE algorithms.
  1082. */
  1083. // https://github.com/junit-team/junit/wiki/Parameterized-tests
  1084. @RunWith(Parameterized.class)
  1085. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1086. public static class TestablePBE extends Base {
  1087. @Parameters(name = "Profile: {0} Version: {1}")
  1088. public static Collection<Object[]> argsList() {
  1089. List<String> algorithmList = new ArrayList<>();
  1090. algorithmList.addAll(cryptoCipherListPBE());
  1091. List<String> versionList = new ArrayList<>();
  1092. versionList.add("0");
  1093. versionList.add("1");
  1094. return product(algorithmList, versionList);
  1095. }
  1096. final String profile;
  1097. final String version;
  1098. final String password = JGIT_PASS;
  1099. public TestablePBE(String profile, String version) {
  1100. this.profile = profile;
  1101. this.version = version;
  1102. }
  1103. @Test
  1104. public void testCrypto() throws Exception {
  1105. assumeTrue(permitLongTests());
  1106. Properties props = new Properties();
  1107. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1108. props.put(AmazonS3.Keys.CRYPTO_VER, version);
  1109. props.put(AmazonS3.Keys.PASSWORD, password);
  1110. cryptoTestIfCan(props);
  1111. }
  1112. }
  1113. /**
  1114. * Test all present and allowed transformation algorithms.
  1115. */
  1116. // https://github.com/junit-team/junit/wiki/Parameterized-tests
  1117. @RunWith(Parameterized.class)
  1118. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  1119. public static class TestableTransformation extends Base {
  1120. @Parameters(name = "Profile: {0} Version: {1}")
  1121. public static Collection<Object[]> argsList() {
  1122. List<String> algorithmList = new ArrayList<>();
  1123. algorithmList.addAll(cryptoCipherListTrans());
  1124. List<String> versionList = new ArrayList<>();
  1125. versionList.add("1");
  1126. return product(algorithmList, versionList);
  1127. }
  1128. final String profile;
  1129. final String version;
  1130. final String password = JGIT_PASS;
  1131. public TestableTransformation(String profile, String version) {
  1132. this.profile = profile;
  1133. this.version = version;
  1134. }
  1135. @Test
  1136. public void testCrypto() throws Exception {
  1137. assumeTrue(permitLongTests());
  1138. Properties props = new Properties();
  1139. props.put(AmazonS3.Keys.CRYPTO_ALG, profile);
  1140. props.put(AmazonS3.Keys.CRYPTO_VER, version);
  1141. props.put(AmazonS3.Keys.PASSWORD, password);
  1142. cryptoTestIfCan(props);
  1143. }
  1144. }
  1145. }