Java Code Examples for hudson.util.Secret#fromString()
The following examples show how to use
hudson.util.Secret#fromString() .
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: LambdaUploadVariablesTest.java From aws-lambda-jenkins-plugin with MIT License | 6 votes |
@Test public void testGetUploadConfigNullTimeoutAndMemory() throws Exception { LambdaUploadVariables variables = new LambdaUploadVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "FILE", "description DESCRIPTION", "FUNCTION", "HANDLER", null, "ROLE", "RUNTIME", "", true, false, "full", null, false, "subnet1, subnet2", "secgroup"); DeployConfig uploadConfig = variables.getUploadConfig(); assertEquals(variables.getArtifactLocation(), uploadConfig.getArtifactLocation()); assertEquals(variables.getDescription(), uploadConfig.getDescription()); assertNull(uploadConfig.getMemorySize()); assertNull(uploadConfig.getTimeout()); assertEquals(variables.getHandler(), uploadConfig.getHandler()); assertEquals(variables.getRuntime(), uploadConfig.getRuntime()); assertEquals(variables.getFunctionName(), uploadConfig.getFunctionName()); assertEquals(variables.getRole(), uploadConfig.getRole()); assertEquals(variables.getUpdateMode(), uploadConfig.getUpdateMode()); assertEquals(Arrays.asList("subnet1", "subnet2"), uploadConfig.getSubnets()); assertEquals(Collections.singletonList("secgroup"), uploadConfig.getSecurityGroups()); }
Example 2
Source File: DockerServerCredentialsTest.java From docker-commons-plugin with MIT License | 6 votes |
@Test public void configRoundTripUpdateCertificates() throws Exception { CredentialsStore store = CredentialsProvider.lookupStores(j.getInstance()).iterator().next(); assertThat(store, instanceOf(SystemCredentialsProvider.StoreImpl.class)); Domain domain = new Domain("docker", "A domain for docker credentials", Collections.singletonList(new DockerServerDomainSpecification())); DockerServerCredentials credentials = new DockerServerCredentials(CredentialsScope.GLOBAL, "foo", "desc", Secret.fromString("key"), "client-cert", "ca-cert"); store.addDomain(domain, credentials); HtmlForm form = getUpdateForm(domain, credentials); for (HtmlElement button : form.getElementsByAttribute("input", "class", "secret-update-btn")) { button.click(); } form.getTextAreaByName("_.clientKeySecret").setText("new key"); form.getTextAreaByName("_.clientCertificate").setText("new cert"); form.getTextAreaByName("_.serverCaCertificate").setText("new ca cert"); j.submit(form); DockerServerCredentials expected = new DockerServerCredentials( credentials.getScope(), credentials.getId(), credentials.getDescription(), Secret.fromString("new key"), "new cert", "new ca cert"); j.assertEqualDataBoundBeans(expected, findFirstWithId(credentials.getId())); }
Example 3
Source File: MarathonRecorderTest.java From marathon-plugin with Apache License 2.0 | 6 votes |
/** * Test that a JSON credential without a "jenkins_token" field and without a proper DC/OS service account value * results in a 401 and only 1 web request. * * @throws Exception */ @Test public void testRecorderInvalidToken() throws Exception { final FreeStyleProject project = j.createFreeStyleProject(); final SystemCredentialsProvider.ProviderImpl system = ExtensionList.lookup(CredentialsProvider.class).get(SystemCredentialsProvider.ProviderImpl.class); final CredentialsStore systemStore = system.getStore(j.getInstance()); final String credentialValue = "{\"field1\":\"some value\"}"; final Secret secret = Secret.fromString(credentialValue); final StringCredentials credential = new StringCredentialsImpl(CredentialsScope.GLOBAL, "invalidtoken", "a token for JSON token test", secret); TestUtils.enqueueFailureResponse(httpServer, 401); systemStore.addCredentials(Domain.global(), credential); addBuilders(TestUtils.loadFixture("idonly.json"), project); // add post-builder addPostBuilders(project, "invalidtoken"); final FreeStyleBuild build = j.assertBuildStatus(Result.FAILURE, project.scheduleBuild2(0).get()); j.assertLogContains("[Marathon] Authentication to Marathon instance failed:", build); j.assertLogContains("[Marathon] Invalid DC/OS service account JSON", build); assertEquals("Only 1 request should have been made.", 1, httpServer.getRequestCount()); }
Example 4
Source File: LambdaUploadVariablesTest.java From aws-lambda-jenkins-plugin with MIT License | 6 votes |
@Test public void testGetUploadConfig() throws Exception { LambdaUploadVariables variables = new LambdaUploadVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "FILE", "description DESCRIPTION", "FUNCTION", "HANDLER", "1024", "ROLE", "RUNTIME", "30", true, false, "full", null, false, "subnet1, subnet2", "secgroup"); EnvironmentConfiguration environmentConfiguration = new EnvironmentConfiguration(Arrays.asList(new EnvironmentEntry("key", "value"))); environmentConfiguration.setKmsArn("kmsArn"); environmentConfiguration.setConfigureEnvironment(true); variables.setEnvironmentConfiguration(environmentConfiguration); DeployConfig uploadConfig = variables.getUploadConfig(); assertEquals(variables.getArtifactLocation(), uploadConfig.getArtifactLocation()); assertEquals(variables.getDescription(), uploadConfig.getDescription()); assertEquals(Integer.valueOf(variables.getMemorySize()), uploadConfig.getMemorySize()); assertEquals(Integer.valueOf(variables.getTimeout()), uploadConfig.getTimeout()); assertEquals(variables.getHandler(), uploadConfig.getHandler()); assertEquals(variables.getRuntime(), uploadConfig.getRuntime()); assertEquals(variables.getFunctionName(), uploadConfig.getFunctionName()); assertEquals(variables.getRole(), uploadConfig.getRole()); assertEquals(variables.getUpdateMode(), uploadConfig.getUpdateMode()); assertEquals(Arrays.asList("subnet1", "subnet2"), uploadConfig.getSubnets()); assertEquals(Collections.singletonList("secgroup"), uploadConfig.getSecurityGroups()); assertEquals(variables.getEnvironmentConfiguration().getKmsArn(), uploadConfig.getKmsArn()); assertEquals(variables.getEnvironmentConfiguration().getEnvironment().get(0).getValue(), uploadConfig.getEnvironmentVariables().get("key")); }
Example 5
Source File: LambdaUploadPublisherTest.java From aws-lambda-jenkins-plugin with MIT License | 6 votes |
@Test @Ignore public void testHtml() throws Exception { LambdaUploadVariables variables = new LambdaUploadVariables(false, "accessKeyId", Secret.fromString("secretKey"), "eu-west-1", "ziplocation", "description", "function", "handler", "1024", "role", "nodejs", "30", true, false, "full", null, false, "", ""); List<LambdaUploadVariables> variablesList = new ArrayList<>(); variablesList.add(variables); FreeStyleProject p = j.createFreeStyleProject(); LambdaUploadPublisher before = new LambdaUploadPublisher(variablesList); p.getPublishersList().add(before); j.submit(j.createWebClient().getPage(p,"configure").getFormByName("config")); LambdaUploadPublisher after = p.getPublishersList().get(LambdaUploadPublisher.class); assertEquals(before, after); }
Example 6
Source File: AWSCodePipelineSCM.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 5 votes |
public AWSCodePipelineSCM( final String projectName, final boolean clear, final String region, final String awsAccessKey, final String awsSecretKey, final String proxyHost, final String proxyPort, final String category, final String provider, final String version, final AWSClientFactory awsClientFactory) { clearWorkspace = clear; this.region = Validation.sanitize(region.trim()); this.awsAccessKey = Validation.sanitize(awsAccessKey.trim()); this.awsSecretKey = Secret.fromString(Validation.sanitize(awsSecretKey.trim())); this.proxyHost = Validation.sanitize(proxyHost.trim()); this.projectName = null; actionTypeCategory = Validation.sanitize(category.trim()); actionTypeProvider = Validation.sanitize(provider.trim()); actionTypeVersion = Validation.sanitize(version.trim()); this.awsClientFactory = awsClientFactory; if (proxyPort != null && !proxyPort.isEmpty()) { this.proxyPort = Integer.parseInt(proxyPort); } else { this.proxyPort = 0; } }
Example 7
Source File: SSLTest.java From hashicorp-vault-plugin with MIT License | 5 votes |
@BeforeClass public static void setupClass() throws IOException, InterruptedException { assumeTrue(hasDockerDaemon()); container.initAndUnsealVault(); container.setBasicSecrets(); pipeline = j.createProject(WorkflowJob.class, "Pipeline"); String pipelineText = IOUtils.toString(TestConstants.class.getResourceAsStream("pipeline.groovy")); pipeline.setDefinition(new CpsFlowDefinition(pipelineText, true)); VaultTokenCredential c = new VaultTokenCredential(CredentialsScope.GLOBAL, credentialsId, "fake description", Secret.fromString(container.getRootToken())); CredentialsProvider.lookupStores(j.jenkins).iterator().next() .addCredentials(Domain.global(), c); }
Example 8
Source File: VaultUsernamePasswordCredentialImpl.java From hashicorp-vault-plugin with MIT License | 5 votes |
@NonNull @Override public Secret getPassword() { String secretKey = defaultIfBlank(passwordKey, DEFAULT_PASSWORD_KEY); String secret = getVaultSecret(path, secretKey, engineVersion); return Secret.fromString(secret); }
Example 9
Source File: DockerServerEndpointTest.java From docker-commons-plugin with MIT License | 5 votes |
@Test public void smokes() throws Exception { DumbSlave slave = j.createOnlineSlave(); VirtualChannel channel = slave.getChannel(); FreeStyleProject item = j.createFreeStyleProject(); CredentialsStore store = CredentialsProvider.lookupStores(j.getInstance()).iterator().next(); assertThat(store, instanceOf(SystemCredentialsProvider.StoreImpl.class)); Domain domain = new Domain("docker", "A domain for docker credentials", Collections.<DomainSpecification>singletonList(new DockerServerDomainSpecification())); DockerServerCredentials credentials = new DockerServerCredentials(CredentialsScope.GLOBAL, "foo", "desc", Secret.fromString("a"), "b", "c"); store.addDomain(domain, credentials); DockerServerEndpoint endpoint = new DockerServerEndpoint("tcp://localhost:2736", credentials.getId()); FilePath dotDocker = DockerServerEndpoint.dotDocker(channel); List<FilePath> dotDockerKids = dotDocker.list(); int initialSize = dotDockerKids == null ? 0 : dotDockerKids.size(); KeyMaterialFactory factory = endpoint.newKeyMaterialFactory(item, channel); KeyMaterial keyMaterial = factory.materialize(); FilePath path = null; try { assertThat(keyMaterial.env().get("DOCKER_HOST", "missing"), is("tcp://localhost:2736")); assertThat(keyMaterial.env().get("DOCKER_TLS_VERIFY", "missing"), is("1")); assertThat(keyMaterial.env().get("DOCKER_CERT_PATH", "missing"), not("missing")); path = new FilePath(channel, keyMaterial.env().get("DOCKER_CERT_PATH", "missing")); if (!Functions.isWindows()) { assertThat(path.mode() & 0777, is(0700)); } assertThat(path.child("key.pem").readToString(), is("a")); assertThat(path.child("cert.pem").readToString(), is("b")); assertThat(path.child("ca.pem").readToString(), is("c")); } finally { keyMaterial.close(); } assertThat(path.child("key.pem").exists(), is(false)); assertThat(path.child("cert.pem").exists(), is(false)); assertThat(path.child("ca.pem").exists(), is(false)); assertThat(dotDocker.list().size(), is(initialSize)); }
Example 10
Source File: DingTalkSecurityPolicyConfig.java From dingtalk-plugin with MIT License | 5 votes |
@DataBoundConstructor public DingTalkSecurityPolicyConfig(boolean checked, String type, String value, String desc) { this.checked = checked; this.type = type; this.value = Secret.fromString(value); this.desc = desc; }
Example 11
Source File: LambdaUploadVariablesTest.java From aws-lambda-jenkins-plugin with MIT License | 5 votes |
@Test public void testGetLambdaClientConfig() throws Exception { LambdaUploadVariables variables = new LambdaUploadVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "FILE", "description DESCRIPTION", "FUNCTION", "HANDLER", "1024", "ROLE", "RUNTIME", "30", true, false, "full", null, false, "subnet1, subnet2", "secgroup"); variables.expandVariables(new EnvVars()); LambdaClientConfig lambdaClientConfig = variables.getLambdaClientConfig(); AWSLambda lambda = lambdaClientConfig.getClient(); assertNotNull(lambda); }
Example 12
Source File: VaultStringCredentialImpl.java From hashicorp-vault-plugin with MIT License | 5 votes |
@NonNull @Override public Secret getSecret() { String k = defaultIfBlank(vaultKey, DEFAULT_VAULT_KEY); String s = getVaultSecret(path, k, engineVersion); if (s == null) { throw new VaultPluginException("Fetching from Vault failed for key " + k, null); } return Secret.fromString(s); }
Example 13
Source File: CredentialsProviderImplTest.java From git-client-plugin with MIT License | 5 votes |
@Before public void setUp() { Secret secret = Secret.fromString(SECRET_VALUE); listener = StreamTaskListener.fromStdout(); StandardUsernameCredentials cred = new StandardUsernamePasswordCredentialsImpl(USER_NAME, secret); provider = new CredentialsProviderImpl(listener, cred); }
Example 14
Source File: LambdaPublishBuildStepVariablesTest.java From aws-lambda-jenkins-plugin with MIT License | 5 votes |
@Test public void testGetPublishConfig() throws Exception { LambdaPublishBuildStepVariables variables = new LambdaPublishBuildStepVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "ARN", "ALIAS", "DESCRIPTION"); PublishConfig publishConfig = variables.getPublishConfig(); assertEquals(variables.getFunctionARN(), publishConfig.getFunctionARN()); assertEquals(variables.getVersionDescription(), publishConfig.getVersionDescription()); assertEquals(variables.getFunctionAlias(), publishConfig.getFunctionAlias()); }
Example 15
Source File: DescriptorImpl.java From qy-wechat-notification-plugin with Apache License 2.0 | 4 votes |
public void setProxyPassword(String proxyPassword) { config.proxyPassword = Secret.fromString(proxyPassword); }
Example 16
Source File: GitLabPushTrigger.java From gitlab-plugin with GNU General Public License v2.0 | 4 votes |
@DataBoundSetter public void setSecretToken(String secretToken) { this.secretToken = Secret.fromString(secretToken); }
Example 17
Source File: GlobalConfigDataForSonarInstance.java From sonar-quality-gates-plugin with MIT License | 4 votes |
public void setPass(String pass) { this.secretPass = Secret.fromString(Util.fixEmptyAndTrim(pass)); }
Example 18
Source File: Site.java From jira-steps-plugin with Apache License 2.0 | 4 votes |
@DataBoundSetter public void setToken(final String token) { this.token = Secret.fromString(Util.fixEmpty(token)); }
Example 19
Source File: ExportTest.java From configuration-as-code-plugin with MIT License | 4 votes |
@DataBoundConstructor public DataBoundSecretField(String mySecretValue) { this.mySecretValue = Secret.fromString(mySecretValue); }
Example 20
Source File: AttributeTest.java From configuration-as-code-plugin with MIT License | 4 votes |
@DataBoundConstructor public SecretFromGetter(String secretField) { this.secretField = Secret.fromString(secretField); }