Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.OAuthDomainEntry


     * Test disabling an oauth token.
     */
    @Test
    public void testSuccessfulDisableOauthToken()
    {
        final OAuthDomainEntry entry = new OAuthDomainEntry();
        entry.setCallbackTokenAttempts(1);
        entry.setCallbackUrlSigned(true);
        entry.setType(OAuthEntry.Type.ACCESS.toString());

        context.checking(new Expectations()
        {
            {
                oneOf(actionContext).getParams();
                will(returnValue(TEST_ENTRY_TOKEN));

                oneOf(entryMapper).execute(TEST_ENTRY_TOKEN);
                will(returnValue(entry));
            }
        });

        sut.execute(actionContext);
        assertEquals(entry.getCallbackTokenAttempts(), 2);
        assertEquals(entry.getType(), OAuthEntry.Type.ACCESS.toString());
        context.assertIsSatisfied();
    }
View Full Code Here


     * Test disabling an oauth token.
     */
    @Test
    public void testSuccessfulDisableOauthTokenOverAttempts()
    {
        final OAuthDomainEntry entry = new OAuthDomainEntry();
        entry.setCallbackTokenAttempts(5);
        entry.setCallbackUrlSigned(true);
        entry.setType(OAuthEntry.Type.ACCESS.toString());

        context.checking(new Expectations()
        {
            {
                oneOf(actionContext).getParams();
                will(returnValue(TEST_ENTRY_TOKEN));

                oneOf(entryMapper).execute(TEST_ENTRY_TOKEN);
                will(returnValue(entry));
            }
        });

        sut.execute(actionContext);
        assertEquals(entry.getCallbackTokenAttempts(), 6);
        assertEquals(entry.getType(), OAuthEntry.Type.DISABLED.toString());
        context.assertIsSatisfied();
    }
View Full Code Here

     * Test successful authorization.
     */
    @Test
    public void testSuccessfulAuthorization()
    {
        final OAuthDomainEntry dto = new OAuthDomainEntry();
        dto.setCallbackUrlSigned(true);

        context.checking(new Expectations()
        {
            {
                oneOf(actionContext).getPrincipal();
                will(returnValue(principal));

                oneOf(principal).getAccountId();
                will(returnValue("testacctid"));

                oneOf(actionContext).getParams();
                will(returnValue("token"));

                oneOf(entryMapper).execute("token");
                will(returnValue(dto));

                oneOf(entryMapper).execute("token");
                will(returnValue(dto));
            }
        });

        String callbackurl = sut.execute(actionContext);
        assertNotNull(callbackurl);
        assertEquals(dto.isAuthorized(), true);
        assertTrue(dto.getCallbackToken() != null);

        context.assertIsSatisfied();

    }
View Full Code Here

     * Test successful authorization.
     */
    @Test
    public void testSuccessfulAuthorizationWithUnsignedCallback()
    {
        final OAuthDomainEntry dto = new OAuthDomainEntry();
        dto.setCallbackUrlSigned(false);

        context.checking(new Expectations()
        {
            {
                oneOf(actionContext).getPrincipal();
                will(returnValue(principal));

                oneOf(principal).getAccountId();
                will(returnValue("testacctid"));

                oneOf(actionContext).getParams();
                will(returnValue("token"));

                oneOf(entryMapper).execute("token");
                will(returnValue(dto));

                oneOf(entryMapper).execute("token");
                will(returnValue(dto));
            }
        });

        String callbackurl = sut.execute(actionContext);
        assertNotNull(callbackurl);
        assertEquals(dto.isAuthorized(), true);
        assertTrue(dto.getCallbackToken() == null);

        context.assertIsSatisfied();

    }
