com.github.tomakehurst.wiremock.matching.UrlPathPattern Java Examples

The following examples show how to use com.github.tomakehurst.wiremock.matching.UrlPathPattern. 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: SwaggerHubUploadTest.java    From swaggerhub-gradle-plugin with Apache License 2.0 6 votes vote down vote up
private UrlPathPattern setupServerMocking(SwaggerHubRequest request, String host, String port, String protocol, String token) {
    String api = request.getApi();
    String owner = request.getOwner();
    String version = request.getVersion();
    String format = request.getFormat();
    String isPrivate = Boolean.toString(request.isPrivate());


    startMockServer(Integer.parseInt(port));

    UrlPathPattern url = urlPathEqualTo("/apis/" + owner + "/" + api);

    stubFor(post(url)
            .withQueryParam("version", equalTo(version))
            .withQueryParam("isPrivate", equalTo(isPrivate != null ? isPrivate : "false"))
            .withHeader("Content-Type", equalToIgnoreCase(
                    String.format("application/%s; charset=UTF-8", format != null ? format : "json")))
            .withHeader("Authorization", equalTo(token))
            .withHeader("User-Agent", equalTo("swaggerhub-gradle-plugin"))
            .withRequestBody(equalTo(request.getSwagger()))
            .willReturn(created()));

    return url;
}
 
Example #2
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testInputFileIsUploaded_andSCMSaveRequestMadeWithToken() throws Exception {
    //Given
    UrlPathPattern saveDefinitionRequest = stubSaveDefinitionRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest = stubSaveSCMPluginConfigurationRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder putRequestPattern1 = createPutSCMConfigRequestPatternWithToken(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, INPUT_FILE_FILENAME, DefinitionFileFormat.JSON.getLanguageTarget(), TEST_RESOURCES_DIRECTORY, SCM_TOKEN);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-input-file-save-github-plugin.xml").execute();

    //Then
    verify(1, postRequestedFor(saveDefinitionRequest));
    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest));
    verify(1, putRequestPattern1);
}
 
Example #3
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testInputFileIsUploaded_andSCMSaveRequestMadeWithUsernamePassword() throws Exception {
    //Given
    UrlPathPattern saveDefinitionRequest = stubSaveDefinitionRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest = stubSaveSCMPluginConfigurationRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder saveSCMConfigRequest = createPutSCMConfigRequestPatternWithUsernamePassword(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, INPUT_FILE_FILENAME,
            DefinitionFileFormat.JSON.getLanguageTarget(), TEST_RESOURCES_DIRECTORY, SCM_USERNAME,SCM_PASSWORD);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-input-file-save-scm-plugin-with-username-password.xml").execute();

    //Then
    verify(1, postRequestedFor(saveDefinitionRequest));
    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest));
    verify(1, saveSCMConfigRequest);
}
 
Example #4
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testInputFileIsUploaded_andSCMSaveRequestMadeWithAccountPATAndProject() throws Exception {
    //Given
    UrlPathPattern saveDefinitionRequest = stubSaveDefinitionRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest = stubSaveSCMPluginConfigurationRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder saveSCMConfigRequest = createPutSCMConfigRequestPatternWithAccountPATandProject(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, INPUT_FILE_FILENAME,
            DefinitionFileFormat.JSON.getLanguageTarget(), TEST_RESOURCES_DIRECTORY, SCM_ACCOUNT, SCM_PERSONAL_ACCESS_TOKEN, SCM_PROJECT);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-input-file-save-scm-plugin-with-account-pat-project.xml").execute();

    //Then
    verify(1, postRequestedFor(saveDefinitionRequest));
    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest));
    verify(1, saveSCMConfigRequest);
}
 
