import java.util.List;
import java.util.Optional;
import java.util.Set;
+import org.apache.commons.lang.StringUtils;
import org.sonar.server.common.gitlab.config.GitlabConfiguration;
import org.sonar.server.common.gitlab.config.GitlabConfigurationService;
import org.sonar.server.common.gitlab.config.ProvisioningType;
sortGroups(configuration.allowedGroups()),
configuration.allowUsersToSignUp(),
toRestProvisioningType(configuration),
+ StringUtils.isNotEmpty(configuration.provisioningToken()),
configurationError.orElse(null)
);
}
List.of("group1", "group2"),
GITLAB_CONFIGURATION.allowUsersToSignUp(),
org.sonar.server.v2.api.gitlab.config.resource.ProvisioningType.valueOf(GITLAB_CONFIGURATION.provisioningType().name()),
+ !GITLAB_CONFIGURATION.provisioningToken().isEmpty(),
"error-message");
private static final String EXPECTED_CONFIGURATION = """
],
"provisioningType": "AUTO_PROVISIONING",
"allowUsersToSignUp": true,
- "errorMessage": "error-message"
+ "errorMessage": "error-message",
+ "isProvisioningTokenSet": true
}
""";
NonNullUpdatedValue.undefined(),
NonNullUpdatedValue.undefined(),
NonNullUpdatedValue.undefined(),
- NonNullUpdatedValue.undefined(), NonNullUpdatedValue.withValueOrThrow(false), UpdatedValue.withValue(null), NonNullUpdatedValue.withValueOrThrow(JIT)
+ NonNullUpdatedValue.undefined(),
+ NonNullUpdatedValue.withValueOrThrow(false),
+ UpdatedValue.withValue(null),
+ NonNullUpdatedValue.withValueOrThrow(JIT)
));
}
"group2"
],
"provisioningType": "AUTO_PROVISIONING",
+ "provisioningToken": "token",
"allowUsersToSignUp": true
}
"group2"
],
"provisioningType": "AUTO_PROVISIONING",
- "allowUsersToSignUp": true
+ "allowUsersToSignUp": true,
+ "isProvisioningTokenSet": true
}
"""));
@Test
public void create_whenConfigCreatedWithoutOptionalParams_returnsIt() throws Exception {
userSession.logIn().setSystemAdministrator();
- when(gitlabConfigurationService.createConfiguration(any())).thenReturn(GITLAB_CONFIGURATION);
+ when(gitlabConfigurationService.createConfiguration(any())).thenReturn(new GitlabConfiguration(
+ "existing-id",
+ true,
+ "application-id",
+ "www.url.com",
+ "secret",
+ true,
+ Set.of("group1", "group2"),
+ false,
+ AUTO_PROVISIONING,
+ null
+ ));
mockMvc.perform(
post(GITLAB_CONFIGURATION_ENDPOINT)
"group2"
],
"provisioningType": "AUTO_PROVISIONING",
- "allowUsersToSignUp": true
+ "allowUsersToSignUp": false,
+ "isProvisioningTokenSet": false
}
"""));