当前位置: 首页>>代码示例>>Java>>正文


Java CredentialsScope.GLOBAL属性代码示例

本文整理汇总了Java中com.cloudbees.plugins.credentials.CredentialsScope.GLOBAL属性的典型用法代码示例。如果您正苦于以下问题:Java CredentialsScope.GLOBAL属性的具体用法?Java CredentialsScope.GLOBAL怎么用?Java CredentialsScope.GLOBAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.cloudbees.plugins.credentials.CredentialsScope的用法示例。


在下文中一共展示了CredentialsScope.GLOBAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRecorderInvalidToken

/**
 * 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());
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:28,代码来源:MarathonRecorderTest.java

示例2: getDockerServerCredentials

public DockerServerCredentials getDockerServerCredentials() throws IOException {
    final LocalDirectorySSLConfig sslContext = (LocalDirectorySSLConfig) clientConfig.getSSLConfig();

    assertThat("DockerCli must be connected via SSL", sslContext, notNullValue());

    String certPath = sslContext.getDockerCertPath();

    final String keypem = FileUtils.readFileToString(new File(certPath + "/" + "key.pem"));
    final String certpem = FileUtils.readFileToString(new File(certPath + "/" + "cert.pem"));
    final String capem = FileUtils.readFileToString(new File(certPath + "/" + "ca.pem"));

    return new DockerServerCredentials(
            CredentialsScope.GLOBAL, // scope
            null, // name
            null, //desc
            keypem,
            certpem,
            capem
    );
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:20,代码来源:DockerRule.java

示例3: prepareGitHubPlugin

/**
 * Prepare global GitHub plugin configuration.
 * Nothing specific to job.
 */
public static GitHubServerConfig prepareGitHubPlugin() {
    // prepare global jRule settings
    final StringCredentialsImpl cred = new StringCredentialsImpl(
            CredentialsScope.GLOBAL,
            null,
            "description",
            Secret.fromString(GH_TOKEN)
    );

    SystemCredentialsProvider.getInstance().getCredentials().add(cred);

    final GitHubPluginConfig gitHubPluginConfig = GitHubPlugin.configuration();

    final List<GitHubServerConfig> gitHubServerConfigs = new ArrayList<>();
    final GitHubServerConfig gitHubServerConfig = new GitHubServerConfig(cred.getId());
    gitHubServerConfig.setManageHooks(false);
    gitHubServerConfig.setClientCacheSize(0);
    gitHubServerConfigs.add(gitHubServerConfig);

    gitHubPluginConfig.setConfigs(gitHubServerConfigs);

    return gitHubServerConfig;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:27,代码来源:GHRule.java

示例4: sshagent

@Issue({ "JENKINS-47225", "JENKINS-42582" })
@Test
public void sshagent() throws Exception {
    PrivateKeySource source = new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(
            new String(IOUtils.toByteArray(getClass().getResourceAsStream("id_rsa"))));
    BasicSSHUserPrivateKey credentials = new BasicSSHUserPrivateKey(CredentialsScope.GLOBAL,
            "ContainerExecDecoratorPipelineTest-sshagent", "bob", source, "secret_passphrase", "test credentials");
    SystemCredentialsProvider.getInstance().getCredentials().add(credentials);

    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "sshagent");
    p.setDefinition(new CpsFlowDefinition(loadPipelineScript("sshagent.groovy"), true));
    WorkflowRun b = p.scheduleBuild2(0).waitForStart();
    assertNotNull(b);
    r.waitForCompletion(b);
    r.assertLogContains("Identity added:", b);
    //check that we don't accidentally start exporting sensitive info to the log
    r.assertLogNotContains("secret_passphrase", b);
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:18,代码来源:ContainerExecDecoratorPipelineTest.java

示例5: testMultiBranchClassicWithCredentialsInFolder

@Test
public void testMultiBranchClassicWithCredentialsInFolder() throws Exception {

	WorkflowMultiBranchProject multi = jenkins.jenkins.createProject(WorkflowMultiBranchProject.class, "multi-classic-creds-in-folder");

	CredentialsStore folderStore = getFolderStore(multi);
	P4BaseCredentials inFolderCredentials = new P4PasswordImpl(
			CredentialsScope.GLOBAL, "idInFolder", "desc:passwd", p4d.getRshPort(),
			null, "jenkins", "0", "0", null, "jenkins");
	folderStore.addCredentials(Domain.global(), inFolderCredentials);

	String format = "jenkins-${NODE_NAME}-${JOB_NAME}";
	String includes = "//stream/...";
	SCMSource source = new BranchesScmSource(inFolderCredentials.getId(), includes, null, format);
	multi.getSourcesList().add(new BranchSource(source));
	multi.scheduleBuild2(0);
	jenkins.waitUntilNoActivity();

	assertEquals("Branch Indexing succeeded", Result.SUCCESS, multi.getComputation().getResult());
	assertThat("We now have branches", multi.getItems(), not(containsInAnyOrder()));
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:21,代码来源:PerforceScmSourceTest.java

示例6: testMultiBranchStreamWithCredentialsInFolder

@Test
public void testMultiBranchStreamWithCredentialsInFolder() throws Exception {

	WorkflowMultiBranchProject multi = jenkins.jenkins.createProject(WorkflowMultiBranchProject.class, "multi-streams-creds-in-folder");

	CredentialsStore folderStore = getFolderStore(multi);
	P4BaseCredentials inFolderCredentials = new P4PasswordImpl(
			CredentialsScope.GLOBAL, "idInFolder", "desc:passwd", p4d.getRshPort(),
			null, "jenkins", "0", "0", null, "jenkins");
	folderStore.addCredentials(Domain.global(), inFolderCredentials);

	String format = "jenkins-${NODE_NAME}-${JOB_NAME}";
	String includes = "//stream/...";
	SCMSource source = new StreamsScmSource(inFolderCredentials.getId(), includes, null, format);
	multi.getSourcesList().add(new BranchSource(source));
	multi.scheduleBuild2(0);
	jenkins.waitUntilNoActivity();

	assertEquals("Branch Indexing succeeded", Result.SUCCESS, multi.getComputation().getResult());
	assertThat("We now have branches", multi.getItems(), not(containsInAnyOrder()));
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:21,代码来源:PerforceScmSourceTest.java

示例7: testAvailableCredentialsAtRoot

@Test
public void testAvailableCredentialsAtRoot() throws IOException {
	P4BaseCredentials systemCredentials = new P4PasswordImpl(
			CredentialsScope.SYSTEM, "idSystem", "desc:passwd", "localhost:1666",
			null, "user", "0", "0", null, "pass");

	P4BaseCredentials globalCredentials = new P4PasswordImpl(
			CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", "localhost:1666",
			null, "user", "0", "0", null, "pass");

	assertTrue(lookupCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
	SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
	SystemCredentialsProvider.getInstance().save();
	assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());

	List<P4BaseCredentials> list = lookupCredentials();
	assertEquals(2, list.size());
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:19,代码来源:PerforceCredentialsTest.java

示例8: testAvailableCredentialsInJob

@Test
public void testAvailableCredentialsInJob() throws IOException {
	Job job = jenkins.createFreeStyleProject("testAvailableCredentialsInJob");

	P4BaseCredentials systemCredentials = new P4PasswordImpl(
			CredentialsScope.SYSTEM, "idSystem", "desc:passwd", "localhost:1666",
			null, "user", "0", "0", null, "pass");

	P4BaseCredentials globalCredentials = new P4PasswordImpl(
			CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", "localhost:1666",
			null, "user", "0", "0", null, "pass");

	assertTrue(lookupCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
	SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
	SystemCredentialsProvider.getInstance().save();
	assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());

	List<P4BaseCredentials> list = CredentialsProvider.lookupCredentials(P4BaseCredentials.class,
			job, ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
	assertEquals(1, list.size());
	assertEquals(globalCredentials.getId(), list.get(0).getId());
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:23,代码来源:PerforceCredentialsTest.java

示例9: basicsPipeline

@Test
public void basicsPipeline() throws Exception {
	// create the Credentials
	String alias = "androiddebugkey";
	String password = "android";
	StandardCertificateCredentials c = new CertificateCredentialsImpl(CredentialsScope.GLOBAL, "my-certificate", alias,
			password, new CertificateCredentialsImpl.FileOnMasterKeyStoreSource(certificate.getAbsolutePath()));
	CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), c);
	// create the Pipeline job
	WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
	String pipelineScript = IOUtils.toString(getTestResourceInputStream("basicsPipeline-Jenkinsfile"));
	p.setDefinition(new CpsFlowDefinition(pipelineScript, true));
	// copy resources into workspace
	FilePath workspace = r.jenkins.getWorkspaceFor(p);
	copyTestResourceIntoWorkspace(workspace, "basicsPipeline-step1.bat", 0755);
	copyTestResourceIntoWorkspace(workspace, "basicsPipeline-step2.bat", 0755);
	copyTestResourceIntoWorkspace(workspace, "basicsPipeline-step1.sh", 0755);
	copyTestResourceIntoWorkspace(workspace, "basicsPipeline-step2.sh", 0755);
	// execute the pipeline
	WorkflowRun b = p.scheduleBuild2(0).waitForStart();
	r.waitForCompletion(b);
	r.assertBuildStatusSuccess(b);
}
 
开发者ID:jenkinsci,项目名称:credentials-binding-plugin,代码行数:23,代码来源:CertificateMultiBindingTest.java

示例10: secretBuildWrapperRunsBeforeNormalWrapper

@Issue("JENKINS-37871")
@Test public void secretBuildWrapperRunsBeforeNormalWrapper() throws Exception {
    StringCredentialsImpl firstCreds = new StringCredentialsImpl(CredentialsScope.GLOBAL, credentialsId, "sample1", Secret.fromString(password));

    CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), firstCreds);

    SecretBuildWrapper wrapper = new SecretBuildWrapper(Arrays.asList(new StringBinding(bindingKey, credentialsId)));

    FreeStyleProject f = r.createFreeStyleProject("buildWrapperOrder");

    f.getBuildersList().add(Functions.isWindows() ? new BatchFile("echo %PASS_1%") : new Shell("echo $PASS_1"));
    f.getBuildWrappersList().add(new BuildWrapperOrder());
    f.getBuildWrappersList().add(wrapper);

    // configRoundtrip makes sure the ordinal of SecretBuildWrapper extension is applied correctly.
    r.configRoundtrip(f);

    FreeStyleBuild b = r.buildAndAssertSuccess(f);
    r.assertLogContains("Secret found!", b);
}
 
开发者ID:jenkinsci,项目名称:credentials-binding-plugin,代码行数:20,代码来源:BuildWrapperOrderCredentialsBindingTest.java

示例11: basics

@Test public void basics() throws Exception {
    String username = "bob";
    String password = "s3cr3t";
    UsernamePasswordCredentialsImpl c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, "sample", username, password);
    CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), c);
    FreeStyleProject p = r.createFreeStyleProject();
    p.getBuildWrappersList().add(new SecretBuildWrapper(Collections.<Binding<?>>singletonList(new UsernamePasswordBinding("AUTH", c.getId()))));
    p.getBuildersList().add(Functions.isWindows() ? new BatchFile("echo %AUTH% > auth.txt") : new Shell("echo $AUTH > auth.txt"));
    r.configRoundtrip(p);
    SecretBuildWrapper wrapper = p.getBuildWrappersList().get(SecretBuildWrapper.class);
    assertNotNull(wrapper);
    List<? extends MultiBinding<?>> bindings = wrapper.getBindings();
    assertEquals(1, bindings.size());
    MultiBinding<?> binding = bindings.get(0);
    assertEquals(c.getId(), binding.getCredentialsId());
    assertEquals(UsernamePasswordBinding.class, binding.getClass());
    assertEquals("AUTH", ((UsernamePasswordBinding) binding).getVariable());
    FreeStyleBuild b = r.buildAndAssertSuccess(p);
    r.assertLogNotContains(password, b);
    assertEquals(username + ':' + password, b.getWorkspace().child("auth.txt").readToString().trim());
    assertEquals("[AUTH]", b.getSensitiveBuildVariables().toString());
}
 
