Examples of HAccount


Examples of org.zanata.model.HAccount

     * longer restricted to authenticated users.
     */
    // @Test(expected = NotLoggedInException.class)
    public void failSaveWhenNotLoggedIn() throws Exception {
        HLocale locale = entityManager.find(HLocale.class, new Long(1));
        HAccount account = entityManager.find(HAccount.class, new Long(1));

        assertThat(locale, notNullValue());
        assertThat(account, notNullValue());

        HLocaleMember newMember =
                new HLocaleMember(account.getPerson(), locale, true, true, true);
        // Should fail as there is no user logged in
        localeMemberDAO.makePersistent(newMember);
    }
View Full Code Here

Examples of org.zanata.model.HAccount

        identity.getCredentials().setUsername("admin");
        identity.getCredentials().setPassword("admin");
        identity.login();

        HLocale locale = entityManager.find(HLocale.class, new Long(1));
        HAccount account = entityManager.find(HAccount.class, new Long(1));

        assertThat(locale, notNullValue());
        assertThat(account, notNullValue());

        HLocaleMember newMember =
                new HLocaleMember(account.getPerson(), locale, true, true, true);
        localeMemberDAO.makePersistent(newMember);
    }
View Full Code Here

Examples of org.zanata.model.HAccount

                                 // simulation

        AccountDAO accountDAO = getSeamAutowire().autowire(AccountDAO.class);

        // Translator
        HAccount translator = accountDAO.getByUsername("demo");

        // Translate using the web editor
        this.simulateWebEditorTranslation("sample-project", "1.0", "my.txt",
                "tf1", translator, de_de, "Translated", ContentState.Approved);
View Full Code Here

Examples of org.zanata.model.HAccount

        seam.reset().use("entityManager", getEm()).use("session", getSession())
                .useImpl(UserAccountServiceImpl.class).ignoreNonResolvable();
    }

    private HAccount createFedoraAccount() {
        HAccount account = new HAccount();
        account.setUsername("fedora-user");
        account.setEnabled(true);
        HAccount newAcc = em.merge(account);

        HCredentials fedoraCreds =
                new HOpenIdCredentials(newAcc,
                        "http://fedora-user.id.fedoraproject.org/",
                        "fedora-user@fedora.org");
        newAcc.getCredentials().add(fedoraCreds);
        return newAcc;
    }
View Full Code Here

Examples of org.zanata.model.HAccount

    @Test
    public void assignedRule() {
        UserAccountService userAccountService =
                seam.autowire(UserAccountServiceImpl.class);
        // Non admin account
        HAccount account = em.find(HAccount.class, 3L);
        assertThat(new ArrayList<HAccountRole>(account.getRoles()),
                not(Matchers.<HAccountRole> hasItem(hasProperty("name",
                        Matchers.is("admin")))));

        account =
                userAccountService.runRoleAssignmentRules(account, null,
                        "zanata");
        // Now it's admin
        assertThat(
                new ArrayList<HAccountRole>(account.getRoles()),
                Matchers.<HAccountRole> hasItem(hasProperty("name",
                        Matchers.is("admin"))));
    }
View Full Code Here

Examples of org.zanata.model.HAccount

    @Test
    public void assignedFedoraRule() {
        UserAccountService userAccountService =
                seam.autowire(UserAccountServiceImpl.class);
        // Non Fedora account
        HAccount account = createFedoraAccount();
        assertThat(new ArrayList<HAccountRole>(account.getRoles()),
                not(Matchers.<HAccountRole> hasItem(hasProperty("name",
                        Matchers.is("Fedora")))));

        account =
                userAccountService.runRoleAssignmentRules(account, account
                        .getCredentials().iterator().next(), "fedora");
        // Now it's fedora
        assertThat(
                new ArrayList<HAccountRole>(account.getRoles()),
                Matchers.<HAccountRole> hasItem(hasProperty("name",
                        Matchers.is("Fedora"))));
    }
View Full Code Here

Examples of org.zanata.model.HAccount

    @Test
    public void notAssignedFedoraRule() {
        UserAccountService userAccountService =
                seam.autowire(UserAccountServiceImpl.class);
        // Non Fedora account
        HAccount account = em.find(HAccount.class, 3L);
        assertThat(new ArrayList<HAccountRole>(account.getRoles()),
                not(Matchers.<HAccountRole> hasItem(hasProperty("name",
                        Matchers.is("Fedora")))));

        account =
                userAccountService.runRoleAssignmentRules(account, null,
                        "fedora");
        // It's still not Fedora
        assertThat(new ArrayList<HAccountRole>(account.getRoles()),
                not(Matchers.<HAccountRole> hasItem(hasProperty("name",
                        Matchers.is("Fedora")))));
    }
View Full Code Here

Examples of org.zanata.model.HAccount

    }

    private void prepareAccount() {
        Session session = getSession();
        String username = "anAuthenticatedAccount";
        HAccount account = (HAccount) session.byNaturalId(HAccount.class).using("username", username).load();
        if (account == null) {
            account = new HAccount();
            account.setUsername(username);
            HPerson person = new HPerson();
            person.setEmail("email@example.com");
            person.setName("aPerson");
            person = (HPerson) session.merge(person);
            account.setPerson(person);
            account = (HAccount) session.merge(account);
        }
        seamAutowire.use(JpaIdentityStore.AUTHENTICATED_USER, account);
    }
View Full Code Here

Examples of org.zanata.model.HAccount

    }

    @Test
    public void willUseAuthenticatedUserApiKeyIfPresent() throws Exception {
        authenticatedUser = new HAccount();
        authenticatedUser.setApiKey("apiKeyInAuth");
        doReturn(authenticatedUser).when(dispatcher).getAuthenticatedUser();

        dispatcher.invoke(request, response);
View Full Code Here

Examples of org.zanata.model.HAccount

                taskCaptor.capture());
    }

    @Test
    public void willUserUsernameIfNoApiKeyButAuthenticated() throws Exception {
        authenticatedUser = new HAccount();
        authenticatedUser.setUsername("admin");
        doReturn(authenticatedUser).when(dispatcher).getAuthenticatedUser();

        dispatcher.invoke(request, response);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.