Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

identity webapp #9

Merged
merged 2 commits into from
Dec 18, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<description>RESThub identity management in order to allow you to build quickly identity functionnalities on your applications</description>

<properties>
<resthub.spring.stack.version>2.0-rc3</resthub.spring.stack.version>
<resthub.spring.stack.version>2.0.0</resthub.spring.stack.version>
<spring.security.version>3.1.3.RELEASE</spring.security.version>
<elasticsearch.spring.integration.version>0.0.2</elasticsearch.spring.integration.version>
<elasticsearch.version>0.20.0.RC1</elasticsearch.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;

import com.fasterxml.jackson.annotation.JsonProperty;


/**
Expand Down Expand Up @@ -121,6 +122,7 @@ public List<Role> getRoles() {
* <b>Only used by Hibernate</b> Please use getRoles() instead.
*/
@SuppressWarnings("unused")
@JsonProperty
private void setRoles(List<Role> roles) {
this.roles = roles;
}
Expand All @@ -143,6 +145,7 @@ public List<Group> getGroups() {
* <b>Only used by Hibernate</b> Please use getGroups() instead.
*/
@SuppressWarnings("unused")
@JsonProperty
private void setGroups(List<Group> groups) {
this.groups = groups;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Role(String roleName) {
this.setName(roleName);
}


@Id
@GeneratedValue
public Long getId() {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions resthub-identity-contract/src/test/resources/logback-test.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public Group create(@RequestBody Group group) {
throw new ExpectationFailedException(e.getMessage());
}
}


/** Override this methods in order to secure it **/

Expand All @@ -89,6 +90,7 @@ public Group update(@PathVariable("id") Long id, @RequestBody Group group) {
}
}


/** Override this methods in order to secure it **/
@Secured({ "IM_GROUP_ADMIN", "IM_GROUP_READ" }) @Override
public Iterable<Group> findAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,32 @@ public User update(@PathVariable("id") Long id, @RequestBody User user) {
throw new ExpectationFailedException(e.getMessage());
}
}



@Secured({ "IM_USER_ADMIN" }) @RequestMapping(method = RequestMethod.DELETE, value = "name/{name}/roles") @ResponseStatus(HttpStatus.NO_CONTENT)
public void removeAllRoleFromUser(@PathVariable("login") String login) {
List<Role> roles = this.service.getAllUserRoles(login);
if (roles == null) {
throw new NotFoundException();
}
for (Role r : roles){
this.service.removeRoleFromUser(login, r.getName());
}

}

@Secured({ "IM_USER_ADMIN" }) @RequestMapping(method = RequestMethod.DELETE, value = "name/{name}/groups") @ResponseStatus(HttpStatus.NO_CONTENT)
public void removeAllGroupFromUser(@PathVariable("login") String login) {
List<Group> groups = this.service.getAllUserGroups(login);
if (groups == null) {
throw new NotFoundException();
}
for (Group grp : groups){
this.service.removeGroupFromUser(login, grp.getName());
}

}

/** Override this methods in order to secure it **/
@Secured({ "IM_USER_ADMIN", "IM_USER_READ" }) @Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
<bean id="passwordEncoder"
class="org.springframework.security.authentication.encoding.ShaPasswordEncoder" />

<!-- Node for Embedded ES -->
<bean id="esNode"
class="fr.pilato.spring.elasticsearch.ElasticsearchNodeFactoryBean">
</bean>

<!-- Client for Embedded ES -->
<bean id="esClient" class="fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import org.fest.assertions.api.Assertions;
import org.resthub.identity.model.Group;
import org.resthub.identity.model.Role;
import org.resthub.identity.model.User;
import org.resthub.test.AbstractWebTest;
import org.resthub.web.JsonHelper;
Expand Down Expand Up @@ -56,7 +57,6 @@ protected Group udpateTestResource(Group r) {
return r;
}

// TODO : this test doesn't work
@Test
public void testShouldGetUsersFromGroup() {

Expand Down Expand Up @@ -91,4 +91,31 @@ public void testShouldGetUsersFromGroup() {
Assertions.assertThat(usersFromGroup.contains(u.getLogin())).as("The list of users should contain our just added user").isTrue();

}

@Test
public void deleteGroupWithRole() {

/* Given a new group */
String groupName = "testGroup";
Group g = new Group();
g.setName(groupName);

Response response = this.request("api/group").jsonPost(g);
g = JsonHelper.deserialize(response.getBody(), Group.class);

/* Given a new user */
String roleName = "roleTest";

Role r = new Role(roleName);
response = this.request("api/role").jsonPost(r);
r = JsonHelper.deserialize(response.getBody(), Role.class);

/* Given a link between this user and the group */
this.request("api/group/name/" + groupName + "/roles/" + r.getName()).put("");

/* When I get the users of the group */
this.request("api/group/" + g.getId()).delete();


}
}
7 changes: 0 additions & 7 deletions resthub-identity-core/src/test/resources/es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ discovery.zen.ping.multicast.enabled=false
node.local=true



# Using less filesystem as possible
index.store.type=memory
index.store.fs.memory.enabled=true
index.gateway.type=none
gateway.type=none

# If ES needs to write something, it's here
path.data=D:/es/data

Expand Down
71 changes: 0 additions & 71 deletions resthub-identity-core/test-output/Default suite/Default test.html

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions resthub-identity-core/test-output/Default suite/testng-failed.xml

This file was deleted.

Binary file removed resthub-identity-core/test-output/bullet_point.png
Binary file not shown.
Binary file removed resthub-identity-core/test-output/collapseall.gif
Binary file not shown.
40 changes: 0 additions & 40 deletions resthub-identity-core/test-output/emailable-report.html

This file was deleted.

Binary file removed resthub-identity-core/test-output/failed.png
Binary file not shown.
Loading