diff --git a/.travis.yml b/.travis.yml index 98964307ef..e09096576e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,13 +20,13 @@ addons: description: Build submitted via Travis CI notification_email: jeremylandis@hotmail.com build_command_prepend: mvn clean - build_command: mvn -DskipTests=true install + build_command: mvn clean install -DskipTests branch_pattern: coverity_scan before_script: - cd Source/JNA -script: if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then mvn clean install -DskipTests=true; fi +script: if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then mvn clean install -DskipTests; fi after_success: - chmod -R 777 ../../travis/after_success.sh diff --git a/README.md b/README.md index 86bf1f877f..f4f55a143e 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ Essentials * [Older Versions on CodePlex](http://waffle.codeplex.com/). * [PlatformSDK Security Group](https://groups.google.com/group/microsoft.public.platformsdk.security) +Jetty +----- +Jetty support is build using java 7 like everything else. However, using the provided jetty version will require java 8 usage. +To continue with java 7, drop back to Jetty version 9.2.13.v20150730. + Legacy 1.7.x Branch ------------------- Waffle legacy support. From 1/3/2015 through 1/1/2016 we will continue to support the 1.7.x branch for any bug fixes to diff --git a/Source/JNA/pom.xml b/Source/JNA/pom.xml index 259c7ed70f..e73173bd69 100644 --- a/Source/JNA/pom.xml +++ b/Source/JNA/pom.xml @@ -119,7 +119,6 @@ 2.3.4 1.19 4.12 - 1.10.19 1.7.12 java17 @@ -152,19 +151,6 @@ ${jmockit.version} test - - - org.mockito - mockito-core - ${mockito.version} - test - - - hamcrest-core - org.hamcrest - - - junit junit diff --git a/Source/JNA/waffle-jetty/pom.xml b/Source/JNA/waffle-jetty/pom.xml index 6c7a7bd35a..206b28ecbf 100644 --- a/Source/JNA/waffle-jetty/pom.xml +++ b/Source/JNA/waffle-jetty/pom.xml @@ -17,7 +17,7 @@ 3.0.1-b08 3.0.1-b04 - 9.3.4.v20151007 + 9.3.5.v20151012 4.4.2 2.3.3-b02 2.3.2-b01 diff --git a/Source/JNA/waffle-jetty/src/test/java/waffle/jetty/StartEmbeddedJetty.java b/Source/JNA/waffle-jetty/src/test/java/waffle/jetty/StartEmbeddedJetty.java index 88cb484e2d..92e2f63ead 100644 --- a/Source/JNA/waffle-jetty/src/test/java/waffle/jetty/StartEmbeddedJetty.java +++ b/Source/JNA/waffle-jetty/src/test/java/waffle/jetty/StartEmbeddedJetty.java @@ -63,7 +63,10 @@ public static void main(final String[] args) throws Exception { try { StartEmbeddedJetty.LOGGER.info(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); - System.in.read(); + if (System.in.read() == -1) { + StartEmbeddedJetty.LOGGER.error("End of Stream reached"); + return; + } StartEmbeddedJetty.LOGGER.info(">>> STOPPING EMBEDDED JETTY SERVER"); server.stop(); server.join(); diff --git a/Source/JNA/waffle-jna/src/test/java/waffle/jaas/WindowsLoginModuleTest.java b/Source/JNA/waffle-jna/src/test/java/waffle/jaas/WindowsLoginModuleTest.java index 2561691bae..666cbe996d 100644 --- a/Source/JNA/waffle-jna/src/test/java/waffle/jaas/WindowsLoginModuleTest.java +++ b/Source/JNA/waffle-jna/src/test/java/waffle/jaas/WindowsLoginModuleTest.java @@ -28,12 +28,12 @@ import javax.security.auth.login.LoginException; import mockit.Deencapsulation; +import mockit.Expectations; +import mockit.Mocked; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mockito; import waffle.windows.auth.PrincipalFormat; @@ -49,7 +49,8 @@ public class WindowsLoginModuleTest { private Subject subject; /** The callback handler. */ - private CallbackHandler callbackHandler; + @Mocked + CallbackHandler callbackHandler; /** The options. */ private Map options; @@ -136,7 +137,6 @@ public void commit_withDebug() throws LoginException { public void init() { this.loginModule = new WindowsLoginModule(); this.subject = new Subject(); - this.callbackHandler = Mockito.mock(CallbackHandler.class); this.options = new HashMap<>(); } @@ -200,7 +200,12 @@ public void login_throwIOException() throws LoginException, IOException, Unsuppo this.options.put("debug", "true"); this.loginModule.initialize(this.subject, this.callbackHandler, null, this.options); Assert.assertTrue(this.loginModule.isAllowGuestLogin()); - Mockito.doThrow(new IOException()).when(this.callbackHandler).handle(Matchers.any(Callback[].class)); + Assert.assertNotNull(new Expectations() { + { + WindowsLoginModuleTest.this.callbackHandler.handle(this.withInstanceOf(Callback[].class)); + this.result = new IOException(); + } + }); this.loginModule.login(); } @@ -220,8 +225,12 @@ public void login_throwUnsupportedCallbackException() throws LoginException, IOE this.options.put("debug", "true"); this.loginModule.initialize(this.subject, this.callbackHandler, null, this.options); Assert.assertTrue(this.loginModule.isAllowGuestLogin()); - Mockito.doThrow(new UnsupportedCallbackException(new NameCallback("Callback Exception"))) - .when(this.callbackHandler).handle(Matchers.any(Callback[].class)); + Assert.assertNotNull(new Expectations() { + { + WindowsLoginModuleTest.this.callbackHandler.handle(this.withInstanceOf(Callback[].class)); + this.result = new UnsupportedCallbackException(new NameCallback("Callback Exception")); + } + }); this.loginModule.login(); } diff --git a/Source/JNA/waffle-jna/src/test/java/waffle/servlet/WindowsPrincipalTest.java b/Source/JNA/waffle-jna/src/test/java/waffle/servlet/WindowsPrincipalTest.java index 21ba85ec75..b42980cbb3 100644 --- a/Source/JNA/waffle-jna/src/test/java/waffle/servlet/WindowsPrincipalTest.java +++ b/Source/JNA/waffle-jna/src/test/java/waffle/servlet/WindowsPrincipalTest.java @@ -15,8 +15,9 @@ import org.junit.Assert; import org.junit.Test; -import org.mockito.Mockito; +import mockit.Expectations; +import mockit.Mocked; import waffle.windows.auth.IWindowsAccount; import waffle.windows.auth.IWindowsIdentity; @@ -30,15 +31,25 @@ public class WindowsPrincipalTest { /** The Constant TEST_FQN. */ private static final String TEST_FQN = "ACME\\john.smith"; + /** The windows identity. */ + @Mocked + IWindowsIdentity windowsIdentity; + /** * Test to string. */ @Test public void testToString() { - final IWindowsIdentity windowsIdentity = Mockito.mock(IWindowsIdentity.class); - Mockito.when(windowsIdentity.getFqn()).thenReturn(WindowsPrincipalTest.TEST_FQN); - Mockito.when(windowsIdentity.getGroups()).thenReturn(new IWindowsAccount[0]); - final WindowsPrincipal principal = new WindowsPrincipal(windowsIdentity); + Assert.assertNotNull(new Expectations() { + { + WindowsPrincipalTest.this.windowsIdentity.getFqn(); + this.result = WindowsPrincipalTest.TEST_FQN; + WindowsPrincipalTest.this.windowsIdentity.getGroups(); + this.result = new IWindowsAccount[0]; + + } + }); + final WindowsPrincipal principal = new WindowsPrincipal(this.windowsIdentity); Assert.assertEquals(WindowsPrincipalTest.TEST_FQN, principal.getName()); Assert.assertEquals(WindowsPrincipalTest.TEST_FQN, principal.toString()); } diff --git a/Source/JNA/waffle-shiro/src/main/java/waffle/shiro/dynamic/DynamicAuthenticationFilter.java b/Source/JNA/waffle-shiro/src/main/java/waffle/shiro/dynamic/DynamicAuthenticationFilter.java index a77e1756d0..2fbf316538 100644 --- a/Source/JNA/waffle-shiro/src/main/java/waffle/shiro/dynamic/DynamicAuthenticationFilter.java +++ b/Source/JNA/waffle-shiro/src/main/java/waffle/shiro/dynamic/DynamicAuthenticationFilter.java @@ -134,6 +134,7 @@ public boolean onAccessDenied(final ServletRequest request, final ServletRespons * waffle.shiro.negotiate.NegotiateAuthenticationFilter#onLoginSuccess(org.apache.shiro.authc.AuthenticationToken * , org.apache.shiro.subject.Subject, javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ + @SuppressWarnings("synthetic-access") @Override protected boolean onLoginSuccess(final AuthenticationToken token, final Subject subject, final ServletRequest request, final ServletResponse response) throws Exception { @@ -178,6 +179,7 @@ public boolean onAccessDenied(final ServletRequest request, final ServletRespons * AuthenticationToken, org.apache.shiro.subject.Subject, javax.servlet.ServletRequest, * javax.servlet.ServletResponse) */ + @SuppressWarnings("synthetic-access") @Override protected boolean onLoginSuccess(final AuthenticationToken token, final Subject subject, final ServletRequest request, final ServletResponse response) throws Exception { diff --git a/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/dynamic/DynamicAuthenticationFilterTest.java b/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/dynamic/DynamicAuthenticationFilterTest.java index 684a9d9fc5..cf3d2357c3 100644 --- a/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/dynamic/DynamicAuthenticationFilterTest.java +++ b/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/dynamic/DynamicAuthenticationFilterTest.java @@ -13,75 +13,55 @@ */ package waffle.shiro.dynamic; -import java.util.HashMap; -import java.util.Map; - import javax.servlet.ServletRequest; -import mockit.Deencapsulation; +import mockit.Expectations; +import mockit.Mocked; +import mockit.Tested; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mockito; /** * The Class DynamicAuthenticationFilterTest. - * - * @author Dan Rollo Date: 2/26/13 Time: 5:47 PM */ public class DynamicAuthenticationFilterTest { - /** - * The Class MockServletRequest. - */ - private static abstract class MockServletRequest implements ServletRequest { - - /** The parameters. */ - private final Map parameters = new HashMap<>(); - - /* - * (non-Javadoc) - * @see javax.servlet.ServletRequest#getParameter(java.lang.String) - */ - @Override - public String getParameter(final String name) { - return this.parameters.get(name); - } - - } - /** The dynamic authentication filter. */ - private DynamicAuthenticationFilter dynamicAuthenticationFilter; + @Tested + DynamicAuthenticationFilter dynamicAuthenticationFilter; /** The request. */ - private MockServletRequest request; - - /** - * Sets the up. - */ - @Before - public void setUp() { - this.dynamicAuthenticationFilter = new DynamicAuthenticationFilter(); - - this.request = Mockito.mock(MockServletRequest.class, Mockito.CALLS_REAL_METHODS); - Deencapsulation.setField(this.request, new HashMap()); - } + @Mocked + ServletRequest request; /** * Test is auth type negotiate. */ @Test public void testIsAuthTypeNegotiate() { - Mockito.when(this.request.getParameter(Matchers.anyString())).thenReturn(null); + Assert.assertNotNull(new Expectations() { + { + DynamicAuthenticationFilterTest.this.request.getParameter(this.anyString); + this.result = null; + } + }); Assert.assertFalse(this.dynamicAuthenticationFilter.isAuthTypeNegotiate(this.request)); - Mockito.when(this.request.getParameter(Matchers.anyString())).thenReturn("zzz"); + Assert.assertNotNull(new Expectations() { + { + DynamicAuthenticationFilterTest.this.request.getParameter(this.anyString); + this.result = "zzz"; + } + }); Assert.assertFalse(this.dynamicAuthenticationFilter.isAuthTypeNegotiate(this.request)); - Mockito.when(this.request.getParameter(Matchers.anyString())).thenReturn( - DynamicAuthenticationFilter.PARAM_VAL_AUTHTYPE_NEGOTIATE); + Assert.assertNotNull(new Expectations() { + { + DynamicAuthenticationFilterTest.this.request.getParameter(this.anyString); + this.result = DynamicAuthenticationFilter.PARAM_VAL_AUTHTYPE_NEGOTIATE; + } + }); Assert.assertTrue(this.dynamicAuthenticationFilter.isAuthTypeNegotiate(this.request)); } diff --git a/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/negotiate/NegotiateAuthenticationRealmTest.java b/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/negotiate/NegotiateAuthenticationRealmTest.java index e51e1b03ba..f3c77c1257 100644 --- a/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/negotiate/NegotiateAuthenticationRealmTest.java +++ b/Source/JNA/waffle-shiro/src/test/java/waffle/shiro/negotiate/NegotiateAuthenticationRealmTest.java @@ -13,47 +13,49 @@ */ package waffle.shiro.negotiate; -import junit.framework.TestCase; +import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationToken; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +import mockit.Expectations; +import mockit.Mocked; +import mockit.Tested; /** * The Class NegotiateAuthenticationRealmTest. * * @author Dan Rollo Date: 2/14/13 Time: 11:11 PM */ -public final class NegotiateAuthenticationRealmTest extends TestCase { +public final class NegotiateAuthenticationRealmTest { /** The neg auth realm. */ + @Tested private NegotiateAuthenticationRealm negAuthRealm; - /* - * (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - this.negAuthRealm = new NegotiateAuthenticationRealm(); - } - /** * Test supports. */ + @Test public void testSupports() { - TestCase.assertFalse("Non-NegotiateToken should not be supported.", - this.negAuthRealm.supports(new AuthenticationToken() { - private static final long serialVersionUID = 334672725950031145L; + Assert.assertFalse("Non-NegotiateToken should not be supported.", + this.negAuthRealm.supports(Mockito.mock(AuthenticationToken.class, Mockito.CALLS_REAL_METHODS))); - @Override - public Object getPrincipal() { - return null; - } - - @Override - public Object getCredentials() { - return null; - } - })); + Assert.assertTrue(this.negAuthRealm.supports(new NegotiateToken(null, null, null, null, false, false, null))); + } - TestCase.assertTrue(this.negAuthRealm.supports(new NegotiateToken(null, null, null, null, false, false, null))); + /** + * Test authentication info exception. + */ + @Test(expected = AuthenticationException.class) + public void testAuthenticationInfo(@Mocked final NegotiateToken negotiateToken) { + Assert.assertNotNull(new Expectations() { + { + negotiateToken.getIn(); + this.result = new Byte((byte) 0); + } + }); + this.negAuthRealm.doGetAuthenticationInfo(negotiateToken); } } diff --git a/Source/JNA/waffle-tomcat6/src/main/java/waffle/apache/WaffleAuthenticatorBase.java b/Source/JNA/waffle-tomcat6/src/main/java/waffle/apache/WaffleAuthenticatorBase.java index 3317c58376..2530071c45 100644 --- a/Source/JNA/waffle-tomcat6/src/main/java/waffle/apache/WaffleAuthenticatorBase.java +++ b/Source/JNA/waffle-tomcat6/src/main/java/waffle/apache/WaffleAuthenticatorBase.java @@ -40,6 +40,7 @@ abstract class WaffleAuthenticatorBase extends AuthenticatorBase { private static final Set SUPPORTED_PROTOCOLS = new LinkedHashSet<>(Arrays.asList("Negotiate", "NTLM")); /** The info. */ + @SuppressWarnings("hiding") protected String info; /** The log. */ diff --git a/Source/JNA/waffle-tomcat6/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java b/Source/JNA/waffle-tomcat6/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java index c4ef610c10..b38ee73607 100644 --- a/Source/JNA/waffle-tomcat6/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java +++ b/Source/JNA/waffle-tomcat6/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java @@ -20,7 +20,8 @@ import javax.servlet.http.HttpSession; import org.apache.catalina.connector.Request; -import org.mockito.Mockito; + +import mockit.Mocked; /** * Simple HTTP Request. @@ -70,6 +71,7 @@ public synchronized static void resetRemotePort() { private byte[] content; /** The http session. */ + @Mocked private SimpleHttpSession httpSession; /** The principal. */ @@ -80,8 +82,6 @@ public synchronized static void resetRemotePort() { */ public SimpleHttpRequest() { super(); - this.httpSession = Mockito.mock(SimpleHttpSession.class, Mockito.CALLS_REAL_METHODS); - this.httpSession.setAttributes(new HashMap()); this.remotePort = SimpleHttpRequest.nextRemotePort(); } @@ -211,10 +211,6 @@ public HttpSession getSession() { */ @Override public HttpSession getSession(final boolean create) { - if (this.httpSession == null && create) { - this.httpSession = Mockito.mock(SimpleHttpSession.class, Mockito.CALLS_REAL_METHODS); - this.httpSession.setAttributes(new HashMap()); - } return this.httpSession; } diff --git a/Source/JNA/waffle-tomcat7/src/main/java/waffle/apache/WaffleAuthenticatorBase.java b/Source/JNA/waffle-tomcat7/src/main/java/waffle/apache/WaffleAuthenticatorBase.java index 68580069b2..d704de8d1c 100644 --- a/Source/JNA/waffle-tomcat7/src/main/java/waffle/apache/WaffleAuthenticatorBase.java +++ b/Source/JNA/waffle-tomcat7/src/main/java/waffle/apache/WaffleAuthenticatorBase.java @@ -43,6 +43,7 @@ abstract class WaffleAuthenticatorBase extends AuthenticatorBase { private static final Set SUPPORTED_PROTOCOLS = new LinkedHashSet<>(Arrays.asList("Negotiate", "NTLM")); /** The info. */ + @SuppressWarnings("hiding") protected String info; /** The log. */ diff --git a/Source/JNA/waffle-tomcat7/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java b/Source/JNA/waffle-tomcat7/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java index fe4e6ab80e..3cd7ea8c5e 100644 --- a/Source/JNA/waffle-tomcat7/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java +++ b/Source/JNA/waffle-tomcat7/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java @@ -20,7 +20,8 @@ import javax.servlet.http.HttpSession; import org.apache.catalina.connector.Request; -import org.mockito.Mockito; + +import mockit.Mocked; /** * Simple HTTP Request. @@ -70,6 +71,7 @@ public synchronized static void resetRemotePort() { private byte[] content; /** The http session. */ + @Mocked private SimpleHttpSession httpSession; /** The principal. */ @@ -80,8 +82,6 @@ public synchronized static void resetRemotePort() { */ public SimpleHttpRequest() { super(); - this.httpSession = Mockito.mock(SimpleHttpSession.class, Mockito.CALLS_REAL_METHODS); - this.httpSession.setAttributes(new HashMap()); this.remotePort = SimpleHttpRequest.nextRemotePort(); } @@ -214,10 +214,6 @@ public HttpSession getSession() { */ @Override public HttpSession getSession(final boolean create) { - if (this.httpSession == null && create) { - this.httpSession = Mockito.mock(SimpleHttpSession.class, Mockito.CALLS_REAL_METHODS); - this.httpSession.setAttributes(new HashMap()); - } return this.httpSession; } diff --git a/Source/JNA/waffle-tomcat8/pom.xml b/Source/JNA/waffle-tomcat8/pom.xml index 24a8539a5c..8915fa72c0 100644 --- a/Source/JNA/waffle-tomcat8/pom.xml +++ b/Source/JNA/waffle-tomcat8/pom.xml @@ -13,9 +13,6 @@ Tomcat 8 integration for WAFFLE http://dblock.github.com/waffle/ - 1.7 - 1.7 - .. 8.0.28 diff --git a/Source/JNA/waffle-tomcat8/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java b/Source/JNA/waffle-tomcat8/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java index fe4e6ab80e..3cd7ea8c5e 100644 --- a/Source/JNA/waffle-tomcat8/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java +++ b/Source/JNA/waffle-tomcat8/src/test/java/waffle/apache/catalina/SimpleHttpRequest.java @@ -20,7 +20,8 @@ import javax.servlet.http.HttpSession; import org.apache.catalina.connector.Request; -import org.mockito.Mockito; + +import mockit.Mocked; /** * Simple HTTP Request. @@ -70,6 +71,7 @@ public synchronized static void resetRemotePort() { private byte[] content; /** The http session. */ + @Mocked private SimpleHttpSession httpSession; /** The principal. */ @@ -80,8 +82,6 @@ public synchronized static void resetRemotePort() { */ public SimpleHttpRequest() { super(); - this.httpSession = Mockito.mock(SimpleHttpSession.class, Mockito.CALLS_REAL_METHODS); - this.httpSession.setAttributes(new HashMap()); this.remotePort = SimpleHttpRequest.nextRemotePort(); } @@ -214,10 +214,6 @@ public HttpSession getSession() { */ @Override public HttpSession getSession(final boolean create) { - if (this.httpSession == null && create) { - this.httpSession = Mockito.mock(SimpleHttpSession.class, Mockito.CALLS_REAL_METHODS); - this.httpSession.setAttributes(new HashMap()); - } return this.httpSession; } diff --git a/travis/after_success.sh b/travis/after_success.sh index 5ee7cb2fc4..87685d62f6 100644 --- a/travis/after_success.sh +++ b/travis/after_success.sh @@ -25,11 +25,12 @@ echo "Java detected: ${VER}" if [ "$waffle_repo" == "https://github.com/dblock/waffle.git" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then if [ $VER == "18" ]; then - mvn clean deploy -q --settings ../../travis/settings.xml + mvn clean deploy -DskipTests -q --settings ../../travis/settings.xml echo -e "Successfully deployed SNAPSHOT artifacts to Sonatype under Travis job ${TRAVIS_JOB_NUMBER}" - mvn clean test jacoco:report coveralls:report -q - echo -e "Successfully deployed Coveralls Report under Travis job ${TRAVIS_JOB_NUMBER}" - mvn site site:deploy -q + # Cannot run tests on linux + # mvn clean test jacoco:report coveralls:report -q + # echo -e "Successfully deployed Coveralls Report under Travis job ${TRAVIS_JOB_NUMBER}" + mvn site site:deploy -DskipTests -q echo -e "Successfully deploy site under Travis job ${TRAVIS_JOB_NUMBER}" else echo "Java Version does not support additonal activity for travis CI"