| | |
| | | package com.gitblit.tests;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | |
|
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | | import com.gitblit.GitBlitException.UnauthorizedException;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.models.FederationModel;
|
| | | import com.gitblit.models.FederationProposal;
|
| | | import com.gitblit.models.FederationSet;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.ServerSettings;
|
| | | import com.gitblit.models.ServerStatus;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.RpcUtils;
|
| | |
|
| | |
| | |
|
| | | retrievedRepository = findRepository(model.name);
|
| | | assertTrue("Failed to delete " + model.name, retrievedRepository == null);
|
| | |
|
| | | for (UserModel u : RpcUtils.getUsers(url, account, password.toCharArray())) {
|
| | | if (u.username.equals(testMember)) {
|
| | | RpcUtils.deleteUser(u, url, account, password.toCharArray());
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private RepositoryModel findRepository(String name) throws IOException {
|
| | |
| | | account, password.toCharArray());
|
| | | assertTrue("No federation result registrations were retrieved!", registrations.size() > 0);
|
| | | }
|
| | | |
| | |
|
| | | public void testFederationProposals() throws Exception {
|
| | | List<FederationProposal> proposals = RpcUtils.getFederationProposals(url,
|
| | | account, password.toCharArray());
|
| | | List<FederationProposal> proposals = RpcUtils.getFederationProposals(url, account,
|
| | | password.toCharArray());
|
| | | assertTrue("No federation proposals were retrieved!", proposals.size() > 0);
|
| | | }
|
| | | |
| | |
|
| | | public void testFederationSets() throws Exception {
|
| | | List<FederationSet> sets = RpcUtils.getFederationSets(url,
|
| | | account, password.toCharArray());
|
| | | List<FederationSet> sets = RpcUtils.getFederationSets(url, account, password.toCharArray());
|
| | | assertTrue("No federation sets were retrieved!", sets.size() > 0);
|
| | | }
|
| | |
|
| | | public void testSettings() throws Exception {
|
| | | ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());
|
| | | assertTrue("No settings were retrieved!", settings != null);
|
| | | }
|
| | |
|
| | | public void testServerStatus() throws Exception {
|
| | | ServerStatus status = RpcUtils.getStatus(url, account, password.toCharArray());
|
| | | assertTrue("No status was retrieved!", status != null);
|
| | | }
|
| | |
|
| | | public void testUpdateSettings() throws Exception {
|
| | | Map<String, String> updated = new HashMap<String, String>();
|
| | | |
| | | // grab current setting
|
| | | ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());
|
| | | boolean showSizes = settings.get(Keys.web.showRepositorySizes).getBoolean(true);
|
| | | showSizes = !showSizes;
|
| | | |
| | | // update setting
|
| | | updated.put(Keys.web.showRepositorySizes, String.valueOf(showSizes));
|
| | | boolean success = RpcUtils.updateSettings(updated, "http://localhost:8080/gb", account,
|
| | | password.toCharArray());
|
| | | assertTrue("Failed to update server settings", success);
|
| | | |
| | | // confirm setting change
|
| | | settings = RpcUtils.getSettings(url, account, password.toCharArray());
|
| | | boolean newValue = settings.get(Keys.web.showRepositorySizes).getBoolean(false);
|
| | | assertEquals(newValue, showSizes);
|
| | | |
| | | // restore setting
|
| | | newValue = !newValue;
|
| | | updated.put(Keys.web.showRepositorySizes, String.valueOf(newValue));
|
| | | }
|
| | | }
|