Apply formatting
This commit is contained in:
@@ -76,9 +76,12 @@ public class ContactsPage {
|
||||
}
|
||||
|
||||
public DeleteContactLink andHasContact(final String name, final String email) {
|
||||
return this.contacts.stream().filter(byEmail(email).and(byName(name)))
|
||||
.map((e) -> e.findElement(By.cssSelector("td:nth-child(4) > a"))).findFirst()
|
||||
.map((e) -> new DeleteContactLink(this.webDriver, e)).get();
|
||||
return this.contacts.stream()
|
||||
.filter(byEmail(email).and(byName(name)))
|
||||
.map((e) -> e.findElement(By.cssSelector("td:nth-child(4) > a")))
|
||||
.findFirst()
|
||||
.map((e) -> new DeleteContactLink(this.webDriver, e))
|
||||
.get();
|
||||
}
|
||||
|
||||
public ContactsPage andContactHasBeenRemoved(final String name, final String email) {
|
||||
|
||||
@@ -229,7 +229,7 @@ public class DataSourcePopulator implements InitializingBean {
|
||||
|
||||
private void changeOwner(int contactNumber, String newOwnerUsername) {
|
||||
AclImpl acl = (AclImpl) this.mutableAclService
|
||||
.readAclById(new ObjectIdentityImpl(Contact.class, (long) contactNumber));
|
||||
.readAclById(new ObjectIdentityImpl(Contact.class, (long) contactNumber));
|
||||
acl.setOwner(new PrincipalSid(newOwnerUsername));
|
||||
updateAclInTransaction(acl);
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class DataSourcePopulator implements InitializingBean {
|
||||
|
||||
private void grantPermissions(int contactNumber, String recipientUsername, Permission permission) {
|
||||
AclImpl acl = (AclImpl) this.mutableAclService
|
||||
.readAclById(new ObjectIdentityImpl(Contact.class, (long) contactNumber));
|
||||
.readAclById(new ObjectIdentityImpl(Contact.class, (long) contactNumber));
|
||||
acl.insertAce(acl.getEntries().size(), permission, new PrincipalSid(recipientUsername), true);
|
||||
updateAclInTransaction(acl);
|
||||
}
|
||||
|
||||
@@ -101,8 +101,9 @@ public class DataSourcePopulator implements InitializingBean {
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('jane','ROLE_USER');");
|
||||
|
||||
// Now create an ACL entry for the root directory
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken("rod", "ignored",
|
||||
AuthorityUtils.createAuthorityList(("ROLE_IGNORED"))));
|
||||
SecurityContextHolder.getContext()
|
||||
.setAuthentication(new UsernamePasswordAuthenticationToken("rod", "ignored",
|
||||
AuthorityUtils.createAuthorityList(("ROLE_IGNORED"))));
|
||||
|
||||
addPermission(this.documentDao, Directory.ROOT_DIRECTORY, "ROLE_USER", LEVEL_GRANT_WRITE);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SecureDocumentDaoImpl extends DocumentDaoImpl implements SecureDocu
|
||||
|
||||
public String[] getUsers() {
|
||||
return getJdbcTemplate().query(SELECT_FROM_USERS, (rs, rowNumber) -> rs.getString("USERNAME"))
|
||||
.toArray(new String[] {});
|
||||
.toArray(new String[] {});
|
||||
}
|
||||
|
||||
public void create(AbstractElement element) {
|
||||
|
||||
@@ -100,7 +100,7 @@ public class DmsIntegrationTests {
|
||||
|
||||
protected void process(String username, String password, boolean shouldBeFiltered) {
|
||||
SecurityContextHolder.getContext()
|
||||
.setAuthentication(new UsernamePasswordAuthenticationToken(username, password));
|
||||
.setAuthentication(new UsernamePasswordAuthenticationToken(username, password));
|
||||
System.out.println("------ Test for username: " + username + " ------");
|
||||
AbstractElement[] rootElements = this.documentDao.findElements(Directory.ROOT_DIRECTORY);
|
||||
assertThat(rootElements).hasSize(3);
|
||||
@@ -140,7 +140,7 @@ public class DmsIntegrationTests {
|
||||
|
||||
if (shouldBeFiltered) {
|
||||
assertThat(nonHomeConfidentialDir).withFailMessage("Found confidential directory when we should not have")
|
||||
.isNull();
|
||||
.isNull();
|
||||
}
|
||||
else {
|
||||
System.out.println("Inaccessible dir....: " + nonHomeConfidentialDir.getFullName());
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SecureDmsIntegrationTests extends DmsIntegrationTests {
|
||||
// and
|
||||
// File
|
||||
assertThat(this.jdbcTemplate.queryForObject("select count(id) from ACL_OBJECT_IDENTITY", Integer.class))
|
||||
.isEqualTo(100);
|
||||
.isEqualTo(100);
|
||||
assertThat(this.jdbcTemplate.queryForObject("select count(id) from ACL_ENTRY", Integer.class)).isEqualTo(115);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,15 +55,22 @@ public class HelloWorldXmlTests {
|
||||
|
||||
@Test
|
||||
void authenticatedUserIsSentToOriginalPage() {
|
||||
final HomePage homePage = HomePage.to(this.driver, this.port).loginForm().username("user").password("password")
|
||||
.submit();
|
||||
final HomePage homePage = HomePage.to(this.driver, this.port)
|
||||
.loginForm()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.submit();
|
||||
homePage.assertAt().andTheUserNameIsDisplayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
void authenticatedUserLogsOut() {
|
||||
LoginPage loginPage = HomePage.to(this.driver, this.port).loginForm().username("user").password("password")
|
||||
.submit().logout();
|
||||
LoginPage loginPage = HomePage.to(this.driver, this.port)
|
||||
.loginForm()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.submit()
|
||||
.logout();
|
||||
loginPage.assertAt();
|
||||
|
||||
loginPage = HomePage.to(this.driver, this.port);
|
||||
|
||||
@@ -63,9 +63,11 @@ public class Saml2XmlITests {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext)
|
||||
.apply(SecurityMockMvcConfigurers.springSecurity()).build();
|
||||
.apply(SecurityMockMvcConfigurers.springSecurity())
|
||||
.build();
|
||||
this.webClient = MockMvcWebClientBuilder.mockMvcSetup(this.mvc)
|
||||
.withDelegate(new LocalHostWebClient(this.environment)).build();
|
||||
.withDelegate(new LocalHostWebClient(this.environment))
|
||||
.build();
|
||||
this.webClient.getCookieManager().clearCookies();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WebConfiguration implements WebMvcConfigurer, ApplicationContextAwa
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
||||
AuthenticationPrincipalArgumentResolver principalArgumentResolver = new AuthenticationPrincipalArgumentResolver();
|
||||
principalArgumentResolver
|
||||
.setBeanResolver(new BeanFactoryResolver(this.context.getAutowireCapableBeanFactory()));
|
||||
.setBeanResolver(new BeanFactoryResolver(this.context.getAutowireCapableBeanFactory()));
|
||||
resolvers.add(principalArgumentResolver);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user