io.fabric8.openshift.client.server.mock.OpenShiftMockServer Java Examples

The following examples show how to use io.fabric8.openshift.client.server.mock.OpenShiftMockServer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testSuccessfulBuild() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig config = defaultConfig.build();
        // @formatter:off
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = config;
        }};
        // @formatter:on
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, false, false);
        OpenShiftMockServer mockServer = collector.getMockServer();

        DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
        LOG.info("Current write timeout is : {}", client.getHttpClient().writeTimeoutMillis());
        LOG.info("Current read timeout is : {}", client.getHttpClient().readTimeoutMillis());
        LOG.info("Retry on failure : {}", client.getHttpClient().retryOnConnectionFailure());
        OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
        service.build(image);

        // we should Foadd a better way to assert that a certain call has been made
        assertTrue(mockServer.getRequestCount() > 8);
        collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
        assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}", collector.getBodies().get(1));
        collector.assertEventsNotRecorded("patch-build-config");
    });
}
 
Example #2
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testSuccessfulBuildSecret() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig config = defaultConfigSecret.build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = config;
        }};
        // @formatter:off
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, false, false);
        OpenShiftMockServer mockServer = collector.getMockServer();

        DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
        LOG.info("Current write timeout is : {}", client.getHttpClient().writeTimeoutMillis());
        LOG.info("Current read timeout is : {}", client.getHttpClient().readTimeoutMillis());
        LOG.info("Retry on failure : {}", client.getHttpClient().retryOnConnectionFailure());
        OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
        service.build(image);

        // we should Foadd a better way to assert that a certain call has been made
        assertTrue(mockServer.getRequestCount() > 8);
        collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
        collector.assertEventsNotRecorded("patch-build-config");
    });
}
 
Example #3
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testSuccessfulSecondBuild() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig config = defaultConfig.build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = config;
        }};
        // @formatter:off
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, true, true);
        OpenShiftMockServer mockServer = collector.getMockServer();

        OpenShiftClient client = mockServer.createOpenShiftClient();
        OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
        service.build(image);

        assertTrue(mockServer.getRequestCount() > 8);
        collector.assertEventsRecordedInOrder("build-config-check", "patch-build-config", "pushed");
        collector.assertEventsNotRecorded("new-build-config");
    });
}
 
Example #4
Source File: PatchServiceTest.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSecretPatching() {
    Secret oldSecret = new SecretBuilder()
            .withNewMetadata().withName("secret").endMetadata()
            .addToData("test", "dGVzdA==")
            .build();
    Secret newSecret = new SecretBuilder()
            .withNewMetadata().withName("secret").endMetadata()
            .addToStringData("test", "test")
            .build();
    WebServerEventCollector<OpenShiftMockServer> collector = new WebServerEventCollector<>(mockServer);
    mockServer.expect().get().withPath("/api/v1/namespaces/test/secrets/secret")
            .andReply(collector.record("get-secret").andReturn(200, oldSecret)).always();
    mockServer.expect().patch().withPath("/api/v1/namespaces/test/secrets/secret")
            .andReply(collector.record("patch-secret")
                    .andReturn(200, new SecretBuilder().withMetadata(newSecret.getMetadata())
                            .addToStringData(oldSecret.getData()).build())).once();

    OpenShiftClient client = mockServer.createOpenShiftClient();

    PatchService patchService = new PatchService(client, log);

    patchService.compareAndPatchEntity("test", newSecret, oldSecret);
    collector.assertEventsRecordedInOrder("get-secret", "get-secret", "patch-secret");
    assertEquals("[{\"op\":\"remove\",\"path\":\"/data\"},{\"op\":\"add\",\"path\":\"/stringData\",\"value\":{\"test\":\"test\"}}]", collector.getBodies().get(2));

}
 
