| 1 |
|
package com.atlassian.xwork.interceptors; |
| 2 |
|
|
| 3 |
|
import com.opensymphony.xwork.config.ConfigurationProvider; |
| 4 |
|
import com.opensymphony.xwork.config.Configuration; |
| 5 |
|
import com.opensymphony.xwork.config.ConfigurationException; |
| 6 |
|
import com.opensymphony.xwork.config.ConfigurationManager; |
| 7 |
|
import com.opensymphony.xwork.config.entities.PackageConfig; |
| 8 |
|
import com.opensymphony.xwork.config.entities.ActionConfig; |
| 9 |
|
import com.opensymphony.xwork.interceptor.Interceptor; |
| 10 |
|
import com.opensymphony.xwork.ActionSupport; |
| 11 |
|
import com.opensymphony.xwork.ActionProxy; |
| 12 |
|
import com.opensymphony.xwork.ActionProxyFactory; |
| 13 |
|
import com.opensymphony.xwork.Action; |
| 14 |
|
import com.opensymphony.webwork.ServletActionContext; |
| 15 |
|
import com.opensymphony.webwork.WebWorkStatics; |
| 16 |
|
import com.atlassian.xwork.PermittedMethods; |
| 17 |
|
import com.atlassian.xwork.HttpMethod; |
| 18 |
|
|
| 19 |
|
import java.util.*; |
| 20 |
|
|
| 21 |
|
import javax.servlet.http.HttpServletRequest; |
| 22 |
|
|
| 23 |
|
import org.jmock.Mock; |
| 24 |
|
import org.jmock.MockObjectTestCase; |
| 25 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (154) |
Complexity: 12 |
Complexity Density: 0.08 |
|
| 26 |
|
public class TestRestrictHttpMethodInterceptor extends MockObjectTestCase |
| 27 |
|
{ |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
private RestrictHttpMethodInterceptor.SecurityLevel securityLevel; |
| 34 |
|
private Mock mockServletRequest; |
| 35 |
|
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
| 36 |
|
public static class UnAnnotatedAction extends ActionSupport |
| 37 |
|
{ |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 38 |
64
|
@Override... |
| 39 |
|
public String execute() throws Exception |
| 40 |
|
{ |
| 41 |
64
|
return SUCCESS; |
| 42 |
|
} |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 44 |
11
|
@Override... |
| 45 |
|
public String doDefault() throws Exception |
| 46 |
|
{ |
| 47 |
11
|
return SUCCESS; |
| 48 |
|
|
| 49 |
|
} |
| 50 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
0
|
public String doEdit() throws Exception... |
| 52 |
|
{ |
| 53 |
0
|
return SUCCESS; |
| 54 |
|
} |
| 55 |
|
} |
| 56 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 5 |
Complexity Density: 1 |
|
| 57 |
|
public static class AnnotatedAction extends ActionSupport |
| 58 |
|
{ |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
26
|
@Override... |
| 60 |
|
@PermittedMethods({HttpMethod.POST, HttpMethod.GET}) |
| 61 |
|
public String execute() throws Exception |
| 62 |
|
{ |
| 63 |
26
|
return SUCCESS; |
| 64 |
|
} |
| 65 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 66 |
10
|
@Override... |
| 67 |
|
@PermittedMethods({HttpMethod.POST, HttpMethod.PUT}) |
| 68 |
|
public String doDefault() throws Exception |
| 69 |
|
{ |
| 70 |
10
|
return SUCCESS; |
| 71 |
|
|
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 74 |
15
|
@PermittedMethods({HttpMethod.ANY_METHOD})... |
| 75 |
|
public String anyMethod() throws Exception |
| 76 |
|
{ |
| 77 |
15
|
return SUCCESS; |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 80 |
9
|
@PermittedMethods({HttpMethod.ALL_RFC2616})... |
| 81 |
|
public String allRfc2616() throws Exception |
| 82 |
|
{ |
| 83 |
9
|
return SUCCESS; |
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 86 |
6
|
@PermittedMethods({HttpMethod.ALL_DEFINED})... |
| 87 |
|
public String allDefined() throws Exception |
| 88 |
|
{ |
| 89 |
6
|
return SUCCESS; |
| 90 |
|
} |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
|
private class SimpleInterceptor extends RestrictHttpMethodInterceptor |
| 94 |
|
{ |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 95 |
222
|
@Override... |
| 96 |
|
protected SecurityLevel getSecurityLevel() |
| 97 |
|
{ |
| 98 |
222
|
return securityLevel; |
| 99 |
|
} |
| 100 |
|
} |
| 101 |
|
|
|
|
|
| 90% |
Uncovered Elements: 3 (30) |
Complexity: 6 |
Complexity Density: 0.25 |
|
| 102 |
|
private class CustomConfigurationProvider implements ConfigurationProvider |
| 103 |
|
{ |
| 104 |
|
private List<Interceptor> interceptors; |
| 105 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 106 |
0
|
public void destroy()... |
| 107 |
|
{ |
| 108 |
|
} |
| 109 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
|
| 110 |
9
|
public void init(Configuration configuration) throws ConfigurationException... |
| 111 |
|
{ |
| 112 |
9
|
PackageConfig packageConfig = new PackageConfig(); |
| 113 |
9
|
interceptors = new ArrayList<Interceptor>(); |
| 114 |
9
|
interceptors.add(new SimpleInterceptor()); |
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
9
|
packageConfig.addActionConfig("unannotated-execute", makeActionConfig(UnAnnotatedAction.class, "execute")); |
| 120 |
9
|
packageConfig.addActionConfig("unannotated-null", makeActionConfig(UnAnnotatedAction.class, null)); |
| 121 |
9
|
packageConfig.addActionConfig("unannotated-dodefault", makeActionConfig(UnAnnotatedAction.class, "doDefault")); |
| 122 |
9
|
packageConfig.addActionConfig("unannotated-doedit", makeActionConfig(UnAnnotatedAction.class, "doEdit")); |
| 123 |
|
|
| 124 |
9
|
packageConfig.addActionConfig("configured-null", makeActionConfig(UnAnnotatedAction.class, null, "GET, POST")); |
| 125 |
9
|
packageConfig.addActionConfig("configured-execute", makeActionConfig(UnAnnotatedAction.class, "execute", "GET, POST")); |
| 126 |
9
|
packageConfig.addActionConfig("configured-dodefault", makeActionConfig(UnAnnotatedAction.class, "execute", "POST")); |
| 127 |
9
|
packageConfig.addActionConfig("configured-doedit", makeActionConfig(UnAnnotatedAction.class, "execute", " GET, PUT , POST,CHEESE")); |
| 128 |
9
|
packageConfig.addActionConfig("configured-anymethod", makeActionConfig(UnAnnotatedAction.class, "execute", "ANY_METHOD")); |
| 129 |
9
|
packageConfig.addActionConfig("configured-rfc2616", makeActionConfig(UnAnnotatedAction.class, "execute", "ALL_RFC2616")); |
| 130 |
|
|
| 131 |
9
|
packageConfig.addActionConfig("annotated-execute", makeActionConfig(AnnotatedAction.class, "execute")); |
| 132 |
9
|
packageConfig.addActionConfig("annotated-null", makeActionConfig(AnnotatedAction.class, null)); |
| 133 |
9
|
packageConfig.addActionConfig("annotated-dodefault", makeActionConfig(AnnotatedAction.class, "doDefault")); |
| 134 |
9
|
packageConfig.addActionConfig("annotated-anymethod", makeActionConfig(AnnotatedAction.class, "anyMethod")); |
| 135 |
9
|
packageConfig.addActionConfig("annotated-allrfc", makeActionConfig(AnnotatedAction.class, "allRfc2616")); |
| 136 |
9
|
packageConfig.addActionConfig("annotated-alldefined", makeActionConfig(AnnotatedAction.class, "allDefined")); |
| 137 |
|
|
| 138 |
9
|
configuration.addPackageConfig("defaultPackage", packageConfig); |
| 139 |
|
} |
| 140 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 141 |
54
|
private ActionConfig makeActionConfig(Class actionClass, String methodName, String permittedMethodsParameter)... |
| 142 |
|
{ |
| 143 |
54
|
return makeActionConfig(actionClass, methodName, Collections.singletonMap(RestrictHttpMethodInterceptor.PERMITTED_METHODS_PARAM_NAME, permittedMethodsParameter)); |
| 144 |
|
} |
| 145 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 146 |
144
|
private ActionConfig makeActionConfig(Class actionClass, String methodName, Map parameterMap)... |
| 147 |
|
{ |
| 148 |
144
|
return new ActionConfig(methodName, actionClass, parameterMap, new HashMap(), interceptors); |
| 149 |
|
} |
| 150 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 151 |
90
|
private ActionConfig makeActionConfig(Class actionClass, String methodName)... |
| 152 |
|
{ |
| 153 |
90
|
return makeActionConfig(actionClass, methodName, new HashMap()); |
| 154 |
|
} |
| 155 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 156 |
0
|
public boolean needsReload()... |
| 157 |
|
{ |
| 158 |
0
|
return false; |
| 159 |
|
} |
| 160 |
|
} |
| 161 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 162 |
5
|
@Override... |
| 163 |
|
protected void setUp() throws Exception |
| 164 |
|
{ |
| 165 |
5
|
super.setUp(); |
| 166 |
|
|
| 167 |
5
|
ConfigurationManager.addConfigurationProvider(new CustomConfigurationProvider()); |
| 168 |
5
|
ConfigurationManager.getConfiguration().reload(); |
| 169 |
|
|
| 170 |
5
|
mockServletRequest = new Mock(HttpServletRequest.class); |
| 171 |
5
|
ServletActionContext.setRequest((HttpServletRequest) mockServletRequest.proxy()); |
| 172 |
|
} |
| 173 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 174 |
5
|
@Override... |
| 175 |
|
protected void tearDown() throws Exception |
| 176 |
|
{ |
| 177 |
5
|
ServletActionContext.setRequest(null); |
| 178 |
5
|
ConfigurationManager.destroyConfiguration(); |
| 179 |
5
|
ConfigurationManager.clearConfigurationProviders(); |
| 180 |
5
|
super.tearDown(); |
| 181 |
|
} |
| 182 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1
PASS
|
|
| 183 |
1
|
public void testSecurityLevelNone() throws Exception... |
| 184 |
|
{ |
| 185 |
1
|
this.securityLevel = RestrictHttpMethodInterceptor.SecurityLevel.NONE; |
| 186 |
|
|
| 187 |
1
|
testInterceptor("unannotated-execute", "GET", Action.SUCCESS); |
| 188 |
1
|
testInterceptor("unannotated-execute", "POST", Action.SUCCESS); |
| 189 |
1
|
testInterceptor("unannotated-execute", "PROPFIND", Action.SUCCESS); |
| 190 |
1
|
testInterceptor("unannotated-execute", "MONKEY", Action.SUCCESS); |
| 191 |
|
|
| 192 |
1
|
testInterceptor("unannotated-null", "GET", Action.SUCCESS); |
| 193 |
1
|
testInterceptor("unannotated-null", "POST", Action.SUCCESS); |
| 194 |
1
|
testInterceptor("unannotated-null", "PROPFIND", Action.SUCCESS); |
| 195 |
1
|
testInterceptor("unannotated-null", "MONKEY", Action.SUCCESS); |
| 196 |
|
|
| 197 |
1
|
testInterceptor("unannotated-dodefault", "GET", Action.SUCCESS); |
| 198 |
1
|
testInterceptor("unannotated-dodefault", "POST", Action.SUCCESS); |
| 199 |
1
|
testInterceptor("unannotated-dodefault", "PROPFIND", Action.SUCCESS); |
| 200 |
1
|
testInterceptor("unannotated-dodefault", "MONKEY", Action.SUCCESS); |
| 201 |
|
|
| 202 |
1
|
testInterceptor("annotated-execute", "GET", Action.SUCCESS); |
| 203 |
1
|
testInterceptor("annotated-execute", "POST", Action.SUCCESS); |
| 204 |
1
|
testInterceptor("annotated-execute", "PROPFIND", Action.SUCCESS); |
| 205 |
1
|
testInterceptor("annotated-execute", "MONKEY", Action.SUCCESS); |
| 206 |
|
|
| 207 |
1
|
testInterceptor("annotated-null", "GET", Action.SUCCESS); |
| 208 |
1
|
testInterceptor("annotated-null", "POST", Action.SUCCESS); |
| 209 |
1
|
testInterceptor("annotated-null", "PROPFIND", Action.SUCCESS); |
| 210 |
1
|
testInterceptor("annotated-null", "MONKEY", Action.SUCCESS); |
| 211 |
|
|
| 212 |
1
|
testInterceptor("annotated-dodefault", "GET", Action.SUCCESS); |
| 213 |
1
|
testInterceptor("annotated-dodefault", "POST", Action.SUCCESS); |
| 214 |
1
|
testInterceptor("annotated-dodefault", "PROPFIND", Action.SUCCESS); |
| 215 |
1
|
testInterceptor("annotated-dodefault", "MONKEY", Action.SUCCESS); } |
| 216 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
| 217 |
1
|
public void testSecurityLevelOptIn() throws Exception... |
| 218 |
|
{ |
| 219 |
1
|
this.securityLevel = RestrictHttpMethodInterceptor.SecurityLevel.OPT_IN; |
| 220 |
|
|
| 221 |
1
|
testInterceptor("unannotated-execute", "GET", Action.SUCCESS); |
| 222 |
1
|
testInterceptor("unannotated-execute", "POST", Action.SUCCESS); |
| 223 |
1
|
testInterceptor("unannotated-execute", "PROPFIND", Action.SUCCESS); |
| 224 |
1
|
testInterceptor("unannotated-execute", "MONKEY", Action.SUCCESS); |
| 225 |
|
|
| 226 |
1
|
testInterceptor("unannotated-null", "GET", Action.SUCCESS); |
| 227 |
1
|
testInterceptor("unannotated-null", "POST", Action.SUCCESS); |
| 228 |
1
|
testInterceptor("unannotated-null", "PROPFIND", Action.SUCCESS); |
| 229 |
1
|
testInterceptor("unannotated-null", "MONKEY", Action.SUCCESS); |
| 230 |
|
|
| 231 |
1
|
testInterceptor("unannotated-dodefault", "GET", Action.SUCCESS); |
| 232 |
1
|
testInterceptor("unannotated-dodefault", "POST", Action.SUCCESS); |
| 233 |
1
|
testInterceptor("unannotated-dodefault", "PROPFIND", Action.SUCCESS); |
| 234 |
1
|
testInterceptor("unannotated-dodefault", "MONKEY", Action.SUCCESS); |
| 235 |
|
|
| 236 |
1
|
assertAnnotationsRespected(); |
| 237 |
|
} |
| 238 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
| 239 |
1
|
public void testSecurityLevelDefault() throws Exception... |
| 240 |
|
{ |
| 241 |
1
|
this.securityLevel = RestrictHttpMethodInterceptor.SecurityLevel.DEFAULT; |
| 242 |
|
|
| 243 |
1
|
testInterceptor("unannotated-execute", "GET", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 244 |
1
|
testInterceptor("unannotated-execute", "POST", Action.SUCCESS); |
| 245 |
1
|
testInterceptor("unannotated-execute", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 246 |
1
|
testInterceptor("unannotated-execute", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 247 |
|
|
| 248 |
1
|
testInterceptor("unannotated-null", "GET", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 249 |
1
|
testInterceptor("unannotated-null", "POST", Action.SUCCESS); |
| 250 |
1
|
testInterceptor("unannotated-null", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 251 |
1
|
testInterceptor("unannotated-null", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 252 |
|
|
| 253 |
1
|
testInterceptor("unannotated-dodefault", "GET", Action.SUCCESS); |
| 254 |
1
|
testInterceptor("unannotated-dodefault", "HEAD", Action.SUCCESS); |
| 255 |
1
|
testInterceptor("unannotated-dodefault", "POST", Action.SUCCESS); |
| 256 |
1
|
testInterceptor("unannotated-dodefault", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 257 |
1
|
testInterceptor("unannotated-dodefault", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 258 |
|
|
| 259 |
1
|
assertAnnotationsRespected(); |
| 260 |
|
} |
| 261 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
| 262 |
1
|
public void testNoRequest() throws Exception... |
| 263 |
|
{ |
| 264 |
1
|
this.securityLevel = RestrictHttpMethodInterceptor.SecurityLevel.OPT_IN; |
| 265 |
|
|
| 266 |
1
|
testInterceptorWithNoRequest("annotated-execute", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 267 |
1
|
testInterceptorWithNoRequest("unannotated-execute", Action.SUCCESS); |
| 268 |
|
} |
| 269 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
| 270 |
1
|
public void testSecurityLevelStrict() throws Exception... |
| 271 |
|
{ |
| 272 |
1
|
this.securityLevel = RestrictHttpMethodInterceptor.SecurityLevel.STRICT; |
| 273 |
|
|
| 274 |
1
|
testInterceptor("unannotated-execute", "GET", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 275 |
1
|
testInterceptor("unannotated-execute", "POST", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 276 |
1
|
testInterceptor("unannotated-execute", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 277 |
1
|
testInterceptor("unannotated-execute", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 278 |
|
|
| 279 |
1
|
testInterceptor("unannotated-null", "GET", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 280 |
1
|
testInterceptor("unannotated-null", "POST", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 281 |
1
|
testInterceptor("unannotated-null", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 282 |
1
|
testInterceptor("unannotated-null", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 283 |
|
|
| 284 |
1
|
testInterceptor("unannotated-dodefault", "GET", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 285 |
1
|
testInterceptor("unannotated-dodefault", "POST", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 286 |
1
|
testInterceptor("unannotated-dodefault", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 287 |
1
|
testInterceptor("unannotated-dodefault", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 288 |
|
|
| 289 |
1
|
assertAnnotationsRespected(); |
| 290 |
|
} |
| 291 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (53) |
Complexity: 1 |
Complexity Density: 0.02 |
|
| 292 |
3
|
private void assertAnnotationsRespected() throws Exception... |
| 293 |
|
{ |
| 294 |
3
|
testInterceptor("annotated-execute", "GET", Action.SUCCESS); |
| 295 |
3
|
testInterceptor("annotated-execute", "HEAD", Action.SUCCESS); |
| 296 |
3
|
testInterceptor("annotated-execute", "POST", Action.SUCCESS); |
| 297 |
3
|
testInterceptor("annotated-execute", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 298 |
3
|
testInterceptor("annotated-execute", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 299 |
|
|
| 300 |
3
|
testInterceptor("annotated-null", "GET", Action.SUCCESS); |
| 301 |
3
|
testInterceptor("annotated-null", "HEAD", Action.SUCCESS); |
| 302 |
3
|
testInterceptor("annotated-null", "POST", Action.SUCCESS); |
| 303 |
3
|
testInterceptor("annotated-null", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 304 |
3
|
testInterceptor("annotated-null", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 305 |
|
|
| 306 |
3
|
testInterceptor("annotated-dodefault", "GET", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 307 |
3
|
testInterceptor("annotated-dodefault", "POST", Action.SUCCESS); |
| 308 |
3
|
testInterceptor("annotated-dodefault", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 309 |
3
|
testInterceptor("annotated-dodefault", "PUT", Action.SUCCESS); |
| 310 |
|
|
| 311 |
3
|
testInterceptor("annotated-allrfc", "GET", Action.SUCCESS); |
| 312 |
3
|
testInterceptor("annotated-allrfc", "HEAD", Action.SUCCESS); |
| 313 |
3
|
testInterceptor("annotated-allrfc", "POST", Action.SUCCESS); |
| 314 |
3
|
testInterceptor("annotated-allrfc", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 315 |
3
|
testInterceptor("annotated-allrfc", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 316 |
|
|
| 317 |
3
|
testInterceptor("annotated-anymethod", "GET", Action.SUCCESS); |
| 318 |
3
|
testInterceptor("annotated-anymethod", "HEAD", Action.SUCCESS); |
| 319 |
3
|
testInterceptor("annotated-anymethod", "POST", Action.SUCCESS); |
| 320 |
3
|
testInterceptor("annotated-anymethod", "PROPFIND", Action.SUCCESS); |
| 321 |
3
|
testInterceptor("annotated-anymethod", "MONKEY", Action.SUCCESS); |
| 322 |
|
|
| 323 |
3
|
testInterceptor("annotated-alldefined", "GET", Action.SUCCESS); |
| 324 |
3
|
testInterceptor("annotated-alldefined", "PROPFIND", Action.SUCCESS); |
| 325 |
3
|
testInterceptor("annotated-alldefined", "CHEESE", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 326 |
|
|
| 327 |
3
|
testInterceptor("configured-execute", "GET", Action.SUCCESS); |
| 328 |
3
|
testInterceptor("configured-execute", "HEAD", Action.SUCCESS); |
| 329 |
3
|
testInterceptor("configured-execute", "POST", Action.SUCCESS); |
| 330 |
3
|
testInterceptor("configured-execute", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 331 |
3
|
testInterceptor("configured-execute", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 332 |
|
|
| 333 |
3
|
testInterceptor("configured-null", "GET", Action.SUCCESS); |
| 334 |
3
|
testInterceptor("configured-null", "HEAD", Action.SUCCESS); |
| 335 |
3
|
testInterceptor("configured-null", "POST", Action.SUCCESS); |
| 336 |
3
|
testInterceptor("configured-null", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 337 |
3
|
testInterceptor("configured-null", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 338 |
|
|
| 339 |
3
|
testInterceptor("configured-dodefault", "GET", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 340 |
3
|
testInterceptor("configured-dodefault", "POST", Action.SUCCESS); |
| 341 |
3
|
testInterceptor("configured-dodefault", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 342 |
3
|
testInterceptor("configured-dodefault", "MONKEY", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 343 |
|
|
| 344 |
3
|
testInterceptor("configured-doedit", "GET", Action.SUCCESS); |
| 345 |
3
|
testInterceptor("configured-doedit", "HEAD", Action.SUCCESS); |
| 346 |
3
|
testInterceptor("configured-doedit", "PUT", Action.SUCCESS); |
| 347 |
3
|
testInterceptor("configured-doedit", "POST", Action.SUCCESS); |
| 348 |
3
|
testInterceptor("configured-doedit", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 349 |
|
|
| 350 |
3
|
testInterceptor("configured-doedit", "CHEESE", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 351 |
|
|
| 352 |
3
|
testInterceptor("configured-anymethod", "GET", Action.SUCCESS); |
| 353 |
3
|
testInterceptor("configured-anymethod", "PROPFIND", Action.SUCCESS); |
| 354 |
3
|
testInterceptor("configured-anymethod", "CHEESE", Action.SUCCESS); |
| 355 |
|
|
| 356 |
3
|
testInterceptor("configured-rfc2616", "GET", Action.SUCCESS); |
| 357 |
3
|
testInterceptor("configured-rfc2616", "PROPFIND", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 358 |
3
|
testInterceptor("configured-rfc2616", "CHEESE", RestrictHttpMethodInterceptor.INVALID_METHOD_RESULT); |
| 359 |
|
} |
| 360 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 361 |
220
|
private void testInterceptor(String actionAlias, String httpMethod, String expectedResult) throws Exception... |
| 362 |
|
{ |
| 363 |
220
|
ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("", actionAlias, makeContext(), false); |
| 364 |
220
|
matchMethod(httpMethod); |
| 365 |
220
|
assertEquals("Testing " + httpMethod + " against " + actionAlias, expectedResult, proxy.execute()); |
| 366 |
|
} |
| 367 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 368 |
2
|
private void testInterceptorWithNoRequest(String actionAlias, String expectedResult) throws Exception... |
| 369 |
|
{ |
| 370 |
2
|
ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("", actionAlias, new HashMap(), false); |
| 371 |
2
|
assertEquals("Testing no request against " + actionAlias, expectedResult, proxy.execute()); |
| 372 |
|
} |
| 373 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 374 |
220
|
private HashMap makeContext()... |
| 375 |
|
{ |
| 376 |
220
|
HashMap<String, Object> context = new HashMap<String, Object>(); |
| 377 |
220
|
context.put(WebWorkStatics.HTTP_REQUEST, mockServletRequest.proxy()); |
| 378 |
220
|
return context; |
| 379 |
|
} |
| 380 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 381 |
220
|
private void matchMethod(String httpMethodName)... |
| 382 |
|
{ |
| 383 |
220
|
mockServletRequest.stubs().method("getMethod").withNoArguments().will(returnValue(httpMethodName)); |
| 384 |
|
} |
| 385 |
|
} |