You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/09/05 03:20:19 UTC

[incubator-skywalking] branch 5.x updated: Remove webapp test.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch 5.x
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/5.x by this push:
     new ab9b0bc  Remove webapp test.
ab9b0bc is described below

commit ab9b0bcb922bb2507733830e5e4d28347ec96323
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Sep 5 11:20:12 2018 +0800

    Remove webapp test.
---
 .../apm/webapp/proxy/NIWSServerListTest.java       | 95 ---------------------
 .../apm/webapp/proxy/RewritePathFilterTest.java    | 60 --------------
 .../apm/webapp/security/LoginFilterTest.java       | 70 ----------------
 .../skywalking/apm/webapp/security/LoginTest.java  | 90 --------------------
 .../apm/webapp/security/ReaderAccountTest.java     | 37 ---------
 .../apm/webapp/security/UserCheckerTest.java       | 96 ----------------------
 6 files changed, 448 deletions(-)

diff --git a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/NIWSServerListTest.java b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/NIWSServerListTest.java
deleted file mode 100644
index 38748ce..0000000
--- a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/NIWSServerListTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp.proxy;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.core.env.AbstractEnvironment;
-import org.springframework.core.env.Environment;
-import org.springframework.core.env.MapPropertySource;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.netflix.loadbalancer.Server;
-import com.netflix.loadbalancer.ServerList;
-import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
-import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest
-@DirtiesContext
-public class NIWSServerListTest {
-    @Autowired
-    private Environment env;
-
-    @Autowired
-    private SpringClientFactory factory;
-
-    private Map<String, String> serverListClassNames = new HashMap<String, String>();
-
-    @Before
-    public void initServerListClassNames() {
-        for (Iterator<?> iter = ((AbstractEnvironment) env).getPropertySources().iterator(); iter.hasNext();) {
-            Object propertySource = iter.next();
-            if (propertySource instanceof MapPropertySource) {
-                Map<String, Object> mapPropertySource = ((MapPropertySource) propertySource).getSource();
-                for (Map.Entry<String, Object> entry : mapPropertySource.entrySet()) {
-                    String key = entry.getKey();
-                    int index;
-                    if (key.endsWith(".NIWSServerListClassName") &&
-                            (index = key.indexOf(".ribbon")) > 0) {
-                        String clientName = key.substring(0, index);
-                        serverListClassNames.put(clientName,(String)entry.getValue());
-                    }
-                }
-            }
-        }
-    }
-
-    @Test
-    public void serverListClass() throws ClassNotFoundException {
-        for (String serverListClassName : serverListClassNames.values()) {
-            Class<?> clazz = Class.forName(serverListClassName);
-        }
-    }
-
-    @Test
-    public void serverListFliter() {
-        for (Map.Entry<String, String> entry : serverListClassNames.entrySet()) {
-            String clientName = entry.getKey();
-            String serverListClassName = entry.getValue();
-            ServerList<Server> serverList = getLoadBalancer(clientName).getServerListImpl();
-            assertNotNull("Client: " + clientName + "'s ServerListImpl is null",serverList);
-            assertEquals("Clinet: " + clientName + "'s ServerListImpl not Same with setting in configs",
-                    serverListClassName, serverList.getClass().getName());
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private ZoneAwareLoadBalancer<Server> getLoadBalancer(String name) {
-        return (ZoneAwareLoadBalancer<Server>)this.factory.getLoadBalancer(name);
-    }
-}
diff --git a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/RewritePathFilterTest.java b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/RewritePathFilterTest.java
deleted file mode 100644
index 013d96d..0000000
--- a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/RewritePathFilterTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp.proxy;
-
-import com.netflix.zuul.context.RequestContext;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER;
-
-public class RewritePathFilterTest {
-
-    private RewritePathFilter filter = new RewritePathFilter();
-
-    @Before
-    public void init() {
-        filter.setPath("/graphql");
-    }
-
-    @Test
-    public void filterOrder() {
-        assertThat(filter.filterOrder(), is(PRE_DECORATION_FILTER_ORDER + 2));
-    }
-
-    @Test
-    public void filterType() {
-        assertThat(filter.filterType(), is("pre"));
-    }
-
-    @Test
-    public void shouldFilter() {
-        assertFalse(filter.shouldFilter());
-        RequestContext.getCurrentContext().set("requestURI");
-        assertTrue(filter.shouldFilter());
-    }
-
-    @Test
-    public void run() {
-        filter.run();
-        assertThat(RequestContext.getCurrentContext().get("requestURI"), is("/graphql"));
-    }
-}
\ No newline at end of file
diff --git a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/LoginFilterTest.java b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/LoginFilterTest.java
deleted file mode 100644
index cb20ba2..0000000
--- a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/LoginFilterTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp.security;
-
-import com.netflix.zuul.context.RequestContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER;
-
-
-public class LoginFilterTest {
-    
-    private LoginFilter loginFilter;
-
-    @Before
-    public void setUp() {
-        UserChecker checker = new UserChecker();
-        UserChecker.User user = new UserChecker.User();
-        user.setPassword("admin");
-        checker.getUser().put("admin", user);
-        loginFilter = new LoginFilter(checker);
-    }
-
-    @After
-    public void tearDown() {
-        RequestContext.testSetCurrentContext(null);
-    }
-
-    @Test
-    public void assertFilterType() {
-        assertThat(loginFilter.filterType(), is("pre"));
-    }
-
-    @Test
-    public void assertFilterOrder() {
-        assertThat(loginFilter.filterOrder(), is(PRE_DECORATION_FILTER_ORDER + 1));
-    }
-
-    @Test
-    public void assertShouldFilter() {
-        RequestContext ctx = new RequestContext();
-        ctx.set("requestURI", "/login/account");
-        RequestContext.testSetCurrentContext(ctx);
-        assertTrue(loginFilter.shouldFilter());
-        ctx.set("requestURI", "/dashboard");
-        assertFalse(loginFilter.shouldFilter());
-    }
-}
\ No newline at end of file
diff --git a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/LoginTest.java b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/LoginTest.java
deleted file mode 100644
index e077d51..0000000
--- a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/LoginTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp.security;
-
-import com.netflix.zuul.context.RequestContext;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.UndeclaredThrowableException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LoginTest {
-
-    private LoginFilter loginFilter;
-
-    @Mock
-    private RequestContext ctx;
-
-    @Mock
-    private HttpServletRequest request;
-    
-    @Mock
-    private HttpServletResponse response;
-
-    @Before
-    public void setUp() {
-        UserChecker checker = new UserChecker();
-        UserChecker.User user = new UserChecker.User();
-        user.setPassword("admin");
-        checker.getUser().put("admin", user);
-        loginFilter = new LoginFilter(checker);
-        when(ctx.getRequest()).thenReturn(request);
-        when(ctx.getResponse()).thenReturn(response);
-        RequestContext.testSetCurrentContext(ctx);
-    }
-
-    @Test
-    public void assertSuccessLogin() throws IOException {
-        when(request.getReader()).thenReturn(new BufferedReader(new StringReader("{\"userName\": \"admin\", \"password\":\"admin\"}")));
-        loginFilter.run();
-        assertHeaderAndStatusCode();
-        verify(ctx).setResponseBody("{\"status\":\"ok\",\"currentAuthority\":\"admin\"}");
-    }
-    
-    @Test
-    public void assertFailLogin() throws IOException {
-        when(request.getReader()).thenReturn(new BufferedReader(new StringReader("{\"userName\": \"admin\", \"password\":\"888888\"}")));
-        loginFilter.run();
-        assertHeaderAndStatusCode();
-        verify(ctx).setResponseBody("{\"status\":\"error\",\"currentAuthority\":\"guest\"}");
-    }
-
-    @Test(expected = UndeclaredThrowableException.class)
-    public void assertException() throws IOException {
-        when(request.getReader()).thenThrow(new IOException());
-        loginFilter.run();
-    }
-    
-    private void assertHeaderAndStatusCode() {
-        verify(ctx).setResponseStatusCode(HttpServletResponse.SC_OK);
-        verify(response).setContentType("application/json");
-        verify(response).setCharacterEncoding("UTF-8");
-    }
-}
diff --git a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/ReaderAccountTest.java b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/ReaderAccountTest.java
deleted file mode 100644
index 3cfe631..0000000
--- a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/ReaderAccountTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp.security;
-
-import java.io.BufferedReader;
-import java.io.StringReader;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
-public class ReaderAccountTest {
-
-    @Test
-    public void assertNewReaderAccount() {
-        Account account = ReaderAccount.newReaderAccount(new BufferedReader(new StringReader("{\"userName\": \"admin\", \"password\":\"888888\"}")));
-        assertThat(account.userName(), is("admin"));
-        assertThat(account.password(), is("888888"));
-    }
-    
-}
\ No newline at end of file
diff --git a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/UserCheckerTest.java b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/UserCheckerTest.java
deleted file mode 100644
index 81c266b..0000000
--- a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/security/UserCheckerTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp.security;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class UserCheckerTest {
-
-    @Test
-    public void assertCheckSuccess() {
-        UserChecker checker = new UserChecker();
-        UserChecker.User user = new UserChecker.User();
-        user.setPassword("888888");
-        checker.getUser().put("admin", user);
-        assertTrue(checker.check(new Account() {
-            @Override public String userName() {
-                return "admin";
-            }
-
-            @Override public String password() {
-                return "888888";
-            }
-        }));
-    }
-
-    @Test
-    public void assertCheckFail() {
-        UserChecker checker = new UserChecker();
-        UserChecker.User user = new UserChecker.User();
-        user.setPassword("123456");
-        checker.getUser().put("guest", user);
-        assertFalse(checker.check(new Account() {
-            @Override public String userName() {
-                return "admin";
-            }
-
-            @Override public String password() {
-                return "888888";
-            }
-        }));
-        assertFalse(checker.check(new Account() {
-            @Override public String userName() {
-                return "guest";
-            }
-
-            @Override public String password() {
-                return "888888";
-            }
-        }));
-        assertFalse(checker.check(new Account() {
-            @Override public String userName() {
-                return "admin";
-            }
-
-            @Override public String password() {
-                return "123456";
-            }
-        }));
-        assertFalse(checker.check(new Account() {
-            @Override public String userName() {
-                return "";
-            }
-
-            @Override public String password() {
-                return "123456";
-            }
-        }));
-        assertFalse(checker.check(new Account() {
-            @Override public String userName() {
-                return "admin";
-            }
-
-            @Override public String password() {
-                return "";
-            }
-        }));
-    }
-}
\ No newline at end of file