Example #5
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSuccessfulBuildNoS2iSuffix() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig config = defaultConfig
                .s2iBuildNameSuffix(null)
                .build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = config;
        }};
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(
            config, true, 50, false, false);
        OpenShiftMockServer mockServer = collector.getMockServer();

        DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
        LOG.info("Current write timeout is : {}", client.getHttpClient().writeTimeoutMillis());
        LOG.info("Current read timeout is : {}", client.getHttpClient().readTimeoutMillis());
        LOG.info("Retry on failure : {}", client.getHttpClient().retryOnConnectionFailure());
        OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
        service.build(image);

        // we should Foadd a better way to assert that a certain call has been made
        assertTrue(mockServer.getRequestCount() > 8);
        collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
        assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}", collector.getBodies().get(1));
        collector.assertEventsNotRecorded("patch-build-config");
    });
}
 
Example #6
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDockerBuild() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig dockerConfig = BuildServiceConfig.builder()
                .buildDirectory(baseDir)
                .buildRecreateMode(BuildRecreateMode.none)
                .s2iBuildNameSuffix("-docker")
                .openshiftBuildStrategy(OpenShiftBuildStrategy.docker).build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = dockerConfig;
        }};
        // @formatter:off
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(dockerConfig, true, 50,
                false, false);
        OpenShiftMockServer mockServer = collector.getMockServer();

        DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
        OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
        service.build(image);

        assertTrue(mockServer.getRequestCount() > 8);
        collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
        assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}", collector.getBodies().get(1));
        collector.assertEventsNotRecorded("patch-build-config");
    });
}
 
Example #7
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDockerBuildNoS2iSuffix() throws Exception {
    retryInMockServer(() -> {
        final BuildServiceConfig dockerConfig = BuildServiceConfig.builder()
                .buildDirectory(baseDir)
                .buildRecreateMode(BuildRecreateMode.none)
                .openshiftBuildStrategy(OpenShiftBuildStrategy.docker)
                .build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = dockerConfig;
        }};
        // @formatter:off
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(dockerConfig, true, 50,
                false, false);
        OpenShiftMockServer mockServer = collector.getMockServer();

        DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
        OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
        service.build(image);

        assertTrue(mockServer.getRequestCount() > 8);
        collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
        assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}", collector.getBodies().get(1));
        collector.assertEventsNotRecorded("patch-build-config");
    });
}
 
Example #8
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDockerBuildFromExt() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig dockerConfig = BuildServiceConfig.builder()
                .buildDirectory(baseDir)
                .buildRecreateMode(BuildRecreateMode.none)
                .s2iBuildNameSuffix("-docker")
                .openshiftBuildStrategy(OpenShiftBuildStrategy.docker)
                .build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = dockerConfig;
        }};
        // @formatter:off
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(dockerConfig, true, 50,
                false, false);
        OpenShiftMockServer mockServer = collector.getMockServer();

        DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
        OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
        Map<String,String> fromExt = ImmutableMap.of("name", "app:1.2-1",
                "kind", "ImageStreamTag",
                "namespace", "my-project");
        ImageConfiguration fromExtImage = ImageConfiguration.builder()
                .name(projectName)
                .build(BuildConfiguration.builder()
                        .fromExt(fromExt)
                        .nocache(Boolean.TRUE)
                        .build()
                ).build();

        service.build(fromExtImage);

        assertTrue(mockServer.getRequestCount() > 8);
        collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
        assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"app:1.2-1\",\"namespace\":\"my-project\"},\"noCache\":true},\"type\":\"Docker\"}}}", collector.getBodies().get(1));
        collector.assertEventsNotRecorded("patch-build-config");
    });
}
 
Example #9
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Test(expected = JKubeServiceException.class)
public void testFailedBuild() throws Exception {
    BuildServiceConfig config = defaultConfig.build();
    // @formatter:on
    new Expectations() {{
        jKubeServiceHub.getBuildServiceConfig(); result = config;
    }};
    // @formatter:off
    WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, false, 50, false, false);
    OpenShiftMockServer mockServer = collector.getMockServer();

    OpenShiftClient client = mockServer.createOpenShiftClient();
    OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
    service.build(image);
}
 
Example #10
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Test(expected = JKubeServiceException.class)
public void testFailedBuildSecret() throws Exception {
    BuildServiceConfig config = defaultConfigSecret.build();
    // @formatter:on
    new Expectations() {{
        jKubeServiceHub.getBuildServiceConfig(); result = config;
    }};
    // @formatter:off
    WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, false, 50, false, false);
    OpenShiftMockServer mockServer = collector.getMockServer();

    OpenShiftClient client = mockServer.createOpenShiftClient();
    OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);
    service.build(image);
}
 
