src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
EcrExtendedAuth { HttpPost createSignedRequest(RegistryAuth localCredentials, Date time) { String host = "ecr." + region + ".amazonaws.com"; logger.debug("Get ECR AuthorizationToken from %s", host); HttpPost request = new HttpPost("https: request.setHeader("host", host); request.setHeader("Content-Type", "application/x...
@Test public void testHeaders() throws ParseException { EcrExtendedAuth eea = new EcrExtendedAuth(logger, "123456789012.dkr.ecr.eu-west-1.amazonaws.com"); RegistryAuth localCredentials = new RegistryAuth.Builder() .username("username") .password("password") .build(); Date signingTime = AwsSigner4Request.TIME_FORMAT.par...
EcrExtendedAuth { public RegistryAuth extendedAuth(RegistryAuth localCredentials) throws IOException { JsonObject jo = getAuthorizationToken(localCredentials); JsonArray authorizationDatas = jo.getAsJsonArray("authorizationData"); JsonObject authorizationData = authorizationDatas.get(0).getAsJsonObject(); String author...
@Test public void testClientClosedAndCredentialsDecoded(@Mocked final CloseableHttpClient closeableHttpClient, @Mocked final CloseableHttpResponse closeableHttpResponse, @Mocked final StatusLine statusLine) throws IOException { final HttpEntity entity = new StringEntity("{\"authorizationData\": [{" + "\"authorizationTo...
OpenShiftRegistryAuthHandler implements RegistryAuthHandler { @Override public RegistryAuth create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String useOpenAuthMode = registryAuthConfig.extractFromProperties(props, kind, A...
@Test public void testOpenShiftConfigFromPluginConfig() throws Exception { executeWithTempHomeDir(homeDir -> { createOpenShiftConfig(homeDir,"openshift_simple_config.yaml"); RegistryAuth config = handler.create(RegistryAuthConfig.Kind.PUSH, "roland", null, s -> s); verifyAuthConfig(config,"admin","token123",null); }); ...
FromConfigRegistryAuthHandler implements RegistryAuthHandler { @Override public RegistryAuth create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { if (registryAuthConfig.getUsername(kind) != null) { if (registryAuthConfig.getPassword(kind) == null) { throw new IllegalA...
@Test public void testFromPluginConfiguration() throws IOException { FromConfigRegistryAuthHandler handler = new FromConfigRegistryAuthHandler(setupAuthConfigFactoryWithConfigData(), log); RegistryAuth config = handler.create(RegistryAuthConfig.Kind.PUSH, null, null, s -> s); verifyAuthConfig(config, "roland", "secret"...
SystemPropertyRegistryAuthHandler implements RegistryAuthHandler { @Override public RegistryAuth create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String username = registryAuthConfig.extractFromProperties(props, kind, Reg...
@Test public void testEmpty() throws Exception { String userHome = System.getProperty("user.home"); try { File tempDir = Files.createTempDirectory("d-m-p").toFile(); System.setProperty("user.home", tempDir.getAbsolutePath()); assertEquals(handler.create(RegistryAuthConfig.Kind.PUSH, null, "blubberbla:1611", s->s), null...
DockerAccessWithHcClient implements DockerAccess { @Override public void saveImage(String image, String filename) throws DockerAccessException { ImageName name = new ImageName(image); String url = urlBuilder.getImage(name); try { delegate.get(url, getImageResponseHandler(filename), HTTP_OK); } catch (IOException e) { t...
@Test public void testSaveImage() throws IOException { givenAnImageName("test"); givenFilename("test.tar"); givenCompression(ArchiveCompression.none); whenSaveImage(); thenNoException(); }
DockerFileBuilder { public DockerFileBuilder maintainer(String maintainer) { this.maintainer = maintainer; return this; } DockerFileBuilder(); File write(File destDir); String content(); DockerFileBuilder baseImage(String baseImage); DockerFileBuilder maintainer(String maintainer); DockerFileBuilder workdir(String work...
@Test public void testMaintainer() { String dockerfileContent = new DockerFileBuilder().maintainer("maintainer@example.com").content(); assertThat(dockerfileToMap(dockerfileContent), hasEntry("MAINTAINER", "maintainer@example.com")); }
DockerFileBuilder { public DockerFileBuilder optimise() { this.shouldOptimise = true; return this; } DockerFileBuilder(); File write(File destDir); String content(); DockerFileBuilder baseImage(String baseImage); DockerFileBuilder maintainer(String maintainer); DockerFileBuilder workdir(String workdir); DockerFileBuild...
@Test public void testOptimise() { String dockerfileContent = new DockerFileBuilder().optimise().run(Arrays.asList("echo something", "echo two")).content(); assertThat(dockerfileToMap(dockerfileContent), hasEntry("RUN", "echo something && echo two")); }
DockerFileBuilder { public DockerFileBuilder user(String user) { this.user = user; return this; } DockerFileBuilder(); File write(File destDir); String content(); DockerFileBuilder baseImage(String baseImage); DockerFileBuilder maintainer(String maintainer); DockerFileBuilder workdir(String workdir); DockerFileBuilder ...
@Test public void testUser() { String dockerFile = new DockerFileBuilder().assemblyUser("jboss:jboss:jboss").user("bob") .add("a","a/nested").add("b","b/deeper/nested").content(); String EXPECTED_REGEXP = "USER bob$"; Pattern pattern = Pattern.compile(EXPECTED_REGEXP); assertTrue(pattern.matcher(dockerFile).find()); }
BuildConfiguration implements Serializable { public String validate() throws IllegalArgumentException { if (entryPoint != null) { entryPoint.validate(); } if (cmd != null) { cmd.validate(); } if (healthCheck != null) { healthCheck.validate(); } if ((dockerFile != null || contextDir != null) && dockerArchive != null) { ...
@Test public void dockerFileAndArchive() { BuildConfiguration config = new BuildConfiguration.Builder(). dockerArchive("this"). dockerFile("that").build(); try { config.validate(); } catch (IllegalArgumentException expected) { return; } fail("Should have failed."); }
BuildConfiguration implements Serializable { public ArchiveCompression getCompression() { return compression; } BuildConfiguration(); boolean isDockerFileMode(); String getDockerFile(); String getDockerArchive(); String getContextDir(); String getFilter(); String getFrom(); Map<String, String> getFromExt(); String getR...
@Test public void compression() { BuildConfiguration config = new BuildConfiguration.Builder(). compression("gzip").build(); assertEquals(gzip, config.getCompression()); config = new BuildConfiguration.Builder().build(); assertEquals(none, config.getCompression()); config = new BuildConfiguration.Builder(). compression...
BuildConfiguration implements Serializable { boolean isValidWindowsFileName(String filename) { Pattern pattern = Pattern.compile( "# Match a valid Windows filename (unspecified file system). \n" + "^ # Anchor to start of string. \n" + "(?! # Assert filename is not: CON, PRN, \n" + " (?: # AUX, NUL, COM1, COM2, COM3, CO...
@Test public void isValidWindowsFileName() { BuildConfiguration cfg = new BuildConfiguration(); assertFalse(cfg.isValidWindowsFileName("/Dockerfile")); assertTrue(cfg.isValidWindowsFileName("Dockerfile")); assertFalse(cfg.isValidWindowsFileName("Dockerfile/")); }
ImageName { public String getFullName() { return getFullName(null); } ImageName(String fullName); ImageName(String fullName, String givenTag); String getRepository(); String getRegistry(); String getTag(); boolean hasRegistry(); String getNameWithoutTag(); String getNameWithoutTag(String optionalRegistry); String getF...
@Test public void testRegistryNaming() throws Exception { assertEquals("docker.jolokia.org/jolokia/jolokia_demo:0.18", new ImageName("jolokia/jolokia_demo:0.18").getFullName("docker.jolokia.org")); assertEquals("docker.jolokia.org/jolokia/jolokia_demo:latest", new ImageName("jolokia/jolokia_demo").getFullName("docker.j...
EnricherFactory { List<Enricher<P>> createEnrichers(String... descriptorPaths) { try { EnricherEntry.initDefaultOrder(); TreeMap<EnricherEntry,Enricher<P>> enricherMap = new TreeMap<>(); for (String descriptor : descriptorPaths) { readEnricherDefinitions(enricherMap, descriptor); } ArrayList<Enricher<P>> ret = new Arra...
@Test public void testOrder() { List<Enricher<ProjectContext>> enrichers = enricherFactory.createEnrichers("enricher/test-enrichers-default", "enricher/test-enrichers"); String[] orderExpected = new String[] { "three", "two", "five", "one"}; assertEquals(enrichers.size(), 4); Iterator<Enricher<ProjectContext>> it = enr...
KeyStoreUtil { public static KeyStore createDockerKeyStore(String certPath) throws IOException, GeneralSecurityException { PrivateKey privKey = loadPrivateKey(certPath + "/key.pem"); Certificate[] certs = loadCertificates(certPath + "/cert.pem"); KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyS...
@Test public void createKeyStore() throws Exception { KeyStore keyStore = KeyStoreUtil.createDockerKeyStore(getFile("certpath")); KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry) keyStore.getEntry("docker", new KeyStore.PasswordProtection("docker".toCharArray())); assertNotNull(pkEntry); assertNotNull(pkEn...
KeyStoreUtil { static PrivateKey loadPrivateKey(String keyPath) throws IOException, GeneralSecurityException { try (Reader reader = new FileReader(keyPath); PEMParser parser = new PEMParser(reader)) { Object readObject; while ((readObject = parser.readObject()) != null) { if (readObject instanceof PEMKeyPair) { PEMKeyP...
@Test public void loadPrivateKeyDefault() throws Exception { PrivateKey privateKey = KeyStoreUtil.loadPrivateKey(getFile("keys/pkcs1.pem")); assertNotNull(privateKey); } @Test public void loadPrivateKeyPKCS8() throws Exception { PrivateKey privateKey = KeyStoreUtil.loadPrivateKey(getFile("keys/pkcs8.pem")); assertNotNu...
EcrExtendedAuth { public boolean isAwsRegistry() { return isAwsRegistry; } EcrExtendedAuth(KitLogger logger, String registry); boolean isAwsRegistry(); RegistryAuth extendedAuth(RegistryAuth localCredentials); }
@Test public void testIsNotAws() { assertFalse(new EcrExtendedAuth(logger, "jolokia").isAwsRegistry()); } @Test public void testIsAws() { assertTrue(new EcrExtendedAuth(logger, "123456789012.dkr.ecr.eu-west-1.amazonaws.com").isAwsRegistry()); }
ObjModel extends IndexedModel { protected static void parseInts(String str, int[] ints) { int len = str.length(); int intIndex = 0; int currentInt = -1; ints[0] = -1; ints[1] = -1; ints[2] = -1; for (int i = 0; i < len; i++) { char c = str.charAt(i); if (c >= '0' && c <= '9') { if (currentInt == -1) { currentInt = (c -...
@Test public void testParseInts() throws Exception { int[] ints = new int[4]; ObjModel.parseInts("1/2/3", ints); assertEquals(ints[0], 1); assertEquals(ints[1], 2); assertEquals(ints[2], 3); ObjModel.parseInts("111/222/333/444", ints); assertEquals(ints[0], 111); assertEquals(ints[1], 222); assertEquals(ints[2], 333); ...
SignatureConfig { public void write(Writer out) throws IOException { Ini configIni = new Ini(); Section section = configIni.add(SECTION_NAME); section.put("algorithm", algorithm.toString()); section.put("provider", provider); section.put("destination", destination.toString()); if (destinationTable != null) { section.pu...
@Test public void writeTest() throws Exception { File file = writeConfigToFile(config1); Ini expectedIni = getIni("config1.ini"); Ini actualIni = new Ini(file); assertThat("writing the ini file produces the correct configuration", expectedIni, equalTo(actualIni)); file = writeConfigToFile(config2); expectedIni = getIni...
SignedBatchWriter implements BatchWriter { @Override public void addMutation(Mutation mutation) throws MutationsRejectedException { Mutation signedMutation = new Mutation(mutation.getRow()); for (ColumnUpdate update : mutation.getUpdates()) { if (update.isDeleted()) { if (signatureConfig.destination == Destination.COLU...
@Test public void deleteExternalTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); when(mockConnector.createBatchWriter(SIG_TABLE, null)).thenReturn(mockSignatureWriter); BatchWriter writer = new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config3...
SignedBatchWriter implements BatchWriter { @Override public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException { for (Mutation mutation : iterable) { addMutation(mutation); } } SignedBatchWriter(Connector connector, String tableName, BatchWriterConfig batchConfig, SignatureConfig signature...
@Test public void addMutationsTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); BatchWriter writer = new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)); List<Mutation> mutations = new Array...
SignedBatchWriter implements BatchWriter { @Override public void flush() throws MutationsRejectedException { tableWriter.flush(); if (signatureTableWriter != null) { signatureTableWriter.flush(); } } SignedBatchWriter(Connector connector, String tableName, BatchWriterConfig batchConfig, SignatureConfig signatureConfig,...
@Test public void flushTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).flush(); verify(mockWriter).flush(); } @Test public void flushExt...
SignedBatchWriter implements BatchWriter { @Override public void close() throws MutationsRejectedException { tableWriter.close(); if (signatureTableWriter != null) { signatureTableWriter.close(); } } SignedBatchWriter(Connector connector, String tableName, BatchWriterConfig batchConfig, SignatureConfig signatureConfig,...
@Test public void closeTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).close(); verify(mockWriter).close(); } @Test public void closeExt...
EncryptedBatchScanner implements BatchScanner { @Override public void setRanges(Collection<Range> collection) { checkArgument(collection != null && collection.size() > 0, "ranges must be non null and contain at least 1 range"); List<Range> serverSideRanges = new ArrayList<>(); clientSideRanges = new ArrayList<>(); for ...
@Test public void setRangesException() throws Exception { BatchScanner scanner = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-key.ini"), KEYS); try { scanner.setRanges(null); fail("null ranges not allowed"); } catch (IllegalArgumentException e) { } try { scanner.setRanges(n...
EncryptedBatchScanner implements BatchScanner { @Override public void fetchColumnFamily(Text col) { checkArgument(col != null, "col is null"); ColumnFilterResult search = encryptor.getColumnFamilyFilter(col); for (Column filter : search.serverSideFilters) { scanner.fetchColumnFamily(new Text(filter.getColumnFamily()));...
@Test public void fetchColumnFamilyException() throws Exception { BatchScanner scanner = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-key.ini"), KEYS); try { scanner.fetchColumnFamily(null); fail("null column family not allowed"); } catch (IllegalArgumentException e) { } }
EncryptedBatchScanner implements BatchScanner { @Override public void fetchColumn(Text colFam, Text colQual) { checkArgument(colFam != null, "colFam is null"); checkArgument(colQual != null, "colQual is null"); ColumnFilterResult search = encryptor.getColumnFilter(colFam, colQual); for (Column column : search.serverSid...
@Test public void fetchColumnException() throws Exception { BatchScanner scanner = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-key.ini"), KEYS); try { scanner.fetchColumn(null); fail("null column not allowed"); } catch (IllegalArgumentException e) { } try { scanner.fetchCo...
EncryptedBatchScanner implements BatchScanner { @Override public void clearColumns() { scanner.clearColumns(); clientSideColumnFilters.clear(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer k...
@Test public void clearColumnsTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); EntryEncryptor encryptor = new EntryEncryptor(getConfig("encrypt-key.ini"), KEYS); List<Map.Entry<Key,Value>> entries = new ArrayList<>(); Map.Entry<Key,Value> entry = n...
SignedScanner implements Scanner { @Override public void clearScanIterators() { valueScanner.clearScanIterators(); if (signatureScanner != null) { signatureScanner.clearScanIterators(); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyC...
@Test public void clearScanIteratorsExternalTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockConnector.createScanner(SIG_TABLE, authorizations)).thenReturn(mockSignatureScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConf...
EncryptedBatchScanner implements BatchScanner { @Override public ItemProcessingIterator<Entry<Key,Value>> iterator() { return new EncryptedScannerIterator(scanner.iterator(), encryptor, clientSideRanges, clientSideColumnFilters); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizatio...
@Test public void iteratorTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); EntryEncryptor encryptor = new EntryEncryptor(getConfig("encrypt-value.ini"), KEYS); List<Map.Entry<Key,Value>> entries = new ArrayList<>(); Map.Entry<Key,Value> entry = new...
EncryptedBatchScanner implements BatchScanner { @Override public void clearScanIterators() { scanner.clearScanIterators(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); @Override void ...
@Test public void clearScanIteratorsTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).clearScanIterators(); verify(mockScanner).clearScanIt...
EncryptedBatchScanner implements BatchScanner { @Override public void close() { scanner.close(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); @Override void setRanges(Collection<Range...
@Test public void closeTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).close(); verify(mockScanner).close(); }
EncryptedBatchScanner implements BatchScanner { @Override public Authorizations getAuthorizations() { return scanner.getAuthorizations(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); ...
@Test public void getAuthorizationsTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); when(mockScanner.getAuthorizations()).thenReturn(authorizations); Authorizations auths = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, get...
EncryptedBatchScanner implements BatchScanner { @Override public void setSamplerConfiguration(SamplerConfiguration samplerConfiguration) { scanner.setSamplerConfiguration(samplerConfiguration); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionC...
@Test public void setSamplerConfigurationTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); SamplerConfiguration config = new SamplerConfiguration("test"); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-val...
EncryptedBatchScanner implements BatchScanner { @Override public SamplerConfiguration getSamplerConfiguration() { return scanner.getSamplerConfiguration(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKe...
@Test public void getSamplerConfigurationTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); SamplerConfiguration config = new SamplerConfiguration("test"); when(mockScanner.getSamplerConfiguration()).thenReturn(config); SamplerConfiguration value = n...
EncryptedBatchScanner implements BatchScanner { @Override public void clearSamplerConfiguration() { scanner.clearSamplerConfiguration(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); @...
@Test public void clearSamplerConfigurationTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).clearSamplerConfiguration(); verify(mockScanne...
EncryptedBatchScanner implements BatchScanner { @Override public void setBatchTimeout(long l, TimeUnit timeUnit) { scanner.setBatchTimeout(l, timeUnit); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyCo...
@Test public void setBatchTimeoutTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).setBatchTimeout(5L, TimeUnit.DAYS); verify(mockScanner)....
EncryptedBatchScanner implements BatchScanner { @Override public long getBatchTimeout(TimeUnit timeUnit) { return scanner.getBatchTimeout(timeUnit); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContai...
@Test public void getBatchTimeoutTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); when(mockScanner.getBatchTimeout(TimeUnit.DAYS)).thenReturn(5L); long value = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encry...
EncryptedBatchScanner implements BatchScanner { @Override public void setClassLoaderContext(String s) { scanner.setClassLoaderContext(s); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); ...
@Test public void setClassLoaderContextTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).setClassLoaderContext("test"); verify(mockScanner)...
SignedScanner implements Scanner { @Override public void close() { valueScanner.close(); if (signatureScanner != null) { signatureScanner.close(); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessin...
@Test public void closeTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).close(); verify(mockScanner).close(); } @Test public...
EncryptedBatchScanner implements BatchScanner { @Override public void clearClassLoaderContext() { scanner.clearClassLoaderContext(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); @Over...
@Test public void clearClassLoaderContextTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).clearClassLoaderContext(); verify(mockScanner).c...
EncryptedBatchScanner implements BatchScanner { @Override public String getClassLoaderContext() { return scanner.getClassLoaderContext(); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); ...
@Test public void getClassLoaderContextTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); when(mockScanner.getClassLoaderContext()).thenReturn("test"); String value = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("...
EncryptedBatchScanner implements BatchScanner { @Override public void addScanIterator(IteratorSetting iteratorSetting) { scanner.addScanIterator(iteratorSetting); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, Encry...
@Test public void addScanIteratorTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); IteratorSetting test = new IteratorSetting(10, "test", "test2"); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"...
EncryptedBatchScanner implements BatchScanner { @Override public void removeScanIterator(String s) { scanner.removeScanIterator(s); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); @Overr...
@Test public void removeScanIteratorTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).removeScanIterator("test"); verify(mockScanner).remov...
EncryptedBatchScanner implements BatchScanner { @Override public void updateScanIteratorOption(String s, String s1, String s2) { scanner.updateScanIteratorOption(s, s1, s2); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, ...
@Test public void updateScanIteratorOptionTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).updateScanIteratorOption("test", "a", "b"); ver...
EncryptedBatchScanner implements BatchScanner { @Override public void setTimeout(long l, TimeUnit timeUnit) { scanner.setTimeout(l, timeUnit); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer ke...
@Test public void setTimeoutTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.ini"), KEYS).setTimeout(5L, TimeUnit.DAYS); verify(mockScanner).setTimeout...
EncryptedBatchScanner implements BatchScanner { @Override public long getTimeout(TimeUnit timeUnit) { return scanner.getTimeout(timeUnit); } EncryptedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys);...
@Test public void getTimeoutTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); when(mockScanner.getTimeout(TimeUnit.DAYS)).thenReturn(5L); Long value = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-value.i...
EncryptedBatchWriter implements BatchWriter { @Override public void addMutation(Mutation mutation) throws MutationsRejectedException { for (ColumnUpdate update : mutation.getUpdates()) { MutableEntry entry = new MutableEntry(mutation.getRow(), update); if (update.isDeleted()) { if (!supportsDelete) { throw new IllegalA...
@Test public void addMutationTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); BatchWriter writer = new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("encrypt-value.ini"), KEYS); EntryEncryptor encryptor = new EntryEncryptor(getConfig("encrypt-va...
EncryptedBatchWriter implements BatchWriter { @Override public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException { for (Mutation mutation : iterable) { addMutation(mutation); } } EncryptedBatchWriter(Connector connector, String tableName, BatchWriterConfig batchConfig, EncryptionConfig cr...
@Test public void addMutationsTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); BatchWriter writer = new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("encrypt-value.ini"), KEYS); List<Mutation> mutations = new ArrayList<>(); Mutation mutation = ...
EncryptedBatchWriter implements BatchWriter { @Override public void flush() throws MutationsRejectedException { writer.flush(); } EncryptedBatchWriter(Connector connector, String tableName, BatchWriterConfig batchConfig, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); @Override void addMutation(Mutation mu...
@Test public void flushTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("encrypt-value.ini"), KEYS).flush(); verify(mockWriter).flush(); }
EncryptedBatchWriter implements BatchWriter { @Override public void close() throws MutationsRejectedException { writer.close(); } EncryptedBatchWriter(Connector connector, String tableName, BatchWriterConfig batchConfig, EncryptionConfig cryptoConfig, EncryptionKeyContainer keys); @Override void addMutation(Mutation mu...
@Test public void closeTest() throws Exception { when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter); new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("encrypt-value.ini"), KEYS).close(); verify(mockWriter).close(); }
EncryptionConfig { public void write(Writer out) throws IOException { Ini configIni = new Ini(); for (FieldEncryptorConfig config : fieldEncryptorConfigs) { config.write(configIni); } configIni.store(out); } EncryptionConfig(List<FieldEncryptorConfig> fieldEncryptorConfigs); void write(Writer out); }
@Test public void writeTest() throws IOException { File iniFile = testFolder.newFile(); FileWriter out = new FileWriter(iniFile); config1.write(out); out.close(); Ini actual = new Ini(new FileReader(iniFile)); Ini expected = getIni("config1.ini"); assertThat("reading the ini produces the correct configuration", actual,...
EncryptedScannerIterator implements ItemProcessingIterator<Entry<Key,Value>> { @Override public boolean hasNext() { if (next == null) { advance(); } return next != null; } EncryptedScannerIterator(Iterator<Entry<Key,Value>> iterator, EntryEncryptor encryptor, List<Range> clientSideRanges, SortedSet<Column> client...
@Test public void hasNextTest() throws Exception { EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS); List<Entry<Key,Value>> entries = new ArrayList<>(); Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(Util...
EncryptedScannerIterator implements ItemProcessingIterator<Entry<Key,Value>> { @Override public Entry<Key,Value> next() { if (next == null) { advance(); } if (next == null) { throw new NoSuchElementException(); } Entry<Key,Value> value = next; next = null; return value; } EncryptedScannerIterator(Iterator<Entry<Key,Val...
@Test public void nextTest() throws Exception { EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS); List<Entry<Key,Value>> entries = new ArrayList<>(); Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(Utils.V...
EncryptedScannerIterator implements ItemProcessingIterator<Entry<Key,Value>> { @Override public Entry<Key,Value> unprocessed() { if (next != null || unprocessedEntry == null) { throw new NoSuchElementException(); } return unprocessedEntry; } EncryptedScannerIterator(Iterator<Entry<Key,Value>> iterator, EntryEncryptor e...
@Test public void unprocessedTest() throws Exception { EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS); List<Entry<Key,Value>> entries = new ArrayList<>(); Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(...
EncryptedScannerIterator implements ItemProcessingIterator<Entry<Key,Value>> { @Override public void remove() { throw new UnsupportedOperationException(); } EncryptedScannerIterator(Iterator<Entry<Key,Value>> iterator, EntryEncryptor encryptor, List<Range> clientSideRanges, SortedSet<Column> clientSideColumnFilte...
@Test public void removeException() throws Exception { EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS); List<Entry<Key,Value>> entries = new ArrayList<>(); Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(...
SignedScanner implements Scanner { @Override public void fetchColumn(Column column) { valueScanner.fetchColumn(column); if (signatureScanner != null) { signatureScanner.fetchColumn(column); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, Signature...
@Test public void fetchColumnTest() throws Exception { Column column = new Column(new Text(new byte[] {1}), new Text(new byte[] {2})); when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyCon...
EntryEncryptor { public boolean canBeDeleteServerSide() { for (EntryField field : FieldEncryptorConfig.KEY_DESTINATION_FIELDS) { if (destinationMap.containsKey(field) && !destinationMap.get(field).canBeFilteredServerSide(FieldEncryptorConfig.KEY_SOURCE_FIELDS)) { return false; } } return true; } EntryEncryptor(Encrypti...
@Test public void canBeDeletedServerSideTest() throws Exception { assertThat("non-encrypted key can be updated", getEncryptor("encrypt-value.ini").canBeDeleteServerSide(), is(true)); assertThat("non-deterministically encrypted key cannot be updated", getEncryptor("encrypt-entry.ini").canBeDeleteServerSide(), is(false))...
EntryEncryptor { public Collection<Key> getDeleteKeys(Key key) { checkArgument(canBeDeleteServerSide(), "canBeDeleteServerSide is false"); checkArgument(key != null, "key is null"); MutableEntry searchKey = new MutableEntry(key); Collection<byte[]> rowValues = getDeleteValues(searchKey, EntryField.ROW); Collection<byte...
@Test public void getDeleteKeysTest() throws Exception { EntryEncryptor encryptor = getEncryptor("deterministic.ini"); MutableEntry searchKey = new MutableEntry(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(VISIBILITY_CHARSET), (long) 5, false)); Collection<Key> keys = encryptor.getDeleteKey...
EntryEncryptor { public ColumnFilterResult getColumnFamilyFilter(Text col) { checkArgument(col != null, "col is null"); MutableEntry key = new MutableEntry(); key.colF = TextUtil.getBytes(col); return getColumnFamilyFilter(key, ImmutableSet.of(EntryField.COLUMN_FAMILY)); } EntryEncryptor(EncryptionConfig config, Encryp...
@Test public void getColumnFamilyFilterTest() throws Exception { byte[] columnFamily = new byte[] {2}; ColumnFilterResult result = getEncryptor("encrypt-value.ini").getColumnFamilyFilter(new Text(columnFamily)); assertThat("unencrypted column is searchable server side", result.serverSideFilters, hasSize(1)); assertThat...
EntryEncryptor { public ColumnFilterResult getColumnFilter(Text colFam, Text colQual) { checkArgument(colFam != null, "colFam is null"); checkArgument(colQual != null, "colQual is null"); Set<EntryField> fields = ImmutableSet.of(EntryField.COLUMN_FAMILY, EntryField.COLUMN_QUALIFIER); MutableEntry key = new MutableEntry...
@Test public void getColumnFilterTest() throws Exception { byte[] columnFamily = new byte[] {2}; byte[] columnQualifier = new byte[] {3}; ColumnFilterResult result = getEncryptor("encrypt-value.ini").getColumnFilter(new Text(columnFamily), new Text(columnQualifier)); assertThat("unencrypted column is searchable server ...
EntryEncryptor { public boolean transformRange(Range range, Collection<Range> serverSideRanges) { checkArgument(range != null, "range is null"); checkArgument(serverSideRanges != null, "serverSideRanges is null"); if (destinationMap.size() == 1 && destinationMap.containsKey(EntryField.VALUE)) { serverSideRanges.add(ran...
@Test public void transformRangeTest() throws Exception { Range range = new Range("A"); Collection<Range> serverSideRanges = new ArrayList<>(); boolean result = getEncryptor("encrypt-value.ini", keys).transformRange(range, serverSideRanges); assertThat("should be filtered server side", serverSideRanges, hasSize(1)); as...
FieldEncryptorConfig { void write(Ini configIni) { Section section = configIni.add(destination.toString()); section.put("cipher", valueEncryptor.toString()); section.put("provider", provider); section.put("useVisibility", encryptUsingVisibility); section.put("keyId", keyId); section.put("keyLength", Integer.toString(ke...
@Test public void writeTest() throws IOException { FieldEncryptorConfig config = new FieldEncryptorConfigBuilder().setValueEncryptor(ValueEncryptor.AES_CBC).setProvider("SunJCE").setKeyLength(24) .setEncryptUsingVisibility(false).setKeyId("keyId").setDestination(EntryField.COLUMN_FAMILY) .setSources(ImmutableSortedSet....
FieldEncryptor { void encrypt(MutableEntry entry, MutableEntry result, ColumnVisibility columnVisibility) throws IOException { byte[] data = concatData(entry); ByteArrayOutputStream ciphertextStream = new ByteArrayOutputStream(); DataOutput ciphertextOut = new DataOutputStream(ciphertextStream); byte[] key = getKey(col...
@Test public void encryptTest() throws Exception { MutableEntry original = new MutableEntry(new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(VISIBILITY_CHARSET), (long) 5, false), new Value(new byte[] {6}))); MutableEntry empty = new MutableEntry(); ColumnVisibility v...
FieldEncryptor { boolean canBeFilteredServerSide(Collection<EntryField> availableSources) { return config.valueEncryptor.isDeterministic() && availableSources.containsAll(config.sources); } FieldEncryptor(FieldEncryptorConfig config, EncryptionKeyContainer keys); }
@Test public void canBeFilteredServerSideTest() throws Exception { assertThat("non-deterministic algorithms can't be filtered server side", getEncryptor("gcm.ini").canBeFilteredServerSide(ImmutableSet.of(EntryField.ROW)), is(false)); assertThat("Visibility can't be filtered server side", getEncryptor("gcmCEABAC.ini").c...
FieldEncryptor { boolean canSearchFor(Set<EntryField> fields) { return config.valueEncryptor.isDeterministic() && fields.equals(config.sources); } FieldEncryptor(FieldEncryptorConfig config, EncryptionKeyContainer keys); }
@Test public void canSearchForTest() throws Exception { assertThat("non-deterministic algorithms can't be searched server side", getEncryptor("gcm.ini").canSearchFor(ImmutableSet.of(EntryField.ROW)), is(false)); assertThat("Visibility can't be filtered server side", getEncryptor("gcmCEABAC.ini").canSearchFor(ImmutableS...
FieldEncryptor { List<byte[]> getServerSideFilterValues(MutableEntry key) { return getServerSideFilterValues(key, false); } FieldEncryptor(FieldEncryptorConfig config, EncryptionKeyContainer keys); }
@Test public void getServerSideFilterValuesTest() throws Exception { MutableEntry original = new MutableEntry(new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(VISIBILITY_CHARSET), (long) 5, false), new Value(new byte[] {6}))); ColumnVisibility visibility = new ColumnV...
MutableEntry implements Cloneable { public Key toKey() { return new Key(row, colF, colQ, colVis, timestamp, delete, false); } MutableEntry(); MutableEntry(Key key); MutableEntry(Map.Entry<Key,Value> entry); MutableEntry(byte[] row, ColumnUpdate update); Key toKey(); Map.Entry<Key,Value> toEntry(); MutableEntry clone...
@Test public void toKeyTest() { MutableEntry mutableKey = new MutableEntry(key); assertThat("returned key should be the same as the original key", mutableKey.toKey(), is(equalTo(key))); }
MutableEntry implements Cloneable { public Map.Entry<Key,Value> toEntry() { return new AbstractMap.SimpleImmutableEntry<>(toKey(), new Value(value, false)); } MutableEntry(); MutableEntry(Key key); MutableEntry(Map.Entry<Key,Value> entry); MutableEntry(byte[] row, ColumnUpdate update); Key toKey(); Map.Entry<Key,Val...
@Test public void toEntryTest() { MutableEntry mutableEntry = new MutableEntry(entry); assertThat("returned entry should be the same as the original entry", mutableEntry.toEntry(), is(equalTo(entry))); }
MutableEntry implements Cloneable { public byte[] getBytes(EntryField field) { switch (field) { case ROW: return row; case COLUMN_FAMILY: return colF; case COLUMN_QUALIFIER: return colQ; case COLUMN_VISIBILITY: return colVis; case VALUE: return value; default: throw new IllegalArgumentException("invalid field"); } } Mu...
@Test public void getBytesTest() { MutableEntry mutableEntry = new MutableEntry(entry); assertThat("correct bytes returned", mutableEntry.getBytes(EntryField.ROW), is(equalTo(row))); assertThat("correct bytes returned", mutableEntry.getBytes(EntryField.COLUMN_FAMILY), is(equalTo(colF))); assertThat("correct bytes retur...
MutableEntry implements Cloneable { public void setBytes(EntryField field, byte[] bytes) { switch (field) { case ROW: row = bytes; break; case COLUMN_FAMILY: colF = bytes; break; case COLUMN_QUALIFIER: colQ = bytes; break; case COLUMN_VISIBILITY: colVis = bytes; break; case VALUE: value = bytes; break; default: throw n...
@Test(expected = IllegalArgumentException.class) public void setBytesException() { MutableEntry mutableEntry = new MutableEntry(entry); mutableEntry.setBytes(EntryField.TIMESTAMP, EMPTY); }
Utils { public static byte[] xor(byte[] first, byte[] second) { checkArgument(first != null, "first is null"); checkArgument(second != null, "second is null"); checkArgument(first.length == second.length, "first and second must be the same length"); for (int i = 0; i < first.length; i++) { first[i] = (byte) (first[i] ^...
@Test public void xorTest() { byte[] first = new byte[] {0, 1, 2}; byte[] second = new byte[] {0, 1, 1}; byte[] result = Utils.xor(first, second); assertThat("the return value is the same as the first argument", result == first, is(true)); assertThat("the correct result was achieved", result, is(equalTo(new byte[] {0, ...
SignedScanner implements Scanner { @Override public void fetchColumnFamily(Text col) { valueScanner.fetchColumnFamily(col); if (signatureScanner != null) { signatureScanner.fetchColumnFamily(col); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, Si...
@Test public void fetchColumnFamilyTest() throws Exception { Text colF = new Text(new byte[] {1}); when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).fe...
SignedScanner implements Scanner { @Override public Authorizations getAuthorizations() { return valueScanner.getAuthorizations(); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessingIterator<Entry<Key...
@Test public void getAuthorizationsTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockScanner.getAuthorizations()).thenReturn(authorizations); Authorizations auths = new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini...
SignatureConfig { public ValueSigner getAlgorithm() { return this.algorithm; } SignatureConfig(ValueSigner signer, String provider, Destination destination, String destinationTable, byte[] defaultVisibility); void write(Writer out); boolean isSignatureInSeparateTable(); ValueSigner getAlgorithm(); }
@Test public void getAlgorithmTest() { assertThat("correct algorithm", config1.getAlgorithm(), Matchers.equalTo(config1.algorithm)); assertThat("correct algorithm", config2.getAlgorithm(), Matchers.equalTo(config2.algorithm)); assertThat("correct algorithm", config3.getAlgorithm(), Matchers.equalTo(config3.algorithm));...
SignedScanner implements Scanner { @Override public SamplerConfiguration getSamplerConfiguration() { return valueScanner.getSamplerConfiguration(); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessing...
@Test public void getSamplerConfigurationTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); SamplerConfiguration config = new SamplerConfiguration("test"); when(mockScanner.getSamplerConfiguration()).thenReturn(config); SamplerConfiguration value = new Signe...
SignedScanner implements Scanner { @Override public void setSamplerConfiguration(SamplerConfiguration samplerConfiguration) { valueScanner.setSamplerConfiguration(samplerConfiguration); if (signatureScanner != null) { signatureScanner.setSamplerConfiguration(samplerConfiguration); } } SignedScanner(Connector connector,...
@Test public void setSamplerConfigurationTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); SamplerConfiguration config = new SamplerConfiguration("test"); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContain...
SignedScanner implements Scanner { @Override public void clearSamplerConfiguration() { valueScanner.clearSamplerConfiguration(); if (signatureScanner != null) { signatureScanner.clearSamplerConfiguration(); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signature...
@Test public void clearSamplerConfigurationTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)) .clearSamplerConfiguration(); ve...
SignedScanner implements Scanner { @Override public void setBatchTimeout(long l, TimeUnit timeUnit) { valueScanner.setBatchTimeout(l, timeUnit); if (signatureScanner != null) { signatureScanner.setBatchTimeout(l, timeUnit); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, Signatur...
@Test public void setBatchTimeoutTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).setBatchTimeout(5L, TimeUnit.DAYS); verify...
SignedScanner implements Scanner { @Override public long getBatchTimeout(TimeUnit timeUnit) { return valueScanner.getBatchTimeout(timeUnit); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessingIterato...
@Test public void getBatchTimeoutTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockScanner.getBatchTimeout(TimeUnit.DAYS)).thenReturn(5L); long value = new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyC...
SignedScanner implements Scanner { @Override public void setClassLoaderContext(String s) { valueScanner.setClassLoaderContext(s); if (signatureScanner != null) { signatureScanner.setClassLoaderContext(s); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureCo...
@Test public void setClassLoaderContextTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)) .setClassLoaderContext("test"); veri...
SignatureConfig { public boolean isSignatureInSeparateTable() { return this.destination == Destination.SEPARATE_TABLE; } SignatureConfig(ValueSigner signer, String provider, Destination destination, String destinationTable, byte[] defaultVisibility); void write(Writer out); boolean isSignatureInSeparateTable(); ValueSi...
@Test public void isSignatureInSeparateTableTest() { assertThat("correct return value", config1.isSignatureInSeparateTable(), is(false)); assertThat("correct return value", config2.isSignatureInSeparateTable(), is(false)); assertThat("correct return value", config3.isSignatureInSeparateTable(), is(true)); }
SignedScanner implements Scanner { @Override public void clearClassLoaderContext() { valueScanner.clearClassLoaderContext(); if (signatureScanner != null) { signatureScanner.clearClassLoaderContext(); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig...
@Test public void clearClassLoaderContextTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)) .clearClassLoaderContext(); verify...
SignedScanner implements Scanner { @Override public String getClassLoaderContext() { return valueScanner.getClassLoaderContext(); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessingIterator<Entry<Key...
@Test public void getClassLoaderContextTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockScanner.getClassLoaderContext()).thenReturn("test"); String value = new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), alic...
SignedScanner implements Scanner { @Override public long getTimeout(TimeUnit timeUnit) { return valueScanner.getTimeout(timeUnit); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessingIterator<Entry<Ke...
@Test public void getTimeoutTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockScanner.getTimeout(TimeUnit.DAYS)).thenReturn(5L); Long value = new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers....
SignedScanner implements Scanner { @Override public void removeScanIterator(String iteratorName) { valueScanner.removeScanIterator(iteratorName); if (signatureScanner != null) { signatureScanner.removeScanIterator(iteratorName); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, Sig...
@Test public void removeScanIteratorTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)) .removeScanIterator("test"); verify(moc...
SignedScanner implements Scanner { @Override public void updateScanIteratorOption(String iteratorName, String key, String value) { valueScanner.updateScanIteratorOption(iteratorName, key, value); if (signatureScanner != null) { signatureScanner.updateScanIteratorOption(iteratorName, key, value); } } SignedScanner(Conne...
@Test public void updateScanIteratorOptionTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)) .updateScanIteratorOption("test",...
SignedScanner implements Scanner { @Override public void setTimeout(long timeout, TimeUnit timeUnit) { valueScanner.setTimeout(timeout, timeUnit); if (signatureScanner != null) { signatureScanner.setTimeout(timeout, timeUnit); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, Signa...
@Test public void setTimeoutTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).setTimeout(5L, TimeUnit.DAYS); verify(mockScann...
SignedScanner implements Scanner { @Override public ItemProcessingIterator<Entry<Key,Value>> iterator() { if (signatureScanner != null) { return new SignedExternalScannerIterator(valueScanner.iterator(), signatureScanner.iterator(), verifier, true); } else { return new SignedInlineScannerIterator(valueScanner.iterator(...
@Test public void iteratorTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); EntrySigner signer = new EntrySigner(getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)); List<Entry<Key,Value>> entries = new ArrayList<>(); Map.Entry<Key,Value>...
SignedScanner implements Scanner { @Override public void disableIsolation() { valueScanner.disableIsolation(); if (signatureScanner != null) { signatureScanner.disableIsolation(); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContain...
@Test public void disableIsolationTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).disableIsolation(); verify(mockScanner).d...
SignedScanner implements Scanner { @Override public void enableIsolation() { valueScanner.enableIsolation(); if (signatureScanner != null) { signatureScanner.enableIsolation(); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer ...
@Test public void enableIsolationTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).enableIsolation(); verify(mockScanner).ena...
SignedScanner implements Scanner { @Override public void setBatchSize(int size) { valueScanner.setBatchSize(size); if (signatureScanner != null) { signatureScanner.setBatchSize(size); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyCon...
@Test public void setBatchSizeTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).setBatchSize(5); verify(mockScanner).setBatch...
SignedScanner implements Scanner { @Override public int getBatchSize() { return valueScanner.getBatchSize(); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessingIterator<Entry<Key,Value>> iterator(); ...
@Test public void getBatchSizeTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockScanner.getBatchSize()).thenReturn(5); int value = new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSi...
SignedScanner implements Scanner { @Override public void setRange(Range range) { valueScanner.setRange(range); if (signatureScanner != null) { signatureScanner.setRange(range); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer ...
@Test public void setRangeTest() throws Exception { Range range = new Range("test"); when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).setRange(range);...
SignedScanner implements Scanner { @Override public Range getRange() { return valueScanner.getRange(); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessingIterator<Entry<Key,Value>> iterator(); @Overr...
@Test public void getRangeTest() throws Exception { Range range = new Range("test"); when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockScanner.getRange()).thenReturn(range); Range value = new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"),...
SignedScanner implements Scanner { @Override public void setReadaheadThreshold(long batches) { valueScanner.setReadaheadThreshold(batches); if (signatureScanner != null) { signatureScanner.setReadaheadThreshold(batches); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureCo...
@Test public void setReadaheadThresholdTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)) .setReadaheadThreshold(5L); verify(m...
SignedScanner implements Scanner { @Override public long getReadaheadThreshold() { return valueScanner.getReadaheadThreshold(); } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys); @Override ItemProcessingIterator<Entry<Key,V...
@Test public void getReadaheadThresholdTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); when(mockScanner.getReadaheadThreshold()).thenReturn(5L); long value = new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyCo...
SignedBatchScanner implements BatchScanner { @Override public ItemProcessingIterator<Entry<Key,Value>> iterator() { if (signatureScanner != null) { return new SignedExternalScannerIterator(valueScanner.iterator(), signatureScanner.iterator(), verifier, false); } else { return new SignedInlineScannerIterator(valueScanne...
@Test public void iteratorTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); EntrySigner signer = new EntrySigner(getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)); List<Entry<Key,Value>> entries = new ArrayList<>(); Entry<Key,Va...
SignedBatchScanner implements BatchScanner { @Override public void addScanIterator(IteratorSetting cfg) { valueScanner.addScanIterator(cfg); if (signatureScanner != null) { signatureScanner.addScanIterator(cfg); } } SignedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThr...
@Test public void addScanIteratorTest() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); IteratorSetting test = new IteratorSetting(10, "test", "test2"); new SignedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("config1.ini"), aliceK...
SignedScanner implements Scanner { @Override public void addScanIterator(IteratorSetting cfg) { valueScanner.addScanIterator(cfg); if (signatureScanner != null) { signatureScanner.addScanIterator(cfg); } } SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfi...
@Test public void addScanIteratorTest() throws Exception { when(mockConnector.createScanner(TEST_TABLE, authorizations)).thenReturn(mockScanner); IteratorSetting test = new IteratorSetting(10, "test", "test2"); new SignedScanner(mockConnector, TEST_TABLE, authorizations, getConfig("config1.ini"), aliceKeyContainers.get...
SignedBatchScanner implements BatchScanner { @Override public void clearColumns() { valueScanner.clearColumns(); if (signatureScanner != null) { signatureScanner.clearColumns(); } } SignedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, SignatureConfig signatureCon...
@Test public void clearColumns() throws Exception { when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner); new SignedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS)).clearColumns(); verify(mockScanne...