@Test
  public void postGroupAsXmlPartial_shouldEnforcePipelineGroupAdminPermissionsForPipelineTemplates()
      throws Exception {
    String md5 = setUpPipelineGroupsWithAdminPermissions();

    ConfigElementImplementationRegistry registry =
        ConfigElementImplementationRegistryMother.withNoPlugins();
    XmlUtils.validate(
        new FileInputStream(configHelper.getConfigFile()),
        GoConfigSchema.getCurrentSchema(),
        new XsdErrorTranslator(),
        new SAXBuilder(),
        registry.xsds());
    controller.postGroupAsXmlPartial(
        TemplatesConfig.PIPELINE_TEMPLATES_FAKE_GROUP_NAME, NEW_TEMPLATES, md5, response);

    assertThat(response.getStatus(), is(SC_UNAUTHORIZED));
    XmlUtils.validate(
        new FileInputStream(configHelper.getConfigFile()),
        GoConfigSchema.getCurrentSchema(),
        new XsdErrorTranslator(),
        new SAXBuilder(),
        registry.xsds());

    setCurrentUser("admin");
    controller.postGroupAsXmlPartial(
        TemplatesConfig.PIPELINE_TEMPLATES_FAKE_GROUP_NAME, NEW_TEMPLATES, md5, response);
    assertThat(response.getStatus(), is(SC_OK));
  }
コード例 #2
0
ファイル: GoConfigSubtagLoader.java プロジェクト: Kisama/gocd
 private Class<?> findConcreteTypeFrom(Element element, Class<?> interfaceType) {
   for (Class<?> implementation : registry.implementersOf(interfaceType)) {
     if (GoConfigClassLoader.compare(element, implementation, configCache)) {
       return implementation;
     }
   }
   return null;
 }