开发者ID:jenkinsci,项目名称:credentials-binding-plugin,代码行数:22,代码来源:UsernamePasswordBindingTest.java

示例12: configRoundtrip

@Test
public void configRoundtrip() throws Exception {
    PersonalAccessTokenImpl expected = new PersonalAccessTokenImpl(
            CredentialsScope.GLOBAL,
            "magic-id",
            "configRoundtrip",
            "b5bc10f13665362bd61de931c731e3c74187acc4");
    CredentialsBuilder builder = new CredentialsBuilder(expected);
    j.configRoundtrip(builder);
    j.assertEqualDataBoundBeans(expected, builder.credentials);
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:11,代码来源:PersonalAccessTokenImplTest.java

示例13: testRecorderBasicToken

/**
 * Test a basic API token using StringCredentials.
 *
 * @throws Exception
 */
@Test
public void testRecorderBasicToken() throws Exception {
    final FreeStyleProject                       project     = j.createFreeStyleProject();
    final String                                 responseStr = "{\"version\": \"one\", \"deploymentId\": \"someid-here\"}";
    final SystemCredentialsProvider.ProviderImpl system      = ExtensionList.lookup(CredentialsProvider.class).get(SystemCredentialsProvider.ProviderImpl.class);
    final CredentialsStore                       systemStore = system.getStore(j.getInstance());
    final String                                 tokenValue  = "my secret token";
    final Secret                                 secret      = Secret.fromString(tokenValue);
    final StringCredentials                      credential  = new StringCredentialsImpl(CredentialsScope.GLOBAL, "basictoken", "a token for basic token test", secret);
    TestUtils.enqueueJsonResponse(httpServer, responseStr);
    systemStore.addCredentials(Domain.global(), credential);

    // add builders
    addBuilders(TestUtils.loadFixture("idonly.json"), project);
    // add post-builder
    addPostBuilders(project, "basictoken");

    final FreeStyleBuild build = j.assertBuildStatusSuccess(project.scheduleBuild2(0).get());
    j.assertLogContains("[Marathon]", build);

    // handler assertions
    assertEquals("Only 1 request should be made", 1, httpServer.getRequestCount());
    RecordedRequest request = httpServer.takeRequest();

    final String authorizationText = request.getHeader("Authorization");
    assertEquals("Token does not match", "token=" + tokenValue, authorizationText);
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:32,代码来源:MarathonRecorderTest.java

示例14: testRecorderJSONToken

/**
 * Test that a JSON credential with "jenkins_token" uses the token value as the authentication token.
 *
 * @throws Exception
 */
@Test
public void testRecorderJSONToken() throws Exception {
    final FreeStyleProject                       project         = j.createFreeStyleProject();
    final String                                 responseStr     = "{\"version\": \"one\", \"deploymentId\": \"someid-here\"}";
    final SystemCredentialsProvider.ProviderImpl system          = ExtensionList.lookup(CredentialsProvider.class).get(SystemCredentialsProvider.ProviderImpl.class);
    final CredentialsStore                       systemStore     = system.getStore(j.getInstance());
    final String                                 tokenValue      = "my secret token";
    final String                                 credentialValue = "{\"field1\":\"some value\", \"jenkins_token\":\"" + tokenValue + "\"}";
    final Secret                                 secret          = Secret.fromString(credentialValue);
    final StringCredentials                      credential      = new StringCredentialsImpl(CredentialsScope.GLOBAL, "jsontoken", "a token for JSON token test", secret);
    TestUtils.enqueueJsonResponse(httpServer, responseStr);
    systemStore.addCredentials(Domain.global(), credential);

    // add builders
    addBuilders(TestUtils.loadFixture("idonly.json"), project);

    // add post-builder
    addPostBuilders(project, "jsontoken");

    final FreeStyleBuild build = j.assertBuildStatusSuccess(project.scheduleBuild2(0).get());
    j.assertLogContains("[Marathon]", build);

    // handler assertions
    assertEquals("Only 1 request should be made", 1, httpServer.getRequestCount());
    RecordedRequest request           = httpServer.takeRequest();
    final String    authorizationText = request.getHeader("Authorization");
    assertEquals("Token does not match", "token=" + tokenValue, authorizationText);
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:33,代码来源:MarathonRecorderTest.java

示例15: BrowserStackCredentials

@DataBoundConstructor
public BrowserStackCredentials(String id, String description, String username, String accesskey) {
    super(CredentialsScope.GLOBAL);
    this.id = IdCredentials.Helpers.fixEmptyId(id);
    this.description = Util.fixNull(description);
    this.username = Util.fixNull(username);
    this.accesskey = Secret.fromString(accesskey);
    Analytics.trackInstall();
}
 
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:9,代码来源:BrowserStackCredentials.java


注:本文中的com.cloudbees.plugins.credentials.CredentialsScope.GLOBAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。