Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Security and Compliance
entitlements-azure
Commits
9741a49a
Commit
9741a49a
authored
Jul 21, 2020
by
harshit aggarwal
Browse files
making changes to use CosmosStore instead of CosmosFacade
parent
c9291761
Pipeline
#3941
failed with stages
in 12 minutes and 38 seconds
Changes
6
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
9741a49a
...
...
@@ -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.
6-SNAPSHOT
</osdu.azurecore.version>
<osdu.azurecore.version>
0.0.
10
</osdu.azurecore.version>
</properties>
<licenses>
...
...
src/main/java/org/opengroup/osdu/azure/entitlements/di/CosmosContainerConfig.java
View file @
9741a49a
package
org.opengroup.osdu.azure.entitlements.di
;
import
com.azure.cosmos.CosmosClient
;
import
com.azure.cosmos.CosmosContainer
;
import
org.opengroup.osdu.common.Validators
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
javax.inject.Named
;
public
class
CosmosContainerConfig
{
@Autowired
private
CosmosClient
cosmosClient
;
@Autowired
private
String
cosmosDBName
;
@Value
(
"${userinfo.container.name}"
)
private
String
userInfoContainerName
;
@Value
(
"${tenantinfo.container.name}"
)
private
String
tenantInfoContainerName
;
@Bean
@Named
(
"userInfoContainer"
)
public
CosmosContainer
UserInfoContainer
()
{
Validators
.
checkNotNull
(
cosmosClient
,
"Cosmos client cannot be null"
);
Validators
.
checkNotNullAndNotEmpty
(
cosmosDBName
,
"Cosmos DB Name"
);
Validators
.
checkNotNullAndNotEmpty
(
userInfoContainerName
,
"Cosmos container name"
);
return
cosmosClient
.
getDatabase
(
cosmosDBName
).
getContainer
(
userInfoContainerName
);
public
String
userInfoContainer
(){
return
userInfoContainerName
;
}
@Bean
@Named
(
"tenantInfoContainer"
)
public
CosmosContainer
TenantInfoContainer
()
{
Validators
.
checkNotNull
(
cosmosClient
,
"Cosmos client cannot be null"
);
Validators
.
checkNotNullAndNotEmpty
(
cosmosDBName
,
"Cosmos DB Name"
);
Validators
.
checkNotNullAndNotEmpty
(
tenantInfoContainerName
,
"Cosmos container name"
);
return
cosmosClient
.
getDatabase
(
cosmosDBName
).
getContainer
(
tenantInfoContainerName
);
public
String
tenantInfoContainer
(){
return
tenantInfoContainerName
;
}
}
\ No newline at end of file
src/main/java/org/opengroup/osdu/azure/entitlements/repository/GroupInfoRepository.java
View file @
9741a49a
...
...
@@ -14,16 +14,15 @@
package
org.opengroup.osdu.azure.entitlements.repository
;
import
com.azure.cosmos.CosmosContainer
;
import
org.apache.http.HttpStatus
;
import
org.opengroup.osdu.azure.Cosmos
Facad
e
;
import
org.opengroup.osdu.azure.Cosmos
Stor
e
;
import
org.opengroup.osdu.azure.entitlements.model.GroupInfoDoc
;
import
org.opengroup.osdu.azure.entitlements.model.TenantInfoDoc
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
javax.inject.Named
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -33,8 +32,16 @@ import java.util.Optional;
public
class
GroupInfoRepository
{
@Autowired
@Named
(
"tenantInfoContainer"
)
private
CosmosContainer
tenantInfoContainer
;
private
CosmosStore
cosmosStore
;
@Autowired
private
String
tenantInfoContainer
;
@Autowired
private
String
cosmosDBName
;
@Autowired
private
DpsHeaders
headers
;
/**
* Method to update the group in Azure Cosmos DB.
...
...
@@ -56,7 +63,7 @@ public class GroupInfoRepository {
groupNameList
.
add
(
groupName
);
tenantInfoDoc
.
setGroups
(
groupNameList
.
toArray
(
new
String
[
0
]));
C
osmos
Facad
e
.
upsertItem
(
tenantInfoContainer
,
tenantInfoDoc
);
c
osmos
Stor
e
.
upsertItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
tenantInfoContainer
,
tenantInfoDoc
);
}
/**
...
...
@@ -65,6 +72,6 @@ public class GroupInfoRepository {
* @return The tenant info.
*/
private
Optional
<
TenantInfoDoc
>
findTenantInfo
(
String
tenantId
)
{
return
C
osmos
Facad
e
.
findItem
(
tenantInfoContainer
,
tenantId
,
tenantId
,
TenantInfoDoc
.
class
);
return
c
osmos
Stor
e
.
findItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
tenantInfoContainer
,
tenantId
,
tenantId
,
TenantInfoDoc
.
class
);
}
}
\ No newline at end of file
src/main/java/org/opengroup/osdu/azure/entitlements/repository/UserInfoRepository.java
View file @
9741a49a
...
...
@@ -14,16 +14,18 @@
package
org.opengroup.osdu.azure.entitlements.repository
;
import
com.azure.cosmos.*
;
import
org.opengroup.osdu.azure.CosmosFacade
;
import
com.azure.cosmos.FeedOptions
;
import
com.azure.cosmos.SqlParameter
;
import
com.azure.cosmos.SqlParameterList
;
import
com.azure.cosmos.SqlQuerySpec
;
import
org.opengroup.osdu.azure.CosmosStore
;
import
org.opengroup.osdu.azure.entitlements.model.UserInfoDoc
;
import
org.opengroup.osdu.azure.entitlements.model.UserTenantItem
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.stereotype.Repository
;
import
javax.inject.Named
;
import
java.util.Arrays
;
import
java.util.Optional
;
import
java.util.logging.Logger
;
...
...
@@ -31,12 +33,19 @@ import java.util.logging.Logger;
@Repository
public
class
UserInfoRepository
{
private
static
Logger
logger
=
Logger
.
getLogger
(
UserInfoRepository
.
class
.
getName
());
@Autowired
@Named
(
"userInfoContainer"
)
private
CosmosContainer
userInfoContainer
;
private
CosmosStore
cosmosStore
;
@Autowired
private
String
userInfoContainer
;
@Autowired
private
String
cosmosDBName
;
@Autowired
private
DpsHeaders
headers
;
/**
* Accessor for getting the tenant groips from Azure Cosmos DB.
...
...
@@ -69,7 +78,7 @@ public class UserInfoRepository
UserTenantItem
existingTenant
=
getTenant
(
userInfoDoc
,
tenantName
);
existingTenant
.
setGroups
(
tenantGroups
);
C
osmos
Facad
e
.
upsertItem
(
userInfoContainer
,
userInfoDoc
);
c
osmos
Stor
e
.
upsertItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
userInfoDoc
);
}
/**
...
...
@@ -99,7 +108,7 @@ public class UserInfoRepository
FeedOptions
options
=
new
FeedOptions
();
options
.
setEnableCrossPartitionQuery
(
true
);
String
[]
members
=
C
osmos
Facad
e
.
queryItems
(
userInfoContainer
,
query
,
options
,
UserInfoDoc
.
class
).
stream
().
map
(
doc
->
doc
.
getId
()).
toArray
(
String
[]::
new
);
String
[]
members
=
c
osmos
Stor
e
.
queryItems
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
query
,
options
,
UserInfoDoc
.
class
).
stream
().
map
(
doc
->
doc
.
getId
()).
toArray
(
String
[]::
new
);
return
members
;
}
...
...
@@ -117,7 +126,7 @@ public class UserInfoRepository
FeedOptions
options
=
new
FeedOptions
();
options
.
setEnableCrossPartitionQuery
(
true
);
String
[]
members
=
C
osmos
Facad
e
.
queryItems
(
userInfoContainer
,
query
,
options
,
UserInfoDoc
.
class
).
stream
().
map
(
doc
->
doc
.
getUid
()).
toArray
(
String
[]::
new
);
String
[]
members
=
c
osmos
Stor
e
.
queryItems
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
query
,
options
,
UserInfoDoc
.
class
).
stream
().
map
(
doc
->
doc
.
getUid
()).
toArray
(
String
[]::
new
);
return
members
;
}
...
...
@@ -127,7 +136,7 @@ public class UserInfoRepository
* @param upn The UPN of the user. This is also the ID and partition key of the Cosmos document
*/
public
Optional
<
UserInfoDoc
>
findUserInfo
(
String
upn
)
{
return
C
osmos
Facad
e
.
findItem
(
userInfoContainer
,
upn
,
upn
,
UserInfoDoc
.
class
);
return
c
osmos
Stor
e
.
findItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
upn
,
upn
,
UserInfoDoc
.
class
);
}
/**
...
...
@@ -136,7 +145,7 @@ public class UserInfoRepository
* @return
*/
public
boolean
exists
(
String
id
)
{
return
C
osmos
Facad
e
.
findItem
(
userInfoContainer
,
id
,
id
,
UserInfoDoc
.
class
).
isPresent
();
return
c
osmos
Stor
e
.
findItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
id
,
id
,
UserInfoDoc
.
class
).
isPresent
();
}
/**
...
...
@@ -144,7 +153,7 @@ public class UserInfoRepository
* @param entity
*/
public
void
create
(
UserInfoDoc
entity
)
{
C
osmos
Facad
e
.
upsertItem
(
userInfoContainer
,
entity
);
c
osmos
Stor
e
.
upsertItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
entity
);
}
/**
...
...
@@ -152,13 +161,13 @@ public class UserInfoRepository
* @param entity
*/
public
void
update
(
UserInfoDoc
entity
)
{
C
osmos
Facad
e
.
upsertItem
(
userInfoContainer
,
entity
);
c
osmos
Stor
e
.
upsertItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
entity
);
}
/**
* Method to delete a user profile in Azure Cosmos DB.
* @param id
*/
public
void
delete
(
String
id
)
{
C
osmos
Facad
e
.
deleteItem
(
userInfoContainer
,
id
,
id
);
}
public
void
delete
(
String
id
)
{
c
osmos
Stor
e
.
deleteItem
(
headers
.
getPartitionId
(),
cosmosDBName
,
userInfoContainer
,
id
,
id
);
}
}
src/test/java/org/opengroup/osdu/azure/entitlements/repository/GroupInfoRepositoryTest.java
View file @
9741a49a
package
org.opengroup.osdu.azure.entitlements.repository
;
import
com.azure.cosmos.
*
;
import
com.azure.cosmos.
CosmosClientException
;
import
org.apache.http.HttpStatus
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -8,44 +8,41 @@ import org.junit.runner.RunWith;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.opengroup.osdu.azure.Cosmos
Facad
e
;
import
org.opengroup.osdu.azure.Cosmos
Stor
e
;
import
org.opengroup.osdu.azure.entitlements.model.GroupInfoDoc
;
import
org.opengroup.osdu.azure.entitlements.model.TenantInfoDoc
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
javax.inject.Named
;
import
java.io.IOException
;
import
java.util.Optional
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.*;
import
static
org
.
mockito
.
Mockito
.
doNothing
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
lenient
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
GroupInfoRepositoryTest
{
@Mock
@Named
(
"tenantInfoContainer"
)
private
CosmosContainer
cosmosContainer
;
@Mock
private
CosmosItem
cosmosItem
;
private
static
final
String
dataPartitionId
=
"data-partition-id"
;
@Mock
private
Cosmos
ItemRespons
e
cosmos
Respons
e
;
private
Cosmos
Stor
e
cosmos
Stor
e
;
@Mock
private
CosmosItemProperties
cosmosItemPropertie
s
;
private
DpsHeaders
header
s
;
@InjectMocks
private
GroupInfoRepository
repo
;
@Before
public
void
init
()
throws
CosmosClientException
{
// mock the common cosmos request/response pattern that most tests need
doReturn
(
cosmosItem
).
when
(
cosmosContainer
).
getItem
(
any
(),
any
());
doReturn
(
cosmosResponse
).
when
(
cosmosItem
).
read
(
any
());
doReturn
(
cosmosItemProperties
).
when
(
cosmosResponse
).
getProperties
();
public
void
init
()
{
lenient
().
doReturn
(
dataPartitionId
).
when
(
headers
).
getPartitionId
();
}
@Test
(
expected
=
AppException
.
class
)
...
...
@@ -53,9 +50,10 @@ public class GroupInfoRepositoryTest {
GroupInfoDoc
groupInfoDoc
=
new
GroupInfoDoc
();
groupInfoDoc
.
setId
(
"opendes"
);
doThrow
(
CosmosClientException
.
class
)
.
when
(
cosmosItem
)
.
read
(
any
());
doThrow
(
AppException
.
class
)
.
when
(
cosmosStore
)
.
findItem
(
anyString
(),
any
(),
any
(),
any
(),
any
(),
any
());
repo
.
updateGroup
(
groupInfoDoc
);
}
...
...
@@ -68,7 +66,9 @@ public class GroupInfoRepositoryTest {
TenantInfoDoc
tenantInfoDoc
=
new
TenantInfoDoc
();
tenantInfoDoc
.
setId
(
"opendes"
);
tenantInfoDoc
.
setGroups
(
new
String
[]
{
"users.test.editors"
,
"users.test.viewers"
});
when
(
CosmosFacade
.
findItem
(
cosmosContainer
,
anyString
(),
anyString
(),
TenantInfoDoc
.
class
)).
thenReturn
(
null
);
doReturn
(
Optional
.
empty
()).
when
(
cosmosStore
).
findItem
(
anyString
(),
any
(),
any
(),
anyString
(),
anyString
(),
any
());
try
{
repo
.
updateGroup
(
groupInfoDoc
);
}
catch
(
AppException
apx
)
{
...
...
@@ -88,7 +88,7 @@ public class GroupInfoRepositoryTest {
tenantInfoDoc
.
setId
(
"opendes"
);
tenantInfoDoc
.
setGroups
(
new
String
[]
{
"users.test.editors"
,
"users.test.viewers"
});
doReturn
(
tenantInfoDoc
).
when
(
cosmos
ItemProperties
).
getObject
(
any
());
doReturn
(
Optional
.
of
(
tenantInfoDoc
)
)
.
when
(
cosmos
Store
).
findItem
(
anyString
(),
any
(),
any
(),
anyString
(),
anyString
(),
any
());
try
{
repo
.
updateGroup
(
groupInfoDoc
);
...
...
@@ -109,7 +109,8 @@ public class GroupInfoRepositoryTest {
tenantInfoDoc
.
setId
(
"opendes"
);
tenantInfoDoc
.
setGroups
(
new
String
[]
{
"users.test.viewers"
});
doReturn
(
tenantInfoDoc
).
when
(
cosmosItemProperties
).
getObject
(
any
());
doReturn
(
Optional
.
of
(
tenantInfoDoc
)).
when
(
cosmosStore
).
findItem
(
anyString
(),
any
(),
any
(),
anyString
(),
anyString
(),
any
());
doNothing
().
when
(
cosmosStore
).
upsertItem
(
any
(),
any
(),
any
(),
any
());
try
{
repo
.
updateGroup
(
groupInfoDoc
);
}
catch
(
Exception
ex
)
{
...
...
src/test/java/org/opengroup/osdu/azure/entitlements/repository/UserInfoRepositoryTest.java
View file @
9741a49a
...
...
@@ -14,8 +14,7 @@
package
org.opengroup.osdu.azure.entitlements.repository
;
import
com.azure.cosmos.*
;
import
com.azure.cosmos.CosmosClientException
;
import
org.hamcrest.CoreMatchers
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -23,95 +22,69 @@ import org.junit.runner.RunWith;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.opengroup.osdu.azure.CosmosStore
;
import
org.opengroup.osdu.azure.entitlements.model.UserInfoDoc
;
import
org.opengroup.osdu.azure.entitlements.model.UserTenantItem
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.springframework.security.access.AccessDeniedException
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
lenient
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
UserInfoRepositoryTest
{
@Mock
private
CosmosContainer
cosmosContainer
;
@Mock
private
CosmosItem
cosmosItem
;
private
static
final
String
dataPartitionId
=
"data-partition-id"
;
@Mock
private
Cosmos
ItemRespons
e
cosmos
Respons
e
;
private
Cosmos
Stor
e
cosmos
Stor
e
;
@Mock
private
CosmosItemProperties
cosmosItemPropertie
s
;
private
DpsHeaders
header
s
;
@InjectMocks
private
UserInfoRepository
repo
;
@Before
public
void
init
()
throws
CosmosClientException
{
// mock the common cosmos request/response pattern that most tests need
doReturn
(
cosmosItem
).
when
(
cosmosContainer
).
getItem
(
any
(),
any
());
doReturn
(
cosmosResponse
).
when
(
cosmosItem
).
read
(
any
());
doReturn
(
cosmosItemProperties
).
when
(
cosmosResponse
).
getProperties
();
public
void
init
()
{
lenient
().
doReturn
(
dataPartitionId
).
when
(
headers
).
getPartitionId
();
}
@Test
(
expected
=
AppException
.
class
)
public
void
errorNotSwallowed_whenUnexpectedExceptionThrown
()
throws
CosmosClientException
{
doThrow
(
CosmosClientException
.
class
)
.
when
(
cosmosItem
)
.
read
(
any
());
repo
.
getTenantGroups
(
"dummy-upn"
,
"dummy-tenant"
);
}
@Test
(
expected
=
AccessDeniedException
.
class
)
public
void
accessDeniedThrown_noUser_dueToNotFoundException
()
throws
CosmosClientException
{
doThrow
(
NotFoundException
.
class
)
.
when
(
cosmosItem
)
.
read
(
any
());
repo
.
getTenantGroups
(
"dummy-upn"
,
"dummy-tenant"
);
}
@Test
(
expected
=
AccessDeniedException
.
class
)
public
void
accessDeniedThrown_noUser_dueToIOException
()
throws
IOException
{
doThrow
(
IOException
.
class
)
.
when
(
cosmosItemProperties
)
.
getObject
(
any
());
doThrow
(
AppException
.
class
).
when
(
cosmosStore
).
findItem
(
anyString
(),
any
(),
any
(),
any
(),
any
(),
any
());
repo
.
getTenantGroups
(
"dummy-upn"
,
"dummy-tenant"
);
}
@Test
(
expected
=
AccessDeniedException
.
class
)
public
void
accessDeniedThrown_noUser_dueToNullResponse
()
throws
IOException
{
doReturn
(
null
)
.
when
(
cosmosItemProperties
)
.
getObject
(
any
());
public
void
accessDeniedThrown_noUser_dueToEmptyResponse
()
throws
IOException
{
doReturn
(
Optional
.
empty
()).
when
(
cosmosStore
).
findItem
(
anyString
(),
any
(),
any
(),
any
(),
any
(),
any
());
repo
.
getTenantGroups
(
"dummy-upn"
,
"dummy-tenant"
);
}
@Test
(
expected
=
AccessDeniedException
.
class
)
public
void
accessDeniedThrown_userHasNoTenantAccess
()
throws
IOException
{
UserInfoDoc
userInfo
=
getUserInfoWithTenantGroups
(
"dummy-upn"
,
"t1"
,
"t2"
);
doReturn
(
userInfo
)
.
when
(
cosmosItemProperties
)
.
getObject
(
any
());
Optional
<
UserInfoDoc
>
userInfo
=
Optional
.
of
(
getUserInfoWithTenantGroups
(
"dummy-upn"
,
"t1"
,
"t2"
));
doReturn
(
userInfo
).
when
(
cosmosStore
).
findItem
(
anyString
(),
any
(),
any
(),
anyString
(),
anyString
(),
any
());
repo
.
getTenantGroups
(
"dummy-upn"
,
"t3"
);
}
@Test
public
void
correctTenantGroupsReturned_userHasTenantAccess
()
throws
IOException
{
UserInfoDoc
userInfo
=
getUserInfoWithTenantGroups
(
"dummy-upn"
,
"t1"
);
doReturn
(
userInfo
)
.
when
(
cosmosItemProperties
)
.
getObject
(
any
());
Optional
<
UserInfoDoc
>
userInfo
=
Optional
.
of
(
getUserInfoWithTenantGroups
(
"dummy-upn"
,
"t1"
));
doReturn
(
userInfo
).
when
(
cosmosStore
).
findItem
(
anyString
(),
any
(),
any
(),
anyString
(),
anyString
(),
any
());
String
[]
expectedGroups
=
userInfo
.
getTenants
()[
0
].
getGroups
();
String
[]
expectedGroups
=
userInfo
.
get
().
getTenants
()[
0
].
getGroups
();
List
<
String
>
actualGroups
=
Arrays
.
asList
(
repo
.
getTenantGroups
(
"dummy-upn"
,
"t1"
));
assertThat
(
"TenantGroups did return expected groups"
,
actualGroups
,
CoreMatchers
.
hasItems
(
expectedGroups
[
0
],
expectedGroups
[
1
]));
...
...
@@ -119,12 +92,10 @@ public class UserInfoRepositoryTest {
@Test
public
void
correctTenantGroupsReturned_userHasTenantAccess_ignoreTenantCasing
()
throws
IOException
{
UserInfoDoc
userInfo
=
getUserInfoWithTenantGroups
(
"dummy-upn"
,
"t1"
);
doReturn
(
userInfo
)
.
when
(
cosmosItemProperties
)
.
getObject
(
any
());
Optional
<
UserInfoDoc
>
userInfo
=
Optional
.
of
(
getUserInfoWithTenantGroups
(
"dummy-upn"
,
"t1"
));
doReturn
(
userInfo
).
when
(
cosmosStore
).
findItem
(
anyString
(),
any
(),
any
(),
anyString
(),
anyString
(),
any
());
String
[]
expectedGroups
=
userInfo
.
getTenants
()[
0
].
getGroups
();
String
[]
expectedGroups
=
userInfo
.
get
().
getTenants
()[
0
].
getGroups
();
List
<
String
>
actualGroups
=
Arrays
.
asList
(
repo
.
getTenantGroups
(
"dummy-upn"
,
"T1"
));
assertThat
(
"TenantGroups did return expected groups"
,
actualGroups
,
CoreMatchers
.
hasItems
(
expectedGroups
[
0
],
expectedGroups
[
1
]));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment