Search in sources :

Example 1 with NamespaceMembershipJson

use of org.eclipse.openvsx.json.NamespaceMembershipJson in project openvsx by eclipse.

the class AdminAPITest method testGetNamespaceMembers.

@Test
public void testGetNamespaceMembers() throws Exception {
    mockAdminUser();
    var namespace = mockNamespace();
    var user = new UserData();
    user.setLoginName("other_user");
    var membership1 = new NamespaceMembership();
    membership1.setNamespace(namespace);
    membership1.setUser(user);
    membership1.setRole(NamespaceMembership.ROLE_OWNER);
    Mockito.when(repositories.findMemberships(namespace)).thenReturn(Streamable.of(membership1));
    mockMvc.perform(get("/admin/namespace/{namespace}/members", "foobar").with(user("admin_user").authorities(new SimpleGrantedAuthority(("ROLE_ADMIN")))).with(csrf().asHeader())).andExpect(status().isOk()).andExpect(content().json(namespaceMemberJson(nml -> {
        var m = new NamespaceMembershipJson();
        m.namespace = "foobar";
        m.user = new UserJson();
        m.user.loginName = "other_user";
        m.role = "owner";
        nml.namespaceMemberships = Arrays.asList(m);
    })));
}
Also used : UserJson(org.eclipse.openvsx.json.UserJson) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) NamespaceMembershipJson(org.eclipse.openvsx.json.NamespaceMembershipJson) Test(org.junit.jupiter.api.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Aggregations

NamespaceMembershipJson (org.eclipse.openvsx.json.NamespaceMembershipJson)1 UserJson (org.eclipse.openvsx.json.UserJson)1 Test (org.junit.jupiter.api.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1