Example #5
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testInputFileIsUploaded_andSCMSaveRequestMadeWithUrlAndProjectCollection() throws Exception {
    //GIVEN
    UrlPathPattern saveDefinitionRequest = stubSaveDefinitionRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest = stubSaveSCMPluginConfigurationRequest(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder saveSCMConfigRequest = createPutSCMConfigRequestPatternWithUrlAndProjectCollection(API_OWNER, INPUT_FILE_API, INPUT_FILE_API_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, INPUT_FILE_FILENAME,
            DefinitionFileFormat.JSON.getLanguageTarget(), TEST_RESOURCES_DIRECTORY, SCM_PERSONAL_ACCESS_TOKEN, SCM_PROJECT, SCM_URL, SCM_PROJECT_COLLECTION);

    //WHEN
    getSwaggerUpload("src/test/resources/testProjects/upload-input-filesave-scm-plugin-with-url-and-project-collection.xml").execute();

    //THEN
    verify(1, postRequestedFor(saveDefinitionRequest));
    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest));
    verify(1, saveSCMConfigRequest);
}
 
Example #6
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiSaveDefinitionRequestMade_despiteSaveFailures() throws Exception {
    //Given
    UrlPathPattern uploadDefinitionRequest1 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest2 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest3 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML,SWAGGERHUB_API_TOKEN);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-save-github-plugins.xml").execute();

    //Then
    verify(1, postRequestedFor(uploadDefinitionRequest1));
    verify(1, postRequestedFor(uploadDefinitionRequest2));
    verify(1, postRequestedFor(uploadDefinitionRequest3));

}
 
Example #7
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
private UrlPathPattern stubSaveSCMPluginConfigurationRequest(String owner, String api, String version, String oasVersion, String token){
    UrlPathPattern url = urlPathEqualTo("/plugins/configurations/" + owner + "/" + api +"/"+version+"/GITHUB");
    stubFor(put(url)
            .withQueryParam("oas", equalTo(oasVersion))
            .withHeader("Content-Type", equalToIgnoreCase(
                    String.format("application/%s; charset=UTF-8", "json")))
            .withHeader("Authorization", equalTo(token))
            .withHeader("User-Agent", equalTo("swaggerhub-maven-plugin"))
            .willReturn(created()));
    return url;
}
 
Example #8
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
private UrlPathPattern stubSaveDefinitionRequest(String definitionPathSegment, String token, String owner, String api, String version, String isPrivate, String oasVersion, String format, ResponseDefinitionBuilder responseDefinitionBuilder){
    UrlPathPattern url = urlPathEqualTo("/" + definitionPathSegment + "/" + owner + "/" + api);
    stubFor(post(url)
            .withQueryParam("version", equalTo(version))
            .withQueryParam("isPrivate", equalTo(isPrivate != null ? isPrivate : "false"))
            .withQueryParam("oas", equalTo(oasVersion))
            .withHeader("Content-Type", equalToIgnoreCase(
                    String.format("application/%s; charset=UTF-8", format != null ? format : "json")))
            .withHeader("Authorization", equalTo(token))
            .withHeader("User-Agent", equalTo("swaggerhub-maven-plugin"))
            .willReturn(responseDefinitionBuilder));
    return url;
}
 
Example #9
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
private UrlPathPattern setupServerMocking(PlexusConfiguration config, String oasVersion) {
    String definitionType = DefinitionType.getByParamValue(config.getChild("definitionType").getValue()).getPathSegment();
    String api = config.getChild("api").getValue();
    String owner = config.getChild("owner").getValue();
    String version = config.getChild("version").getValue();
    String token = config.getChild("token").getValue();
    String format = config.getChild("format").getValue();
    String isPrivate = config.getChild("isPrivate").getValue();

    UrlPathPattern url = stubSaveDefinitionRequest(definitionType, token, owner, api, version, isPrivate, oasVersion, format, created());

    return url;
}
 
Example #10
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void runTest(File pom, String expectedOasVersion) throws Exception {
    assertNotNull(pom);
    assertTrue(pom.exists());

    SwaggerHubUpload swaggerHubUpload = (SwaggerHubUpload) rule.lookupConfiguredMojo(pom, "upload");
    assertNotNull(swaggerHubUpload);

    final PlexusConfiguration config = rule.extractPluginConfiguration("swaggerhub-maven-plugin", pom);
    UrlPathPattern url = setupServerMocking(config, expectedOasVersion);

    swaggerHubUpload.execute();
    verify(1, postRequestedFor(url));
}
 
