Package org.jenkinsci.plugins

Examples of org.jenkinsci.plugins.GithubAuthenticationToken


    @Test
    public void should_allow_permission_on_github_org_only_if_member() throws Exception {
        OrganizationContainer organizationContainer = Mockito.mock(OrganizationContainer.class);
        Mockito.when(organizationContainer.getName()).thenReturn("chairman-meow");
        DotCiACL acl = new DotCiACL(organizationContainer, "suryagaddipati", false);
        GithubAuthenticationToken githubAuthentication = getGithubAuthentication("chairman-meow");
        Assert.assertTrue(acl.hasPermission(githubAuthentication, Jenkins.READ));
    }
View Full Code Here


    @Test
    public void should_allow_all_permission_on_github_org_only_if_member() throws Exception {
        DynamicProject project = Mockito.mock(DynamicProject.class);
        Mockito.when(project.getGithubRepoUrl()).thenReturn("https://github.com/groupon/DotCi");
        DotCiACL acl = new DotCiACL(project, "suryagaddipati", false);
        GithubAuthenticationToken githubAuthentication = getGithubAuthentication("chairman-meow");
        Mockito.when(githubAuthentication.hasRepositoryPermission("groupon/DotCi")).thenReturn(true);
        Assert.assertTrue(acl.hasPermission(githubAuthentication, Permission.DELETE));

    }
View Full Code Here

    }



    private GithubAuthenticationToken getGithubAuthentication(String user) {
        GithubAuthenticationToken auth = Mockito.mock(GithubAuthenticationToken.class);
        Mockito.when(auth.getName()).thenReturn(user);
        Mockito.when(auth.isAuthenticated()).thenReturn(true);
        return auth;
    }
View Full Code Here

        GitHub github = PowerMockito.mock(GitHub.class);
        PowerMockito.when(GitHub.connectUsingOAuth("https://localhost/api/v3", "thisismytoken")).thenReturn(github);
        PowerMockito.when(github.getMyself()).thenReturn(myself);
        PowerMockito.when(github.getRepository("groupon/DotCi")).thenReturn(ghRepository);

        GithubAuthenticationToken token = PowerMockito.mock(GithubAuthenticationToken.class);
        PowerMockito.when(token.getGitHub()).thenReturn(github);
        PowerMockito.when(token.getAccessToken()).thenReturn("thisismytoken");
        PowerMockito.when(token.getName()).thenReturn("thisismyname");

        SecurityContext context = PowerMockito.mock(SecurityContext.class);
        PowerMockito.when(context.getAuthentication()).thenReturn(token);
        SecurityContextHolder.setContext(context);
View Full Code Here

        response.sendRedirect2(redirectAfterCreateItem(request, project));
    }

    private GHRepository getGithubRepository(StaplerRequest request) throws IOException {
        String repoName = request.getParameter("fullName");
        GithubAuthenticationToken auth = (GithubAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
        return auth.getGitHub().getRepository(repoName);
    }
View Full Code Here

            throw new RuntimeException(e);
        }
    }

    public static GithubCurrentUserService current() {
        GithubAuthenticationToken auth = (GithubAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
        GitHub gh = auth.getGitHub();
        return new GithubCurrentUserService(gh);
    }
View Full Code Here

    }

      public void put(String url) throws IOException {
        DBObject token = getToken(url);

        GithubAuthenticationToken auth = getAuthentication();
        GitHub gh = auth.getGitHub();
        String accessToken = getEncryptedToken(auth);

            if (token != null) {
                 getCollection().remove(token);
            }
View Full Code Here

TOP

Related Classes of org.jenkinsci.plugins.GithubAuthenticationToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.