Skip to content
Merged
Show file tree
Hide file tree
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 @@ -251,6 +251,7 @@ class NewAction {
private String deprecatedSince;
private boolean post = false;
private boolean isInternal = false;
private boolean supportsScopedOrganizationTokens = false;
private RequestHandler handler;
private Map<String, NewParam> newParams = new HashMap<>();
private URL responseExample = null;
Expand Down Expand Up @@ -309,6 +310,18 @@ public NewAction setInternal(boolean b) {
return this;
}

/**
* Indicates that the action can be authenticated using a SonarQube Cloud scoped
* organization token, in addition to any other supported authentication mechanism.
* This is only relevant to SonarQube Cloud. By default an action does not support it.
*
* @since 13.9
*/
public NewAction setSupportsScopedOrganizationTokens(boolean b) {
this.supportsScopedOrganizationTokens = b;
return this;
}

public NewAction setHandler(RequestHandler h) {
this.handler = h;
return this;
Expand Down Expand Up @@ -511,6 +524,7 @@ class Action {
private final String deprecatedSince;
private final boolean post;
private final boolean isInternal;
private final boolean supportsScopedOrganizationTokens;
private final RequestHandler handler;
private final Map<String, Param> params;
private final URL responseExample;
Expand All @@ -526,6 +540,7 @@ private Action(Controller controller, NewAction newAction) {
this.deprecatedSince = newAction.deprecatedSince;
this.post = newAction.post;
this.isInternal = newAction.isInternal;
this.supportsScopedOrganizationTokens = newAction.supportsScopedOrganizationTokens;
this.responseExample = newAction.responseExample;
this.handler = newAction.handler;
this.changelog = newAction.changelog;
Expand Down Expand Up @@ -602,6 +617,14 @@ public boolean isInternal() {
return isInternal;
}

/**
* @see NewAction#setSupportsScopedOrganizationTokens(boolean)
* @since 13.9
*/
public boolean isSupportsScopedOrganizationTokens() {
Comment thread
aurelien-poscia-sonarsource marked this conversation as resolved.
return supportsScopedOrganizationTokens;
}

public RequestHandler handler() {
return handler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void define_web_service() {
assertThat(showAction.since()).isEqualTo("4.2");
assertThat(showAction.isPost()).isFalse();
assertThat(showAction.isInternal()).isFalse();
assertThat(showAction.isSupportsScopedOrganizationTokens()).isFalse();
assertThat(showAction.path()).isEqualTo("api/metric/show");
WebService.Action createAction = controller.action("create");
assertThat(createAction).isNotNull();
Expand All @@ -89,6 +90,7 @@ public void define_web_service() {
assertThat(createAction.since()).isEqualTo("4.1");
assertThat(createAction.isPost()).isTrue();
assertThat(createAction.isInternal()).isTrue();
assertThat(createAction.isSupportsScopedOrganizationTokens()).isTrue();
assertThat(createAction.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("6.4", "Last event"), tuple("6.0", "Old event"), tuple("4.5.6", "Very old event"));
}
Expand Down Expand Up @@ -539,6 +541,7 @@ public void define(Context context) {
.setDeprecatedSince("5.3")
.setPost(true)
.setInternal(true)
.setSupportsScopedOrganizationTokens(true)
.setResponseExample(getClass().getResource("WebServiceTest/response-example.txt"))
.setChangelog(
new Change("6.4", "Last event"),
Expand Down
Loading