Example #11
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploaded_andSCMSaveRequestMadeWithHost() throws Exception {
    //GIVEN
    UrlPathPattern uploadDefinitionRequest1 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest2 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest3 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);

    UrlPathPattern saveSCMPluginConfigurationRequest1 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest2 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest3 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder saveSCMPluginRequestPattern1 = createPutSCMConfigRequestWithHost(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_1_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_HOST);
    RequestPatternBuilder saveSCMPluginRequestPattern2 = createPutSCMConfigRequestWithHost(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_2_FILENAME, DefinitionFileFormat.JSON.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_HOST);
    RequestPatternBuilder saveSCMPluginRequestPattern3 = createPutSCMConfigRequestWithHost(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_3_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_HOST);

    //WHEN
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-save-scm-plugins-with-host.xml").execute();

    //THEN
    verify(1, postRequestedFor(uploadDefinitionRequest1));
    verify(1, postRequestedFor(uploadDefinitionRequest2));
    verify(1, postRequestedFor(uploadDefinitionRequest3));

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest1));
    verify(saveSCMPluginRequestPattern1);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest2));
    verify(saveSCMPluginRequestPattern2);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest3));
    verify(saveSCMPluginRequestPattern3);
}
 
Example #12
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploadedWithCorrectPath_WhenUsingWindowsSupportedFilePath() throws Exception {
    //Given
    UrlPathPattern definition1Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern definition2Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern definition3Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);


    UrlPathPattern saveSCMPluginConfigurationRequest1 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest2 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest3 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder putRequestPattern1 = createPutSCMConfigRequestPatternWithToken(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_1_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_TOKEN);
    RequestPatternBuilder putRequestPattern2 = createPutSCMConfigRequestPatternWithToken(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_2_FILENAME, DefinitionFileFormat.JSON.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_TOKEN);
    RequestPatternBuilder putRequestPattern3 = createPutSCMConfigRequestPatternWithToken(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_3_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_TOKEN);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-windows.xml").execute();

    //Then
    verify(1, postRequestedFor(definition1Request));
    verify(1, postRequestedFor(definition2Request));
    verify(1, postRequestedFor(definition3Request));

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest1));
    verify(putRequestPattern1);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest2));
    verify(putRequestPattern2);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest3));
    verify(putRequestPattern3);
}
 
Example #13
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test(expected = RuntimeException.class)
public void testBuildFails_whenSaveDefinitionFails_andFailuresArentSkipped() throws Exception {
    //Given
    stubSaveDefinitionRequest(DefinitionType.API.getPathSegment(), SWAGGERHUB_API_TOKEN, API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, badRequest());
    UrlPathPattern uploadDefinitionRequest2 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);

    //When
    getSwaggerUpload("src/test/resources/testProjects/fail_build_on_failed_requests.xml").execute();

    //Then
    fail();

}
 
