@@ -60,6 +60,7 @@ of this software and associated documentation files (the "Software"), to deal
6060import java .util .Collections ;
6161import java .util .List ;
6262
63+ import hudson .model .Computer ;
6364import hudson .model .Hudson ;
6465import hudson .model .Item ;
6566import hudson .model .Messages ;
@@ -555,6 +556,30 @@ public void testCannotReadRepositoryWithInvalidRepoUrl() throws IOException {
555556 }
556557 }
557558
559+ @ Test
560+ public void testAgentUserCanCreateConnectAndConfigureAgents () {
561+ GithubAuthenticationToken authenticationToken = Mockito .mock (GithubAuthenticationToken .class );
562+ Mockito .when (authenticationToken .isAuthenticated ()).thenReturn (true );
563+ Mockito .when (authenticationToken .getName ()).thenReturn ("agent" );
564+ GithubRequireOrganizationMembershipACL acl = createACL ();
565+
566+ assertTrue (acl .hasPermission (authenticationToken , Computer .CREATE ));
567+ assertTrue (acl .hasPermission (authenticationToken , Computer .CONFIGURE ));
568+ assertTrue (acl .hasPermission (authenticationToken , Computer .CONNECT ));
569+ }
570+
571+ @ Test
572+ public void testAuthenticatedCanNotCreateConnectAndConfigureAgents () {
573+ GithubAuthenticationToken authenticationToken = Mockito .mock (GithubAuthenticationToken .class );
574+ Mockito .when (authenticationToken .isAuthenticated ()).thenReturn (true );
575+ Mockito .when (authenticationToken .getName ()).thenReturn ("authenticated" );
576+ GithubRequireOrganizationMembershipACL acl = createACL ();
577+
578+ assertFalse (acl .hasPermission (authenticationToken , Computer .CREATE ));
579+ assertFalse (acl .hasPermission (authenticationToken , Computer .CONFIGURE ));
580+ assertFalse (acl .hasPermission (authenticationToken , Computer .CONNECT ));
581+ }
582+
558583 @ Test
559584 public void testAnonymousCanViewJobStatusWhenGranted () {
560585 this .allowAnonymousJobStatusPermission = true ;
0 commit comments