Revision cb9e95fa
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/HttpInvokerServicesTest.java | ||
---|---|---|
12 | 12 |
import org.junit.Assert; |
13 | 13 |
import org.junit.Ignore; |
14 | 14 |
import org.junit.Test; |
15 |
import org.springframework.remoting.RemoteAccessException; |
|
16 |
import org.springframework.security.core.context.SecurityContext; |
|
17 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
15 | 18 |
|
19 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
16 | 20 |
import eu.etaxonomy.cdm.api.service.ITestService; |
17 | 21 |
import eu.etaxonomy.cdm.config.CdmSourceException; |
18 | 22 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
... | ... | |
40 | 44 |
} |
41 | 45 |
|
42 | 46 |
getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null); |
47 |
|
|
48 |
} |
|
49 |
|
|
50 |
@Test |
|
51 |
public void whenCallingMethodsOnRemoteServicesThenFailIfNotAuthenticated() { |
|
52 |
|
|
53 |
SecurityContext context = SecurityContextHolder.getContext(); |
|
54 |
|
|
55 |
CdmApplicationState.setCurrentSecurityContext(null); |
|
56 |
try { |
|
57 |
getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null); |
|
58 |
Assert.fail("service call should fail as it is not authenticated"); |
|
59 |
}catch (RemoteAccessException rae) { |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
CdmApplicationState.setCurrentSecurityContext(context); |
|
64 |
|
|
43 | 65 |
} |
44 | 66 |
|
45 | 67 |
// should be kept at ignore and only used for manual testing |
Also available in: Unified diff
Add test for unathenticated user