Skip to content

Commit

Permalink
Adapt tests to categorised user properties (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Jun 9, 2024
1 parent 668e35e commit c866a83
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import hudson.model.User;
import hudson.util.FormValidation;

import static org.htmlunit.html.HtmlFormUtil.submit;
import static org.junit.Assert.*;

import org.htmlunit.FailingHttpStatusCodeException;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
Expand All @@ -23,11 +27,25 @@ public void dsa() throws Exception {
testRoundtrip(PUBLIC_DSA_KEY);
}

public User configRoundtrip(User u) throws Exception {
try {
submit(r.createWebClient().goTo(u.getUrl() + "/security/").getFormByName("config"));
} catch (FailingHttpStatusCodeException e) {
// prior to https://github.com/jenkinsci/jenkins/pull/7268
if (e.getStatusCode() == 404) {
r.configRoundtrip(u);
} else {
throw e;
}
}
return u;
}

private void testRoundtrip(String publicKey) throws Exception {
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
User foo = User.getById("foo", true);
foo.addProperty(new UserPropertyImpl(publicKey));
r.configRoundtrip(foo);
configRoundtrip(foo);
assertEquals(publicKey, foo.getProperty(UserPropertyImpl.class).authorizedKeys);
}

Expand Down

0 comments on commit c866a83

Please sign in to comment.