Example #11
Source File: OpenShiftServiceImplTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    server = new OpenShiftMockServer();
    client = server.createOpenShiftClient();

    config = new OpenShiftConfigurationProperties();
    service = new OpenShiftServiceImpl(client, config);
}
 
Example #12
Source File: PortForwardServiceTest.java    From jkube with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testSimpleScenario() throws Exception {
    // Cannot test more complex scenarios due to errors in mockwebserver
    OpenShiftMockServer mockServer = new OpenShiftMockServer(false);

    Pod pod1 = new PodBuilder()
            .withNewMetadata()
            .withName("mypod")
            .addToLabels("mykey", "myvalue")
            .withResourceVersion("1")
            .endMetadata()
            .withNewStatus()
            .withPhase("run")
            .endStatus()
            .build();

    PodList pods1 = new PodListBuilder()
            .withItems(pod1)
            .withNewMetadata()
            .withResourceVersion("1")
            .endMetadata()
            .build();

    mockServer.expect().get().withPath("/api/v1/namespaces/test/pods?labelSelector=mykey%3Dmyvalue").andReturn(200, pods1).always();
    mockServer.expect().get().withPath("/api/v1/namespaces/test/pods").andReturn(200, pods1).always();
    mockServer.expect().get().withPath("/api/v1/namespaces/test/pods?labelSelector=mykey%3Dmyvalue&watch=true")
            .andUpgradeToWebSocket().open()
            .waitFor(1000)
            .andEmit(new WatchEvent(pod1, "MODIFIED"))
            .done().always();

    mockServer.expect().get().withPath("/api/v1/namespaces/test/pods?resourceVersion=1&watch=true")
            .andUpgradeToWebSocket().open()
            .waitFor(1000)
            .andEmit(new WatchEvent(pod1, "MODIFIED"))
            .done().always();

    OpenShiftClient client = mockServer.createOpenShiftClient();
    PortForwardService service = new PortForwardService(client, logger) {
        @Override
        public ProcessUtil.ProcessExecutionContext forwardPortAsync(KitLogger externalProcessLogger, String pod, String namespace, int remotePort, int localPort) throws JKubeServiceException {
            return new ProcessUtil.ProcessExecutionContext(process, Collections.<Thread>emptyList(), logger);
        }
    };

    try (Closeable c = service.forwardPortAsync(logger, new LabelSelectorBuilder().withMatchLabels(Collections.singletonMap("mykey", "myvalue")).build(), 8080, 9000)) {
        Thread.sleep(3000);
    }
}
 
Example #13
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void checkTarPackage() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig config = defaultConfig.build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = config;
        }};
        // @formatter:off
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, true, true);
        OpenShiftMockServer mockServer = collector.getMockServer();

        OpenShiftClient client = mockServer.createOpenShiftClient();
        final OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);

        ImageConfiguration imageWithEnv = image.toBuilder()
                .build(image.getBuildConfiguration().toBuilder()
                        .env(Collections.singletonMap("FOO", "BAR"))
                        .build()
                ).build();

        service.createBuildArchive(imageWithEnv);

        final List<ArchiverCustomizer> customizer = new LinkedList<>();
        new Verifications() {{
            jKubeServiceHub.getDockerServiceHub().getArchiveService()
                .createDockerBuildArchive(withInstanceOf(ImageConfiguration.class), withInstanceOf(JKubeConfiguration.class), withCapture(customizer));

            assertTrue(customizer.size() == 1);
        }};

        customizer.get(0).customize(tarArchiver);

        final List<File> file = new LinkedList<>();
        new Verifications() {{
            String path;
            tarArchiver.includeFile(withCapture(file), path = withCapture());

            assertEquals(".s2i/environment", path);
        }};

        assertEquals(1, file.size());
        List<String> lines;
        try (FileReader reader = new FileReader(file.get(0))) {
            lines = IOUtils.readLines(reader);
        }
        assertTrue(lines.contains("FOO=BAR"));
    });
}
 
Example #14
Source File: OpenshiftBuildServiceTest.java    From jkube with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void checkTarPackageSecret() throws Exception {
    retryInMockServer(() -> {
        BuildServiceConfig config = defaultConfigSecret.build();
        // @formatter:on
        new Expectations() {{
            jKubeServiceHub.getBuildServiceConfig(); result = config;
        }};
        // @formatter:off
        WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, true, true);
        OpenShiftMockServer mockServer = collector.getMockServer();

        OpenShiftClient client = mockServer.createOpenShiftClient();
        final OpenshiftBuildService service = new OpenshiftBuildService(client, logger, jKubeServiceHub);

        ImageConfiguration imageWithEnv = image.toBuilder()
                .build(image.getBuildConfiguration().toBuilder()
                        .env(Collections.singletonMap("FOO", "BAR"))
                        .build()
                ).build();

        service.createBuildArchive(imageWithEnv);

        final List<ArchiverCustomizer> customizer = new LinkedList<>();
        new Verifications() {{
            jKubeServiceHub.getDockerServiceHub().getArchiveService()
                .createDockerBuildArchive(withInstanceOf(ImageConfiguration.class), withInstanceOf(JKubeConfiguration.class), withCapture(customizer));

            assertEquals(1, customizer.size());
        }};

        customizer.get(0).customize(tarArchiver);

        final List<File> file = new LinkedList<>();
        new Verifications() {{
            String path;
            tarArchiver.includeFile(withCapture(file), path = withCapture());

            assertEquals(".s2i/environment", path);
        }};

        assertEquals(1, file.size());
        List<String> lines;
        try (FileReader reader = new FileReader(file.get(0))) {
            lines = IOUtils.readLines(reader);
        }
        assertTrue(lines.contains("FOO=BAR"));
    });
}
 
Example #15
Source File: OpenShiftServerTest.java    From vertx-service-discovery with Apache License 2.0 4 votes vote down vote up
@Override
public KubernetesMockServer getServer() {
  return new OpenShiftMockServer(false);
}
 
Example #16
Source File: ConfigMapStoreOpenShiftTest.java    From vertx-config with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp(TestContext tc) throws MalformedURLException {
  vertx = Vertx.vertx();
  vertx.exceptionHandler(tc.exceptionHandler());

  ConfigMap map1 = new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map").build())
    .addToData("my-app-json", SOME_JSON)
    .addToData("my-app-props", SOME_PROPS)
    .build();

  Map<String, String> data = new LinkedHashMap<>();
  data.put("key", "value");
  data.put("bool", "true");
  data.put("count", "3");
  ConfigMap map2 = new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map-2").build())
    .withData(data)
    .build();

  ConfigMap map3 = new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map-x").build())
    .addToData("my-app-json", SOME_JSON)
    .build();

  Secret secret = new SecretBuilder().withMetadata(new ObjectMetaBuilder().withName("my-secret").build())
    .addToData("password", Base64.getEncoder().encodeToString("secret".getBytes(UTF_8)))
    .build();

  server = new OpenShiftMockServer(false);

  server.expect().get().withPath("/api/v1/namespaces/default/configmaps").andReturn(200, new
    ConfigMapListBuilder().addToItems(map1, map2).build()).always();
  server.expect().get().withPath("/api/v1/namespaces/my-project/configmaps").andReturn(200, new
    ConfigMapListBuilder().addToItems(map3).build()).always();

  server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-config-map")
    .andReturn(200, map1).always();
  server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-config-map-2")
    .andReturn(200, map2).always();

  server.expect().get().withPath("/api/v1/namespaces/my-project/configmaps/my-config-map-x")
    .andReturn(200, map3).always();

  server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-unknown-config-map")
    .andReturn(500, null).always();
  server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-unknown-map")
    .andReturn(500, null).always();

  server.expect().get().withPath("/api/v1/namespaces/my-project/secrets/my-secret").andReturn(200, secret)
    .always();

  server.init();
  client = server.createClient();
  port = new URL(client.getConfiguration().getMasterUrl()).getPort();
}