Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[FIXED JENKINS-9094] "Remember me" doesn't work with PAM
Originally-Committed-As: ca4de00c2c93b156a3e4ffc1d5c39d13e351792e
- Loading branch information
Showing
with
50 additions
and 8 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
@@ -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())); | ||
} | ||
} |