Example #14
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploaded_andSCMSaveRequestMadeWithUrlAndProjectCollection() throws Exception {
    //GIVEN
    UrlPathPattern uploadDefinitionRequest1 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest2 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest3 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);

    UrlPathPattern saveSCMPluginConfigurationRequest1 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest2 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest3 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder saveSCMPluginRequestPattern1 = createPutSCMConfigRequestPatternWithUrlAndProjectCollection(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_1_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_PERSONAL_ACCESS_TOKEN,
            SCM_PROJECT, SCM_URL, SCM_PROJECT_COLLECTION);
    RequestPatternBuilder saveSCMPluginRequestPattern2 = createPutSCMConfigRequestPatternWithUrlAndProjectCollection(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_2_FILENAME, DefinitionFileFormat.JSON.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_PERSONAL_ACCESS_TOKEN,
            SCM_PROJECT, SCM_URL, SCM_PROJECT_COLLECTION);
    RequestPatternBuilder saveSCMPluginRequestPattern3 = createPutSCMConfigRequestPatternWithUrlAndProjectCollection(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_3_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_PERSONAL_ACCESS_TOKEN,
            SCM_PROJECT, SCM_URL, SCM_PROJECT_COLLECTION);

    //WHEN
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-save-scm-plugins-with-url-and-project-collection.xml").execute();

    //THEN
    verify(1, postRequestedFor(uploadDefinitionRequest1));
    verify(1, postRequestedFor(uploadDefinitionRequest2));
    verify(1, postRequestedFor(uploadDefinitionRequest3));

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest1));
    verify(saveSCMPluginRequestPattern1);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest2));
    verify(saveSCMPluginRequestPattern2);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest3));
    verify(saveSCMPluginRequestPattern3);
}
 
Example #15
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploaded_andSCMSaveRequestMadeWithAccountPATAndProject() throws Exception {
    //Given
    UrlPathPattern uploadDefinitionRequest1 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest2 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest3 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);

    UrlPathPattern saveSCMPluginConfigurationRequest1 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest2 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest3 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder saveSCMPluginRequestPattern1 = createPutSCMConfigRequestPatternWithAccountPATandProject(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_1_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_ACCOUNT, SCM_PERSONAL_ACCESS_TOKEN, SCM_PROJECT);
    RequestPatternBuilder saveSCMPluginRequestPattern2 = createPutSCMConfigRequestPatternWithAccountPATandProject(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_2_FILENAME, DefinitionFileFormat.JSON.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_ACCOUNT, SCM_PERSONAL_ACCESS_TOKEN, SCM_PROJECT);
    RequestPatternBuilder saveSCMPluginRequestPattern3 = createPutSCMConfigRequestPatternWithAccountPATandProject(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_3_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_ACCOUNT, SCM_PERSONAL_ACCESS_TOKEN, SCM_PROJECT);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-save-scm-plugins-with-account-pat-project.xml").execute();

    //Then
    verify(1, postRequestedFor(uploadDefinitionRequest1));
    verify(1, postRequestedFor(uploadDefinitionRequest2));
    verify(1, postRequestedFor(uploadDefinitionRequest3));

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest1));
    verify(saveSCMPluginRequestPattern1);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest2));
    verify(saveSCMPluginRequestPattern2);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest3));
    verify(saveSCMPluginRequestPattern3);
}
 
Example #16
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploaded_andSCMSaveRequestMadeWithUsernamePassword() throws Exception {
    //Given
    UrlPathPattern uploadDefinitionRequest1 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest2 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest3 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);

    UrlPathPattern saveSCMPluginConfigurationRequest1 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest2 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest3 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder saveSCMPluginRequestPattern1 = createPutSCMConfigRequestPatternWithUsernamePassword(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_1_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_USERNAME, SCM_PASSWORD);
    RequestPatternBuilder saveSCMPluginRequestPattern2 = createPutSCMConfigRequestPatternWithUsernamePassword(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_2_FILENAME, DefinitionFileFormat.JSON.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_USERNAME, SCM_PASSWORD);
    RequestPatternBuilder saveSCMPluginRequestPattern3 = createPutSCMConfigRequestPatternWithUsernamePassword(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_3_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_USERNAME, SCM_PASSWORD);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-save-scm-plugins-with-username-password.xml").execute();

    //Then
    verify(1, postRequestedFor(uploadDefinitionRequest1));
    verify(1, postRequestedFor(uploadDefinitionRequest2));
    verify(1, postRequestedFor(uploadDefinitionRequest3));

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest1));
    verify(saveSCMPluginRequestPattern1);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest2));
    verify(saveSCMPluginRequestPattern2);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest3));
    verify(saveSCMPluginRequestPattern3);
}
 
Example #17
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploaded_andSCMSaveRequestMadeWithTokenMade() throws Exception {
    //Given
    UrlPathPattern uploadDefinitionRequest1 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest2 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern uploadDefinitionRequest3 = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);

    UrlPathPattern saveSCMPluginConfigurationRequest1 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest2 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SWAGGERHUB_API_TOKEN);
    UrlPathPattern saveSCMPluginConfigurationRequest3 = stubSaveSCMPluginConfigurationRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SWAGGERHUB_API_TOKEN);

    RequestPatternBuilder putRequestPattern1 = createPutSCMConfigRequestPatternWithToken(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_1_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_TOKEN);
    RequestPatternBuilder putRequestPattern2 = createPutSCMConfigRequestPatternWithToken(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, OAS2, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_2_FILENAME, DefinitionFileFormat.JSON.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_TOKEN);
    RequestPatternBuilder putRequestPattern3 = createPutSCMConfigRequestPatternWithToken(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, OAS3, SCM_BRANCH,
            SCM_ENABLE_INTEGRATION, SCM_REPOSITORY, SCM_REPOSITORY_OWNER, MULTI_UPLOAD_API_3_FILENAME, DefinitionFileFormat.YAML.getLanguageTarget(), FILE_FINDER_DIRECTORY, SCM_TOKEN);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-save-github-plugins.xml").execute();

    //Then
    verify(1, postRequestedFor(uploadDefinitionRequest1));
    verify(1, postRequestedFor(uploadDefinitionRequest2));
    verify(1, postRequestedFor(uploadDefinitionRequest3));

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest1));
    verify(putRequestPattern1);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest2));
    verify(putRequestPattern2);

    verify(1, putRequestedFor(saveSCMPluginConfigurationRequest3));
    verify(putRequestPattern3);

}
 
Example #18
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploaded_WhenSpecifyingDirectoryAndRegexPattern() throws Exception {
    //Given
    UrlPathPattern definition1Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern definition2Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern definition3Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions-with-regex.xml").execute();

    //Then
    verify(1, postRequestedFor(definition1Request));
    verify(1, postRequestedFor(definition2Request));
    verify(0, postRequestedFor(definition3Request));
}
 
Example #19
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiDefinitionsAreUploaded_WhenSpecifyingDirectory() throws Exception {
    //Given
    UrlPathPattern definition1Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_1_TITLE, MULTI_UPLOAD_API_1_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);
    UrlPathPattern definition2Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_2_TITLE, MULTI_UPLOAD_API_2_VERSION, IS_PRIVATE, OAS2, JSON, SWAGGERHUB_API_TOKEN);
    UrlPathPattern definition3Request = stubSaveDefinitionRequest(API_OWNER, MULTI_UPLOAD_API_3_TITLE, MULTI_UPLOAD_API_3_VERSION, IS_PRIVATE, OAS3, YAML, SWAGGERHUB_API_TOKEN);

    //When
    getSwaggerUpload("src/test/resources/testProjects/upload-multi-definitions.xml").execute();

    //Then
    verify(1, postRequestedFor(definition1Request));
    verify(1, postRequestedFor(definition2Request));
    verify(1, postRequestedFor(definition3Request));
}
 
Example #20
Source File: SwaggerHubUploadTest.java    From swaggerhub-maven-plugin with Apache License 2.0 4 votes vote down vote up
private UrlPathPattern stubSaveDefinitionRequest(String owner, String api, String version, String isPrivate, String oasVersion, String format, String token){
    return stubSaveDefinitionRequest(DefinitionType.API.getPathSegment(), token, owner, api, version, isPrivate, oasVersion, format, created());
}
 
Example #21
Source File: SchemaRegistryMock.java    From fluent-kafka-streams-tests with MIT License 4 votes vote down vote up
private static UrlPathPattern getSubjectVersionPattern(final String subject) {
    return WireMock.urlPathMatching(ALL_SUBJECT_PATTERN + "/" + subject + "/versions/(?:latest|\\d+)");
}