diff --git a/oauth2-platform-api/src/test/java/com/intuit/oauth2/config/ProxyConfigTest.java b/oauth2-platform-api/src/test/java/com/intuit/oauth2/config/ProxyConfigTest.java new file mode 100644 index 00000000..1a005859 --- /dev/null +++ b/oauth2-platform-api/src/test/java/com/intuit/oauth2/config/ProxyConfigTest.java @@ -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()); + } + + +} diff --git a/oauth2-platform-api/src/test/java/com/intuit/oauth2/config/ScopeTest.java b/oauth2-platform-api/src/test/java/com/intuit/oauth2/config/ScopeTest.java new file mode 100644 index 00000000..fe4bed5e --- /dev/null +++ b/oauth2-platform-api/src/test/java/com/intuit/oauth2/config/ScopeTest.java @@ -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 validScopeValuesdp() { + + Set 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."); + } + } + + +}