Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2017 Intuit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.intuit.oauth2.config;

import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

/**
* Config class to hold the proxy properties
*
* @author dderose
*/
public class ProxyConfigTest {

private ProxyConfig.ProxyConfigBuilder initProxyConfigBuilder()
{
ProxyConfig.ProxyConfigBuilder proxyConfigBuilder = new ProxyConfig.ProxyConfigBuilder("oauth.platform.intuit.com","8080");
proxyConfigBuilder.username("myusername");
proxyConfigBuilder.password("mypassword");
proxyConfigBuilder.domain("mydomain");
return proxyConfigBuilder;
}


@Test
public void testProxyConfigBuilder()
{
ProxyConfig.ProxyConfigBuilder proxyConfigBuilder = initProxyConfigBuilder();
ProxyConfig proxyConfig = proxyConfigBuilder.buildConfig();
assertNotNull(proxyConfigBuilder);
assertNotNull(proxyConfig);
assertEquals("oauth.platform.intuit.com", proxyConfig.getHost());
assertEquals("8080", proxyConfig.getPort());
assertEquals("myusername", proxyConfig.getUsername());
assertEquals("mypassword", proxyConfig.getPassword());
assertEquals("mydomain", proxyConfig.getDomain());
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2017 Intuit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.intuit.oauth2.config;

import com.intuit.oauth2.exception.InvalidRequestException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import static org.testng.Assert.*;

/**
* Config class to hold the proxy properties
*
* @author dderose
*/
public class ScopeTest {

@Test(expectedExceptions = IllegalArgumentException.class)
public void testfromValueforIllegalArgument()
{
String badenum ="I am bad value";
Scope.fromValue(badenum);
fail(badenum + " is not present in the Scope enum");
}


@DataProvider(parallel = true, name = "validScopeValuesdp")
public Iterator<Object[]> validScopeValuesdp() {

Set<Object[]> dataToBeReturned = new HashSet<>();

for (Scope scope : Scope.values()) {
dataToBeReturned.add(new Object[]{scope.name(), scope.value()});
}
return dataToBeReturned.iterator();
}


@Test(dataProvider = "validScopeValuesdp")
public void testfromValueforInvalidArgument(String name, String value)
{
try{
Scope returnedScope = Scope.fromValue(value);
assertNotNull(returnedScope);
assertTrue(returnedScope.name().equals(name));
} catch (Exception e)
{
fail(value + "is a valid Scope enumvalue.");
}
}


}