Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt tests to categorised user properties #173

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading