本文整理汇总了Java中com.thoughtworks.go.plugin.api.request.GoPluginApiRequest类的典型用法代码示例。如果您正苦于以下问题:Java GoPluginApiRequest类的具体用法?Java GoPluginApiRequest怎么用?Java GoPluginApiRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GoPluginApiRequest类属于com.thoughtworks.go.plugin.api.request包,在下文中一共展示了GoPluginApiRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldAuthenticate
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void shouldAuthenticate() throws Exception {
final GoPluginApiRequest goApiRequest = mock(GoPluginApiRequest.class);
final String requestBody = requestJson("username", "password");
when(goApiRequest.requestBody()).thenReturn(requestBody);
final User user = new User("username", "displayName", "email");
when(authenticator.authenticate(Credentials.fromJSON(requestBody), AuthConfig.fromJSONList(requestBody))).thenReturn(user);
final GoPluginApiResponse response = new UserAuthenticationExecutor(goApiRequest, authenticator).execute();
assertThat(response.responseCode(), is(200));
final String expectedResponseBody = "{\n" +
" \"roles\": [],\n" +
" \"user\": {\n" +
" \"username\": \"username\",\n" +
" \"display_name\": \"displayName\",\n" +
" \"email\": \"email\"\n" +
" }\n" +
"}";
JSONAssert.assertEquals(expectedResponseBody, response.responseBody(), true);
}
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:25,代码来源:UserAuthenticationExecutorTest.java
示例2: handle
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
String requestName = request.requestName();
if (requestName.equals(PLUGIN_SETTINGS_GET_CONFIGURATION)) {
return handleGetPluginSettingsConfiguration();
} else if (requestName.equals(PLUGIN_SETTINGS_GET_VIEW)) {
try {
return handleGetPluginSettingsView();
} catch (IOException e) {
return renderJSON(500, String.format("Failed to find template: %s", e.getMessage()));
}
} else if (requestName.equals(PLUGIN_SETTINGS_VALIDATE_CONFIGURATION)) {
return handleValidatePluginSettingsConfiguration(request);
}
if ("parse-directory".equals(request.requestName())) {
return handleParseDirectoryRequest(request);
}
throw new UnhandledRequestTypeException(request.requestName());
}
示例3: settingsValidationOk
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationOk() throws Exception {
String requestJson =
"{\"plugin-settings\": {"
+ "\"connectTimeout\": {"
+ "\"value\": \"5\""
+ "}, "
+ "\"proxyUrl\": {"
+ "\"value\": \"http://proxy.example.com:1234\""
+ "},"
+ "\"connPoolSize\": {"
+ "\"value\": \"200\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().equals("[]"));
}
示例4: settingsValidationBadTimeout
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationBadTimeout() throws Exception {
String requestJson =
"{\"plugin-settings\": {"
+ "\"connectTimeout\": {"
+ "\"value\": \"asdf\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"key\":\"connectTimeout\""));
Assert.assertTrue(response.responseBody().contains("\"message\":\"Invalid timeout value. Must be an integer > 0 or -1.\""));
}
示例5: settingsValidationBadProxy
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationBadProxy() throws Exception {
String requestJson =
"{\"plugin-settings\": {"
+ "\"proxyUrl\": {"
+ "\"value\": \"ftp://whatever:anc\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"key\":\"proxyUrl\""));
Assert.assertTrue(response.responseBody().contains("\"message\":"));
Assert.assertTrue(response.responseBody().contains("Exception"));
}
示例6: settingsValidationBadConnPoolSize
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationBadConnPoolSize() throws Exception {
String requestJson =
"{\"plugin-settings\": {"
+ "\"connPoolSize\": {"
+ "\"value\": \"asdf\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"key\":\"connPoolSize\""));
Assert.assertTrue(response.responseBody().contains("\"message\":\"Must be an integer\""));
}
示例7: scmConfig
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmConfig() throws Exception {
String requestJson =
"{}"
;
GoPluginApiRequest request = createRequest("scm-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Map map = new ObjectMapper().readValue(response.responseBody(), Map.class);
Map urlMap = (Map) map.get("url");
Map patternMap = (Map) map.get("pattern");
Map dummyIdMap = (Map) map.get("dummy_id");
Assert.assertEquals("url", urlMap.get("display-name"));
Assert.assertEquals(Boolean.TRUE, urlMap.get("part-of-identity"));
Assert.assertEquals("filename regex", patternMap.get("display-name"));
Assert.assertEquals(Boolean.TRUE, dummyIdMap.get("part-of-identity"));
Assert.assertEquals("dummy id", dummyIdMap.get("display-name"));
Assert.assertEquals(Boolean.TRUE, dummyIdMap.get("part-of-identity"));
}
示例8: scmConfigView
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmConfigView() throws Exception {
String requestJson ="{}";
GoPluginApiRequest request = createRequest("scm-view", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
System.out.println("got response:");
System.out.println(response.responseBody());
System.out.println();
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"template\":\"<div class"));
Assert.assertTrue(response.responseBody().contains("GOINPUTNAME[url].$error.server"));
Assert.assertTrue(response.responseBody().contains("GOINPUTNAME[pattern].$error.server"));
Assert.assertTrue(response.responseBody().contains("GOINPUTNAME[dummy_id].$error.server"));
}
示例9: scmValidationOk
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationOk() throws Exception {
String requestJson =
"{\"scm-configuration\": {"
+ "\"url\": {"
+ "\"value\": \"" + APP_URL + "\""
+ "},"
+ "\"pattern\": {"
+ "\"value\": \"abc\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().equals("[]"));
}
示例10: scmValidationUrlMissing
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationUrlMissing() throws Exception {
String requestJson =
"{\"scm-configuration\": {"
+ "\"url\": {"
+ "\"value\": \"\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"key\":\"url\""));
Assert.assertTrue(response.responseBody().contains("\"message\":\"URL not specified\""));
}
示例11: scmValidationUrlBadScheme
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationUrlBadScheme() throws Exception {
String requestJson =
"{\"scm-configuration\": {"
+ "\"url\": {"
+ "\"value\": \"ftp://foo/bar/\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"key\":\"url\""));
Assert.assertTrue(response.responseBody().contains("\"message\":\"URL with unknown scheme\""));
}
示例12: scmValidationUrlNoTrailingSlash
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationUrlNoTrailingSlash() throws Exception {
String requestJson =
"{\"scm-configuration\": {"
+ "\"url\": {"
+ "\"value\": \"http://foo/bar\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"key\":\"url\""));
Assert.assertTrue(response.responseBody().contains("\"message\":\"URL must end with a slash\""));
}
示例13: scmValidationInvalidPattern
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationInvalidPattern() throws Exception {
String requestJson =
"{\"scm-configuration\": {"
+ "\"pattern\": {"
+ "\"value\": \"(\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);
ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"key\":\"pattern\""));
Assert.assertTrue(response.responseBody().contains("\"message\":\"java.util.regex.PatternSyntaxException: Unclosed group near index 1"));
}
示例14: checkScmConnection
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void checkScmConnection() throws Exception {
String requestJson =
"{\"scm-configuration\": {"
+ "\"url\": {"
+ "\"value\": \"" + APP_URL + "\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("check-scm-connection", requestJson);
ArtifactoryScmPlugin plugin = createPluginScm();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"status\":\"success\""));
}
示例15: latestRevision
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void latestRevision() throws Exception {
String requestJson =
"{\"scm-configuration\": {"
+ "\"url\": {"
+ "\"value\": \"" + APP_URL + "\""
+ "}"
+ "}}"
;
GoPluginApiRequest request = createRequest("latest-revision", requestJson);
ArtifactoryScmPlugin plugin = createPluginScm();
GoPluginApiResponse response = plugin.handle(request);
Assert.assertNotNull(response);
Assert.assertTrue(response.responseBody().contains("\"revision\":{"));
Assert.assertTrue(response.responseBody().contains("\"revision\":\"1.2.3\""));
Assert.assertTrue(response.responseBody().contains("\"revisionComment\":\"1.2.3\""));
Assert.assertTrue(response.responseBody().contains("\"timestamp\":\"2016-01-03T14:15:00.000Z\""));
Assert.assertTrue(response.responseBody().contains("\"modifiedFiles\":["));
Assert.assertTrue(response.responseBody().contains("\"fileName\":\"foo##1.2.3.txt\""));
Assert.assertTrue(response.responseBody().contains("\"action\":\"added\""));
Assert.assertFalse(response.responseBody().contains("0.5.1"));
Assert.assertFalse(response.responseBody().contains("0.9.5"));
}