Commit e6ff4201 authored by harshit aggarwal's avatar harshit aggarwal
Browse files

Initial commit

parent 1fd77123
Pipeline #9879 failed with stages
in 3 minutes and 24 seconds
......@@ -107,6 +107,12 @@
<artifactId>httpcore</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -60,7 +60,7 @@
<springfox-version>2.7.0</springfox-version>
<reactor.netty.version>0.9.0.RELEASE</reactor.netty.version>
<reactor.core.version>3.3.0.RELEASE</reactor.core.version>
<osdu.azurecore.version>0.0.19</osdu.azurecore.version>
<osdu.azurecore.version>0.0.28</osdu.azurecore.version>
</properties>
<licenses>
......
......@@ -16,14 +16,19 @@ package org.opengroup.osdu.azure.entitlements.di;
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import javax.inject.Named;
@Configuration
@Getter
public class AzureBootstrapConfig {
@Value("${azure.keyvault.url}")
private String keyVaultURL;
......@@ -54,6 +59,16 @@ public class AzureBootstrapConfig {
@Value("${azure.graph-api.version}")
private String graphApiVersion ;
private String appDevSpObjectId;
@Autowired
private SecretClient secretClient;
@PostConstruct
public void setAppDevSpObjectId() {
appDevSpObjectId = getKeyVaultSecret(secretClient,"app-dev-sp-object-id");
}
@Bean
@Named("APP_DEV_SP_TENANT_ID")
public String appDevSpTenantId(SecretClient kv) {
......
......@@ -71,7 +71,7 @@ public class GroupInfoRepository {
* @param tenantId
* @return The tenant info.
*/
private Optional<TenantInfoDoc> findTenantInfo(String tenantId) {
public Optional<TenantInfoDoc> findTenantInfo(String tenantId) {
return cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, tenantInfoContainer, tenantId, tenantId, TenantInfoDoc.class);
}
}
\ No newline at end of file
......@@ -19,9 +19,11 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.azure.entitlements.di.AzureBootstrapConfig;
import org.opengroup.osdu.azure.entitlements.dto.CreateGroupRequest;
import org.opengroup.osdu.azure.entitlements.graph.IGraphService;
import org.opengroup.osdu.azure.entitlements.model.GroupInfoDoc;
import org.opengroup.osdu.azure.entitlements.model.TenantInfoDoc;
import org.opengroup.osdu.azure.entitlements.repository.GroupInfoRepository;
import org.opengroup.osdu.azure.entitlements.model.UserInfoDoc;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
......@@ -79,6 +81,9 @@ public class EntitlementsAzure
@Autowired
private IGraphService graphService;
@Autowired
private AzureBootstrapConfig azureBootstrapConfig;
@Data
@NoArgsConstructor
@AllArgsConstructor
......@@ -241,6 +246,25 @@ public class EntitlementsAzure
String[] userTenantGroups = userInfoRepository.getTenantGroups(oid, headers.getPartitionId());
// String[] userTenantGroups;
// if(oid.equals(azureBootstrapConfig.getAppDevSpObjectId())) {
// try {
// Optional<TenantInfoDoc> result = groupInfoRepository.findTenantInfo(headers.getPartitionId());
// if(!result.isPresent()) {
// throw new AppException(HttpStatus.SC_NOT_FOUND, "tenant not found", "the tenant does not exist");
// }
// userTenantGroups = result.get().getGroups();
// }
// catch (AppException exception) {
// throw new AppException(exception.getError().getCode(), exception.getError().getReason(), exception.getError().getMessage());
// }
// }
// else {
// userTenantGroups = userInfoRepository.getTenantGroups(oid, headers.getPartitionId());
// }
List<GroupInfo> groupInfoList = new ArrayList();
for (String groupName : userTenantGroups) {
......
......@@ -24,7 +24,7 @@ import static org.mockito.Mockito.doReturn;
public class AzureBootstrapConfigTest {
private AzureBootstrapConfig bootstrapConfig = new AzureBootstrapConfig();
private AzureBootstrapConfig bootstrapConfig = new AzureBootstrapConfig(Mockito.mock(SecretClient.class));
private SecretClient kv = Mockito.mock(SecretClient.class);
@Test(expected = IllegalStateException.class)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment