Skip to content

Commit

Permalink
Merge pull request #17 from Stupnikov-NA/feature/repo-participants
Browse files Browse the repository at this point in the history
Add repository path for retrieving participants
  • Loading branch information
monitorjbl authored Jun 9, 2017
2 parents 7f96a74 + e117e8a commit a2b66c5
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void setDefaults() {
config.setProjectPaths(new ProjectPaths(true, true, true));
}
if(config.getRepoPaths() == null) {
config.setRepoPaths(new RepoPaths(true, true, true, true, true, true, true));
config.setRepoPaths(new RepoPaths(true, true, true, true, true, true, true, true));
}
if(config.getSSHPaths() == null) {
config.setSSHPaths(new SSHPaths(true, true));
Expand Down Expand Up @@ -87,6 +87,7 @@ public AdminConfig doInTransaction() {
BooleanUtils.toBoolean((String) settings.get(repoCommitHistory)),
BooleanUtils.toBoolean((String) settings.get(repoFiles)),
BooleanUtils.toBoolean((String) settings.get(repoPullRequests)),
BooleanUtils.toBoolean((String) settings.get(repoParticipants)),
BooleanUtils.toBoolean((String) settings.get(repoBranchPermissions)),
BooleanUtils.toBoolean((String) settings.get(repoBuildStatus)),
BooleanUtils.toBoolean((String) settings.get(repoBaseDetails))
Expand Down Expand Up @@ -135,6 +136,7 @@ public AdminConfig doInTransaction() {
settings.put(repoCommitHistory, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getCommitHistory()));
settings.put(repoFiles, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getFiles()));
settings.put(repoPullRequests, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getPullRequests()));
settings.put(repoParticipants, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getParticipants()));
settings.put(repoBranchPermissions, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getBranchPermissions()));
settings.put(repoBuildStatus, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getBuildStatus()));
settings.put(repoBaseDetails, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getBaseDetails()));
Expand Down Expand Up @@ -178,6 +180,7 @@ private synchronized AdminConfig getCache() {
public static final String repoCommitHistory = repoPathPrefix + ".commitHistory";
public static final String repoFiles = repoPathPrefix + ".files";
public static final String repoPullRequests = repoPathPrefix + ".pullRequests";
public static final String repoParticipants = repoPathPrefix + ".participants";
public static final String repoBranchPermissions = repoPathPrefix + ".branchPermissions";
public static final String repoBuildStatus = repoPathPrefix + ".buildStatus";
public static final String repoBaseDetails = repoPathPrefix + ".baseDetails";
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/thundermoose/plugins/paths/RepoPaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class RepoPaths implements Paths {
@XmlElement
@Matches({"/rest/api/1.0/projects/*/repos/*/pull-requests/**"})
private boolean pullRequests;
@XmlElement
@Matches({"/rest/api/1.0/projects/*/repos/*/participants"})
private boolean participants;

@XmlElement
@Matches({
Expand All @@ -49,11 +52,12 @@ public class RepoPaths implements Paths {
@Matches({"/rest/api/1.0/projects/*/repos/*"})
private boolean baseDetails;

public RepoPaths(boolean permissions, boolean commitHistory, boolean files, boolean pullRequests, boolean branchPermissions, boolean buildStatus, boolean baseDetails) {
public RepoPaths(boolean permissions, boolean commitHistory, boolean files, boolean pullRequests, boolean participants, boolean branchPermissions, boolean buildStatus, boolean baseDetails) {
this.permissions = permissions;
this.commitHistory = commitHistory;
this.files = files;
this.pullRequests = pullRequests;
this.participants = participants;
this.branchPermissions = branchPermissions;
this.buildStatus = buildStatus;
this.baseDetails = baseDetails;
Expand Down Expand Up @@ -94,6 +98,14 @@ public void setPullRequests(boolean pullRequests) {
this.pullRequests = pullRequests;
}

public boolean getParticipants() {
return participants;
}

public void setParticipants(boolean participants) {
this.participants = participants;
}

public boolean getBranchPermissions() {
return branchPermissions;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ <h2>$i18n.getText("admin.label")</h2>

<div class="description">$i18n.getText("admin.paths.repo.pullRequests.description")</div>
</div>
<div class="checkbox">
<input type="checkbox" id="repo.participants" name="repo.participants" value="true">
<label for="repo.participants">$i18n.getText("admin.paths.repo.participants.label")</label>

<div class="description">#set($messageHtml = $i18n.getText("admin.paths.repo.participants.description"))$messageHtml</div>
</div>
<div class="checkbox">
<input type="checkbox" id="repo.branchPermissions" name="repo.branchPermissions" value="true">
<label for="repo.branchPermissions">$i18n.getText("admin.paths.repo.branchPermissions.label")</label>
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/com/thundermoose/plugins/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ admin.paths.repo.settings.label=Settings
admin.paths.repo.settings.description=/rest/api/1.0/projects/'{'projectKey'}'/repos/'{'repositorySlug'}'/settings/'*'
admin.paths.repo.pullRequests.label=Pull Requests
admin.paths.repo.pullRequests.description=/rest/api/1.0/projects/'{'projectKey'}'/repos/'{'repositorySlug'}'/pull-requests/'*'
admin.paths.repo.participants.label=Participants
admin.paths.repo.participants.description=/rest/api/1.0/projects/'{'projectKey'}'/repos/'{'repositorySlug'}'/participants
admin.paths.repo.commitHistory.label=Commit History
admin.paths.repo.commitHistory.description=/rest/api/1.0/projects/'{'projectKey'}'/repos/'{'repositorySlug'}'/commits/'*' <br/> \
/rest/api/1.0/projects/'{'projectKey'}'/repos/'{'repositorySlug'}'/compare/'*' <br/> \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void before() {
adminConfig.setKey(new KeyGenerator().generateKey());
adminConfig.setAdminPaths(new AdminPaths(true, true, true, true));
adminConfig.setProjectPaths(new ProjectPaths(true, true, true));
adminConfig.setRepoPaths(new RepoPaths(true, true, true, true, true, true, true));
adminConfig.setRepoPaths(new RepoPaths(true, true, true, true, true, true, true, true));
adminConfig.setSSHPaths(new SSHPaths(true, true));
}

Expand Down
20 changes: 20 additions & 0 deletions src/test/java/com/thundermoose/plugins/paths/PathMatcherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ public void testMultiplePaths() {
assertTrue(sut.pathAllowed("/rest/api/1.0/admin/groups/add-user"));
}

@Test
public void testParticipantsPaths() {
RepoPaths repoPaths = new RepoPaths();
repoPaths.setParticipants(true);

PathMatcher sut = new PathMatcher(repoPaths);

assertTrue(sut.pathAllowed("/rest/api/1.0/projects/PROJECT/repos/REPOSITORY/participants"));
}

@Test
public void testDisallowedParticipantsPaths() {
RepoPaths repoPaths = new RepoPaths();
repoPaths.setParticipants(false);

PathMatcher sut = new PathMatcher(repoPaths);

assertFalse(sut.pathAllowed("/rest/api/1.0/projects/PROJECT/repos/REPOSITORY/participants"));
}

@Test
public void testBranchPermissionsPaths() {
RepoPaths repoPaths = new RepoPaths();
Expand Down

0 comments on commit a2b66c5

Please sign in to comment.