Skip to content

Commit aaffe9d

Browse files
author
eugenp
committed
work on scenarios of interaction with the API
1 parent ab86d9f commit aaffe9d

4 files changed

Lines changed: 34 additions & 5 deletions

File tree

‎sec/eclipse/INTEGRATION-SINGLE.launch‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
33
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4-
<listEntry value="/rest-sec/src/test/java/org/rest/sec/persistence/service/PrivilegeServicePersistenceIntegrationTest.java"/>
4+
<listEntry value="/rest-sec/src/test/java/org/rest/sec/client/template/test/scenario/SecurityScenariosOverRestLiveTest.java"/>
55
</listAttribute>
66
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
77
<listEntry value="1"/>
@@ -14,7 +14,7 @@
1414
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
1515
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
1616
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
17-
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.rest.sec.persistence.service.PrivilegeServicePersistenceIntegrationTest"/>
17+
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.rest.sec.client.template.test.scenario.SecurityScenariosOverRestLiveTest"/>
1818
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="rest-sec"/>
1919
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
2020
</launchConfiguration>

‎sec/src/test/java/org/rest/sec/client/template/test/scenario/SecurityScenariosOverRestLiveTest.java‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package org.rest.sec.client.template.test.scenario;
22

3+
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
4+
35
import org.junit.Ignore;
6+
import org.junit.Test;
47
import org.junit.runner.RunWith;
8+
import org.rest.sec.client.template.RoleClientRestTemplate;
59
import org.rest.sec.client.template.UserClientRestTemplate;
10+
import org.rest.sec.model.RoleEntityOpsImpl;
611
import org.rest.sec.model.UserEntityOpsImpl;
712
import org.rest.sec.spring.ClientTestConfig;
813
import org.rest.sec.spring.ContextConfig;
@@ -18,13 +23,30 @@ public class SecurityScenariosOverRestLiveTest {
1823

1924
@Autowired
2025
private UserClientRestTemplate userApi;
26+
@Autowired
27+
private RoleClientRestTemplate roleApi;
28+
2129
@Autowired
2230
private UserEntityOpsImpl userEntityOps;
31+
@Autowired
32+
private RoleEntityOpsImpl roleEntityOps;
2333

2434
public SecurityScenariosOverRestLiveTest() {
2535
super();
2636
}
2737

2838
// tests
2939

40+
@Test
41+
public final void givenAsAdmin_whenAssigningRoleToUser_thenNoException() {
42+
// Given
43+
final String nameOfUser = randomAlphabetic(6);
44+
userApi.create(userEntityOps.createNewEntity(nameOfUser));
45+
final String nameOfRole = randomAlphabetic(6);
46+
roleApi.create(roleEntityOps.createNewEntity(nameOfRole));
47+
48+
// When
49+
50+
}
51+
3052
}

‎sec/src/test/java/org/rest/sec/model/RoleEntityOpsImpl.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
44

55
import org.rest.common.client.IEntityOperations;
6-
import org.rest.sec.model.Privilege;
7-
import org.rest.sec.model.Role;
86
import org.springframework.stereotype.Component;
97

108
import com.google.common.collect.Sets;
@@ -18,6 +16,12 @@ public RoleEntityOpsImpl() {
1816

1917
// API
2018

19+
public final Role createNewEntity(final String name) {
20+
return new Role(name, Sets.<Privilege> newHashSet());
21+
}
22+
23+
// template
24+
2125
@Override
2226
public final Role createNewEntity() {
2327
return new Role(randomAlphabetic(8), Sets.<Privilege> newHashSet());

‎sec/src/test/java/org/rest/sec/model/UserEntityOpsImpl.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
44

55
import org.rest.common.client.IEntityOperations;
6-
import org.rest.sec.model.Role;
76
import org.rest.sec.model.dto.User;
87
import org.springframework.stereotype.Component;
98

@@ -18,6 +17,10 @@ public UserEntityOpsImpl() {
1817

1918
// API
2019

20+
public final User createNewEntity(final String name) {
21+
return new User(name, randomAlphabetic(8), Sets.<Role> newHashSet());
22+
}
23+
2124
// template method
2225

2326
@Override

0 commit comments

Comments
 (0)