use of org.osgi.service.useradmin.Authorization in project aries by apache.
the class UserAdminTest method testGetAuthorization.
/**
* Test method for {@link org.apache.aries.jmx.useradmin.UserAdmin#getAuthorization(java.lang.String)}.
*
* @throws IOException
*/
@Test
public void testGetAuthorization() throws IOException {
Authorization auth = Mockito.mock(Authorization.class);
User user = Mockito.mock(User.class);
Mockito.when(user.getType()).thenReturn(Role.USER);
Mockito.when(userAdmin.getAuthorization(user)).thenReturn(auth);
Mockito.when(userAdmin.getRole("role1")).thenReturn(user);
Mockito.when(auth.getName()).thenReturn("auth1");
Mockito.when(auth.getRoles()).thenReturn(new String[] { "role1" });
CompositeData data = mbean.getAuthorization("role1");
Assert.assertNotNull(data);
AuthorizationData authData = AuthorizationData.from(data);
Assert.assertNotNull(authData);
Assert.assertEquals("auth1", authData.getName());
Assert.assertArrayEquals(new String[] { "role1" }, authData.getRoles());
}
Aggregations