use of io.fabric8.kubernetes.api.model.rbac.Subject in project fabric8 by jboss-fuse.
the class MavenProxySnapshotResolutionTest method snapshotIsAvailableInRemoteRepositoryInNewerVersionUpdateAlways.
@Test
public void snapshotIsAvailableInRemoteRepositoryInNewerVersionUpdateAlways() throws IOException, InvalidMavenArtifactRequest {
File differentLocalRepository = initFileRepository("dlr");
File remoteRepository = initFileRepository("rr");
MavenResolver resolver = new ResolverBuilder().withRemoteRepositories(Collections.singletonList(remoteRepository)).withUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS).build();
MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
servlet.start();
mvnDeploy(differentLocalRepository, remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("11:00"), "a");
// first resolution
servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-20170101.110000-1.jar");
mvnDeploy(differentLocalRepository, remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("12:00"), "b");
// second resolution, subject to update policy
File file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
Metadata metadata = readMetadata(file);
assertThat("Policy forces fetching changed metadata", metadata.getVersioning().getSnapshotVersions().get(0).getVersion(), is("0.1.0-20170101.120000-2"));
assertTrue(new File(localRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-20170101.110000-1.jar").isFile());
assertFalse(new File(localRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-20170101.120000-2.jar").isFile());
assertTrue(new File(remoteRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-20170101.110000-1.jar").isFile());
assertTrue(new File(remoteRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-20170101.120000-2.jar").isFile());
}
use of io.fabric8.kubernetes.api.model.rbac.Subject in project fabric8 by jboss-fuse.
the class MavenProxySnapshotResolutionTest method snapshotIsAvailableInRemoteRepositoryInNewerVersion.
@Test
public void snapshotIsAvailableInRemoteRepositoryInNewerVersion() throws IOException, InvalidMavenArtifactRequest {
File differentLocalRepository = initFileRepository("dlr");
File remoteRepository = initFileRepository("rr");
MavenResolver resolver = new ResolverBuilder().withRemoteRepositories(Collections.singletonList(remoteRepository)).withUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_DAILY).build();
MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
servlet.start();
mvnDeploy(differentLocalRepository, remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("11:00"), "a");
// first resolution
servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-20170101.110000-1.jar");
mvnDeploy(differentLocalRepository, remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("12:00"), "b");
// second resolution, subject to update policy
File file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
Metadata metadata = readMetadata(file);
assertThat("Policy prevents from fetching changed metadata", metadata.getVersioning().getSnapshotVersions().get(0).getVersion(), is("0.1.0-20170101.110000-1"));
assertTrue(new File(localRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-20170101.110000-1.jar").isFile());
assertFalse(new File(localRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-20170101.120000-2.jar").isFile());
assertTrue(new File(remoteRepository, "io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/universalis-api-0.1.0-20170101.120000-2.jar").isFile());
}
use of io.fabric8.kubernetes.api.model.rbac.Subject in project syndesis-qe by syndesisio.
the class Jaeger method processResources.
private void processResources() {
for (String jaegerResource : JAEGER_RESOURCES) {
// version 1.20.0 ==> repo v1.20.0
jaegerResource = String.format(jaegerResource, "v" + TestConfiguration.jaegerVersion());
log.info("Processing " + jaegerResource);
try (InputStream is = new URL(jaegerResource).openStream()) {
List<HasMetadata> resources = OpenShiftUtils.getInstance().load(is).get();
// Change the namespace in the resources to the current
for (HasMetadata resource : resources) {
if (resource instanceof ClusterRoleBinding) {
for (Subject subject : ((ClusterRoleBinding) resource).getSubjects()) {
subject.setNamespace(TestConfiguration.openShiftNamespace());
}
}
resource.getMetadata().setNamespace(TestConfiguration.openShiftNamespace());
processedResources.add(resource);
// change docker image to quay
if (resource instanceof Deployment) {
((Deployment) resource).getSpec().getTemplate().getSpec().getContainers().get(0).setImage("quay.io/jaegertracing/jaeger-operator:" + TestConfiguration.jaegerVersion());
}
}
} catch (IOException e) {
fail("Unable to process Jaeger resource " + jaegerResource, e);
}
}
}
use of io.fabric8.kubernetes.api.model.rbac.Subject in project strimzi by strimzi.
the class Ca method generateSignedCert.
/**
* Generates a certificate signed by this CA
*
* @param commonName The CN of the certificate to be generated.
* @param organization The O of the certificate to be generated. May be null.
* @return The CertAndKey
* @throws IOException If the cert could not be generated.
*/
public CertAndKey generateSignedCert(String commonName, String organization) throws IOException {
File csrFile = File.createTempFile("tls", "csr");
File keyFile = File.createTempFile("tls", "key");
File certFile = File.createTempFile("tls", "cert");
File keyStoreFile = File.createTempFile("tls", "p12");
Subject.Builder subject = new Subject.Builder();
if (organization != null) {
subject.withOrganizationName(organization);
}
subject.withCommonName(commonName);
CertAndKey result = generateSignedCert(subject.build(), csrFile, keyFile, certFile, keyStoreFile);
delete(reconciliation, csrFile);
delete(reconciliation, keyFile);
delete(reconciliation, certFile);
delete(reconciliation, keyStoreFile);
return result;
}
use of io.fabric8.kubernetes.api.model.rbac.Subject in project strimzi by strimzi.
the class Ca method getSubjectAltNames.
/**
* Extracts the alternate subject names out of existing certificate
*
* @param certificate Existing X509 certificate as a byte array
* @return
*/
protected List<String> getSubjectAltNames(byte[] certificate) {
List<String> subjectAltNames = null;
try {
X509Certificate cert = x509Certificate(certificate);
Collection<List<?>> altNames = cert.getSubjectAlternativeNames();
subjectAltNames = altNames.stream().filter(name -> name.get(1) instanceof String).map(item -> (String) item.get(1)).collect(Collectors.toList());
} catch (CertificateException | RuntimeException e) {
// TODO: We should mock the certificates properly so that this doesn't fail in tests (not now => long term :-o)
LOGGER.debugCr(reconciliation, "Failed to parse existing certificate", e);
}
return subjectAltNames;
}
Aggregations