Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.ConnectionCredentials


            }

            // Duplicate if both credentials and URLs are equal.
            // If the URLs are the same then make sure credentials are not
            if (cUrl.equals(oUrl)) {
                ConnectionCredentials cCreds = connection.getCredentials();
                ConnectionCredentials oCreds = otherConnection.getCredentials();

                if ((cCreds == null && oCreds == null) || (cCreds != null && oCreds != null && cCreds.equals(oCreds))) {
                    throw ConnectionExistsException.Factory.duplicateCredentials(connection);
                }
            }
View Full Code Here


        mapper.registerModule(module);
    }

    @Test
    public void testEncrypt() throws Exception {
        ConnectionCredentials cc = new ConnectionCredentials("foo", "bar");
        String jsonAsString = mapper.writeValueAsString(cc);
        JSONObject json = JSONObject.fromObject(jsonAsString);
        Assert.assertEquals("foo", json.getString("identity"));
        Assert.assertFalse(json.getString("credential").equals("bar"));
    }
View Full Code Here

        Assert.assertFalse(json.getString("credential").equals("bar"));
    }

    @Test
    public void testEncrypt_NullIdentity() throws Exception {
        ConnectionCredentials cc = new ConnectionCredentials(null, "bar");
        String jsonAsString = mapper.writeValueAsString(cc);
        JSONObject json = JSONObject.fromObject(jsonAsString);
        Assert.assertFalse(json.containsKey("identity"));
    }
View Full Code Here

        Assert.assertFalse(json.containsKey("identity"));
    }

    @Test
    public void testEncrypt_NullCredential() throws Exception {
        ConnectionCredentials cc = new ConnectionCredentials("foo", null);
        String jsonAsString = mapper.writeValueAsString(cc);
        JSONObject json = JSONObject.fromObject(jsonAsString);
        Assert.assertFalse(json.containsKey("credential"));
    }
View Full Code Here

                "  \"access_token\" : \"ya29.AHES6ZS2UHOclj7rSPx8lAKbQo2Z6AOPmGeSlaeGA5eMxhe5nO6pAg\",\n" +
                "  \"token_type\" : \"Bearer\",\n" +
                "  \"expires_in\" : 3600,\n" +
                "  \"refresh_token\" : \"1/1B3mzvdzu7dEpQKa2PHoBigmhu-Jefuj-a90Cs7AsEw\"\n" +
                "}");
        ConnectionCredentials credentials = new ConnectionCredentials();

        new GoogleAnalyticsProvider().updateCredentials(credentials, mockToken);

        Assert.assertNotNull(credentials.getOauthToken());
        Assert.assertEquals(credentials.getOauthToken(), "ya29.AHES6ZS2UHOclj7rSPx8lAKbQo2Z6AOPmGeSlaeGA5eMxhe5nO6pAg");
        Assert.assertNotNull(credentials.getOauthRefreshToken());
        Assert.assertEquals(credentials.getOauthRefreshToken(), "1/1B3mzvdzu7dEpQKa2PHoBigmhu-Jefuj-a90Cs7AsEw");
    }
View Full Code Here

    @Test
    public void testSerializeDeserializeEncryptsCredentials() throws Exception{
        String beforeEncryption = "k32hgr23y4uiofg32qiofygq3oyfiqgf4gt3qggq3g34gqagegeqg";

        ConnectionCredentials connectionCredentials = new ConnectionCredentials();
        connectionCredentials.setIdentity("foo");
        connectionCredentials.setApiKey(beforeEncryption);
        connectionCredentials.setCredential(beforeEncryption);
        connectionCredentials.setOauthToken(beforeEncryption);
        connectionCredentials.setOauthTokenSecret(beforeEncryption);

        OutboundConfiguration outboundConfiguration =  new OutboundConfiguration.Builder()
                .dataTypes(OutboundDataType.PROCESSED)
                .protocol("s3")
                .credentials(connectionCredentials)
View Full Code Here

        mapper.registerModule(module);
    }

    @Test
    public void testSerializeAndDeserialize() throws Exception {
        ConnectionCredentials cc = new ConnectionCredentials("foo",null);
        cc.setCredential("ihateyou");
        cc.setApiKey("ihateyou");
        cc.setOauthToken("ihateyou");
        cc.setOauthTokenSecret("ihateyou");
        cc.setOauthVerifier("notencrypted");

        String jsonAsString = mapper.writeValueAsString(cc);

        assertFalse(jsonAsString.contains("ihateyou"));

        ConnectionCredentials deserializedCC = mapper.readValue(jsonAsString,ConnectionCredentials.class);
        Assert.assertEquals(cc,deserializedCC);
    }
View Full Code Here

    public void getConnectionPostLoadSetsReferenceInOutboundConnections() throws Exception {
        //Test that verifies that an OutboundConfiguration will include a reference to its containing connection
        //after it has been loaded from mongo.

        OutboundConfiguration outboundConfiguration = new OutboundConfiguration.Builder()
                .credentials(new ConnectionCredentials(cloudBundle.getString("nodeable.aws.accessKeyId"), cloudBundle.getString("nodeable.aws.secretKey")))
                .protocol("s3")
                .namespace("my.bucket.name.here")
                .dataTypes(OutboundDataType.PROCESSED)
                .build();
View Full Code Here

    }

    @Test
    public void testCreateConnectionPersistsOutboundConfigurations() throws Exception {
        OutboundConfiguration outboundConfiguration = new OutboundConfiguration.Builder()
                .credentials(new ConnectionCredentials(cloudBundle.getString("nodeable.aws.accessKeyId"), cloudBundle.getString("nodeable.aws.secretKey")))
                .destination("eu-west-1")
                .protocol("s3")
                .namespace("com.streamreduce.bucket")
                .dataTypes(OutboundDataType.PROCESSED)
                .build();
View Full Code Here

    @Test(expected = Exception.class)
    public void testCreateJiraConnectionWithInvalidURLFails() throws Exception {
        Connection tmpConnection = new Connection.Builder()
                .alias("Nodeable Jira")
                .description("Nodeable's Jira instance.")
                .credentials(new ConnectionCredentials(jiraProperties.getString("nodeable.jira.username"),
                        jiraProperties.getString("nodeable.jira.password")))
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.JIRA_PROVIDER_ID))
                .url("http://some.fake.url")
                .authType(AuthType.USERNAME_PASSWORD)
                .user(testUser)
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.ConnectionCredentials

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.