Package com.saasovation.identityaccess.domain.model.identity

Examples of com.saasovation.identityaccess.domain.model.identity.User


        assertEquals(user.username(), reader.stringValue("username"));
        assertEquals(user.person().emailAddress().address(), reader.stringValue("emailAddress"));
    }

    public void testGetAuthenticUserWrongPassword() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/users/{username}/autenticatedWith/{password}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username());
        request.pathParameter("password", UUID.randomUUID().toString());
        ClientResponse<String> response = request.get(String.class);
        assertTrue(response.getStatus() == 404 || response.getStatus() == 500);
    }
View Full Code Here


        assertTrue(managerRole.isInRole(user, DomainRegistry.groupMemberService()));
    }

    public void testUserIsNotInRole() throws Exception {
        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);
        Group group = tenant.provisionGroup("Managers", "A group of managers.");
        DomainRegistry.groupRepository().add(group);
        managerRole.assignGroup(group, DomainRegistry.groupMemberService());
        DomainRegistry.roleRepository().add(managerRole);
        Role accountantRole = new Role(user.tenantId(), "Accountant", "An accountant role.");
        DomainRegistry.roleRepository().add(accountantRole);

        assertFalse(managerRole.isInRole(user, DomainRegistry.groupMemberService()));
        assertFalse(accountantRole.isInRole(user, DomainRegistry.groupMemberService()));
    }
View Full Code Here

                return GroupUserAdded.class;
            }
        });

        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);
        Group group = new Group(user.tenantId(), "Managers", "A group of managers.");
        DomainRegistry.groupRepository().add(group);
        managerRole.assignGroup(group, DomainRegistry.groupMemberService());
        managerRole.assignUser(user);
        DomainRegistry.roleRepository().add(managerRole);
        group.addUser(user); // legal add
View Full Code Here

        ClientResponse<String> response = request.get(String.class);
        assertTrue(response.getStatus() == 404 || response.getStatus() == 500);
    }

    public void testGetUser() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/users/{username}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username());
        ClientResponse<String> response = request.get(String.class);
        assertEquals(200, response.getStatus());
        String entity = response.getEntity();
        System.out.println(entity);
        RepresentationReader reader = new RepresentationReader(entity);
        assertEquals(user.username(), reader.stringValue("username"));
        assertTrue(reader.booleanValue("enabled"));
    }
View Full Code Here

                return GroupUserRemoved.class;
            }
        });

        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);
        Group group = new Group(user.tenantId(), "Managers", "A group of managers.");
        DomainRegistry.groupRepository().add(group);
        managerRole.assignUser(user);
        managerRole.assignGroup(group, DomainRegistry.groupMemberService());
        DomainRegistry.roleRepository().add(managerRole);
View Full Code Here

        assertEquals(user.username(), reader.stringValue("username"));
        assertTrue(reader.booleanValue("enabled"));
    }

    public void testGetNonExistingUser() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/users/{username}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username() + "!");
        ClientResponse<String> response = request.get(String.class);
        assertTrue(response.getStatus() == 404 || response.getStatus() == 500);
    }
View Full Code Here

        ClientResponse<String> response = request.get(String.class);
        assertTrue(response.getStatus() == 404 || response.getStatus() == 500);
    }

    public void testIsUserInRole() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        Role role = this.roleAggregate();
        role.assignUser(user);
        DomainRegistry.roleRepository().add(role);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/users/{username}/inRole/{role}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username());
        request.pathParameter("role", role.name());
        ClientResponse<String> response = request.get(String.class);
        assertEquals(200, response.getStatus());
        String entity = response.getEntity();
        System.out.println(entity);
        RepresentationReader reader = new RepresentationReader(entity);
        assertEquals(user.username(),  reader.stringValue("username"));
        assertEquals(role.name(), reader.stringValue("role"));
    }
View Full Code Here

        assertEquals(user.username(),  reader.stringValue("username"));
        assertEquals(role.name(), reader.stringValue("role"));
    }

    public void testIsUserNotInRole() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        Role role = this.roleAggregate();
        DomainRegistry.roleRepository().add(role);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/users/{username}/inRole/{role}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username());
        request.pathParameter("role", role.name());
        ClientResponse<String> response = request.get(String.class);
        assertEquals(204, response.getStatus());
    }
View Full Code Here

    public Response getUser(
            @PathParam("tenantId") String aTenantId,
            @PathParam("username") String aUsername,
            @Context Request aRequest) {

        User user = this.identityApplicationService().user(aTenantId, aUsername);

        if (user == null) {
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
View Full Code Here

            @PathParam("username") String aUsername,
            @PathParam("role") String aRoleName) {

        Response response = null;

        User user = null;

        try {
            user = this.accessApplicationService()
                       .userInRole(
                               aTenantId,
View Full Code Here

TOP

Related Classes of com.saasovation.identityaccess.domain.model.identity.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.