@Test public void validatePluginNoCredentialsFailure() { final String error = "AWS CodePipeline Jenkins plugin setup error. One or more required configuration parameters have not been specified." + System.lineSeparator() + "The AWS credentials provided are not valid."; thrown.expect(Failure.class); thrown.expectMessage(error); Validation.validatePlugin( null, null, "us-east-1", CategoryType.Build.getName(), "Jenkins-Build", "1", "ProjectName", null); }
@Test public void validatePluginNoRegionFailure() { final String error = "AWS CodePipeline Jenkins plugin setup error. One or more required configuration parameters have not been specified." + System.lineSeparator(); final String regionError = "The specified AWS region is not valid."; thrown.expect(Failure.class); thrown.expectMessage(error); thrown.expectMessage(regionError); Validation.validatePlugin( "", "", "", CategoryType.Build.getName(), "Jenkins-Build", "1", "ProjectName", null); }
@Test public void validatePluginInvalidActionTypeProviderFailure() { final String error = "AWS CodePipeline Jenkins plugin setup error. One or more required configuration parameters have not been specified." + System.lineSeparator(); thrown.expect(Failure.class); thrown.expectMessage(error); thrown.expectMessage("Category:"); thrown.expectMessage("Version: 1"); thrown.expectMessage("Provider:"); Validation.validatePlugin( "", "", "us-east-1", CategoryType.Build.getName(), "", "1", "ProjectName", null); }
@Test public void validatePluginInvalidActionTypeCategoryFailure() { final String error = "AWS CodePipeline Jenkins plugin setup error. One or more required configuration parameters have not been specified." + System.lineSeparator(); thrown.expect(Failure.class); thrown.expectMessage(error); thrown.expectMessage("Category: Please Choose A Category"); thrown.expectMessage("Version: 1"); thrown.expectMessage("Provider: Jenkins-Build"); Validation.validatePlugin( "", "", "us-east-1", CategoryType.PleaseChooseACategory.getName(), "Jenkins-Build", "1", "ProjectName", null); }
@Test public void validatePluginInvalidActionTypeVersionFailure() { final String error = "AWS CodePipeline Jenkins plugin setup error. One or more required configuration parameters have not been specified." + System.lineSeparator(); thrown.expect(Failure.class); thrown.expectMessage(error); thrown.expectMessage("Category: Build"); thrown.expectMessage("Version:"); thrown.expectMessage("Provider: Jenkins-Build"); Validation.validatePlugin( "", "", "us-east-1", CategoryType.Build.getName(), "Jenkins-Build", "", "ProjectName", null); }
@Test public void validatePluginAllFieldsMissingFailure() { thrown.expect(Failure.class); thrown.expectMessage("AWS CodePipeline Jenkins plugin setup error. One or more required configuration parameters have not been specified."); thrown.expectMessage("The specified AWS region is not valid."); thrown.expectMessage("The AWS credentials provided are not valid."); Validation.validatePlugin( null, null, "", CategoryType.Build.getName(), "Jenkins-Build", "", "ProjectName", null); }
public FormValidation doCheckCloudName(@QueryParameter String value) { try { Hudson.checkGoodName(value); } catch (Failure e){ return FormValidation.error(e.getMessage()); } String cloudId = createCloudId(value); int found = 0; for (Cloud c : Hudson.getInstance().clouds) { if (c.name.equals(cloudId)) { found++; } } if (found>1) { return FormValidation.error(Messages.AmazonEC2Cloud_NonUniqName()); } return FormValidation.ok(); }
@Override public void checkName(String name) throws Failure { initPython(); if (pexec.isImplemented(1)) { pexec.execPythonVoid("check_name", name); } else { super.checkName(name); } }
private FormValidation validGoodName(String variance) { if (StringUtils.isBlank(variance)) { return FormValidation.ok(); } try { Jenkins.checkGoodName(variance); return FormValidation.ok(); } catch (Failure e) { return FormValidation.error(e.getMessage()); } }
public void superCheckName(String name) throws Failure { super.checkName(name); }