mirror of
https://github.com/nicolabs/script-realm-plugin.git
synced 2026-04-10 16:14:43 +02:00
In the current version of Hudson, stdout needs to be set or else the process invocation will fail.
This commit is contained in:
parent
394ff24234
commit
5c9562cb24
|
|
@ -26,6 +26,7 @@ package hudson.plugins.script_realm;
|
|||
import hudson.Extension;
|
||||
import hudson.Launcher.LocalLauncher;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.security.AbstractPasswordBasedSecurityRealm;
|
||||
import hudson.security.GroupDetails;
|
||||
import hudson.security.SecurityRealm;
|
||||
|
|
@ -38,6 +39,7 @@ import org.acegisecurity.GrantedAuthority;
|
|||
import org.acegisecurity.userdetails.User;
|
||||
import org.acegisecurity.userdetails.UserDetails;
|
||||
import org.acegisecurity.userdetails.UsernameNotFoundException;
|
||||
import org.apache.commons.io.output.NullOutputStream;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
|
|
@ -59,7 +61,7 @@ public class ScriptSecurityRealm extends AbstractPasswordBasedSecurityRealm {
|
|||
try {
|
||||
StringWriter out = new StringWriter();
|
||||
LocalLauncher launcher = new LocalLauncher(new StreamTaskListener(out));
|
||||
if (launcher.launch().cmds(QuotedStringTokenizer.tokenize(commandLine))
|
||||
if (launcher.launch().cmds(QuotedStringTokenizer.tokenize(commandLine)).stdout(new NullOutputStream())
|
||||
.envs("U="+username,"P="+password).join()!=0)
|
||||
throw new BadCredentialsException(out.toString());
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package hudson.plugins.script_realm;
|
||||
|
||||
import org.acegisecurity.AuthenticationException;
|
||||
import org.jvnet.hudson.test.HudsonTestCase;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ScriptSecurityRealmTest extends HudsonTestCase {
|
||||
public void test1() {
|
||||
new ScriptSecurityRealm("/bin/true").authenticate("test","test");
|
||||
}
|
||||
|
||||
public void test2() {
|
||||
try {
|
||||
new ScriptSecurityRealm("/bin/false").authenticate("test","test");
|
||||
fail();
|
||||
} catch (AuthenticationException e) {
|
||||
// as expected
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue