Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-9094] "Remember me" doesn't work with PAM
- Loading branch information
Showing
4 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/src/test/java/hudson/security/PAMSecurityRealmTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package hudson.security; | ||
|
||
import hudson.Functions; | ||
import hudson.security.SecurityRealm.SecurityComponents; | ||
import org.acegisecurity.userdetails.UsernameNotFoundException; | ||
import org.jvnet.hudson.test.HudsonTestCase; | ||
|
||
import java.util.Arrays; | ||
|
||
import static hudson.util.jna.GNUCLibrary.*; | ||
|
||
/** | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class PAMSecurityRealmTest extends HudsonTestCase { | ||
public void testLoadUsers() { | ||
if (Functions.isWindows()) return; // skip on Windows | ||
|
||
SecurityComponents sc = new PAMSecurityRealm("sshd").getSecurityComponents(); | ||
|
||
try { | ||
sc.userDetails.loadUserByUsername("bogus-bogus-bogus"); | ||
fail("no such user"); | ||
} catch (UsernameNotFoundException e) { | ||
// expected | ||
} | ||
|
||
String name = LIBC.getpwuid(LIBC.geteuid()).pw_name; | ||
|
||
System.out.println(Arrays.asList(sc.userDetails.loadUserByUsername(name).getAuthorities())); | ||
} | ||
} |