View Full Code Here

     * Test failure authorization.
     */
    @Test(expected = ExecutionException.class)
    public void testAuthorizationFailedTokenNotFound()
    {
        final OAuthDomainEntry dto = new OAuthDomainEntry();
        dto.setCallbackUrlSigned(true);

        context.checking(new Expectations()
        {
            {
                oneOf(actionContext).getPrincipal();
View Full Code Here

     * Test successful authorization.
     */
    @Test
    public void testSuccessfulAuthorizationWithCallbackUrl()
    {
        final OAuthDomainEntry dto = new OAuthDomainEntry();
        dto.setCallbackUrlSigned(true);
        dto.setCallbackUrl("http://example.com/callbackurl");
        context.checking(new Expectations()
        {
            {
                oneOf(actionContext).getPrincipal();
                will(returnValue(principal));

                oneOf(principal).getAccountId();
                will(returnValue("testacctid"));

                oneOf(actionContext).getParams();
                will(returnValue("token"));

                oneOf(entryMapper).execute("token");
                will(returnValue(dto));

                oneOf(entryMapper).execute("token");
                will(returnValue(dto));
            }
        });

        String callbackurl = sut.execute(actionContext);
        assertNotNull(callbackurl);
        assertEquals(dto.isAuthorized(), true);
        assertTrue(dto.getCallbackToken() != null);

        context.assertIsSatisfied();

    }
View Full Code Here

            {
                oneOf(actionContext).getParams();
                will(returnValue("token"));

                oneOf(entryMapper).execute("token");
                will(returnValue(new OAuthDomainEntry()));

                oneOf(conversionStrat).convertToEntry(with(any(OAuthDomainEntry.class)));
            }
        });
View Full Code Here

     * Test successful conversion of an {@link OAuthDomainEntry} to an {@link OAuthEntry}.
     */
    @Test
    public void testSuccessfulDtoToEntry()
    {
        OAuthDomainEntry dto = new OAuthDomainEntry();
        dto.setAppId("appId");
        dto.setAuthorized(true);
        dto.setCallbackToken("callbacktoken");
        dto.setCallbackTokenAttempts(0);
        dto.setCallbackUrl("callbackurl");
        dto.setCallbackUrlSigned(true);
        dto.setConsumer(new OAuthConsumer(null, null, "key", null, null));
        dto.setContainer("container");
        dto.setDomain("domain");
        dto.setIssueTime(new Date());
        dto.setOauthVersion("1.0");
        dto.setToken("token");
        dto.setTokenSecret("tokensecret");
        dto.setType(Type.ACCESS.toString());
        dto.setUserId("userid");
               
        OAuthEntry entry = sut.convertToEntry(dto);
       
        assertEquals(entry.getAppId(), dto.getAppId());
        assertEquals(entry.isAuthorized(), dto.isAuthorized());
        assertEquals(entry.getCallbackToken(), dto.getCallbackToken());
        assertEquals(entry.getCallbackTokenAttempts(), dto.getCallbackTokenAttempts());
        assertEquals(entry.getCallbackUrl(), dto.getCallbackUrl());
        assertEquals(entry.isCallbackUrlSigned(), dto.isCallbackUrlSigned());
        assertEquals(entry.getConsumerKey(), dto.getConsumer().getConsumerKey());
        assertEquals(entry.getContainer(), dto.getContainer());
        assertEquals(entry.getDomain(), dto.getDomain());
        assertEquals(entry.getIssueTime(), dto.getIssueTime());
        assertEquals(entry.getOauthVersion(), dto.getOauthVersion());
        assertEquals(entry.getToken(), dto.getToken());
        assertEquals(entry.getTokenSecret(), dto.getTokenSecret());
        assertEquals(entry.getType(), Type.valueOf(dto.getType()));
        assertEquals(entry.getUserId(), dto.getUserId());

    }
View Full Code Here

                oneOf(mapper).execute("testkey");
                will(returnValue(new OAuthConsumer(null, null, "testkey", null, null)));
            }
        });

        OAuthDomainEntry dto = sut.convertToEntryDTO(entry);
        assertEquals(entry.getAppId(), dto.getAppId());
        assertEquals(entry.isAuthorized(), dto.isAuthorized());
        assertEquals(entry.getCallbackToken(), dto.getCallbackToken());
        assertEquals(entry.getCallbackTokenAttempts(), dto.getCallbackTokenAttempts());
        assertEquals(entry.getCallbackUrl(), dto.getCallbackUrl());
        assertEquals(entry.isCallbackUrlSigned(), dto.isCallbackUrlSigned());
        assertEquals(entry.getConsumerKey(), dto.getConsumer().getConsumerKey());
        assertEquals(entry.getContainer(), dto.getContainer());
        assertEquals(entry.getDomain(), dto.getDomain());
        assertEquals(entry.getIssueTime(), dto.getIssueTime());
        assertEquals(entry.getOauthVersion(), dto.getOauthVersion());
        assertEquals(entry.getToken(), dto.getToken());
        assertEquals(entry.getTokenSecret(), dto.getTokenSecret());
        assertEquals(entry.getType(), Type.valueOf(dto.getType()));
        assertEquals(entry.getUserId(), dto.getUserId());
        context.assertIsSatisfied();
    }
View Full Code Here

        {
            entry.setCallbackUrlSigned(true);
            entry.setCallbackUrl(currentRequest.getSignedCallbackUrl());
        }

        OAuthDomainEntry dto = oauthConversionStrat.convertToEntryDTO(entry);
        insertMapper.execute(new PersistenceRequest<OAuthDomainEntry>(dto));
        return entry;
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.OAuthDomainEntry

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.