Skip to content

Commit

Permalink
Jetty fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
vharseko committed Mar 22, 2024
1 parent a763cad commit 58f5531
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion OpenICF-groovy-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>8.1.15.v20140411</version>
<version>9.4.51.v20230217</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import java.io.IOException;
import java.util.Arrays;

import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.MappedLoginService;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.security.*;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.UserIdentity;
Expand Down Expand Up @@ -82,21 +79,12 @@ private SecurityHandler getSecurityHandler() throws IOException {
sh.setAuthenticator(new BasicAuthenticator());
sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));

MappedLoginService loginService = new MappedLoginService() {

@Override
protected UserIdentity loadUser(String username) {
return null;
}

@Override
protected void loadUsers() throws IOException {
Credential credential = Credential.getCredential("Passw0rd");
String[] roles = new String[]{"user"};
putUser("admin", credential, roles);

}
};
HashLoginService loginService = new HashLoginService();
UserStore us=new UserStore();
Credential credential = Credential.getCredential("Passw0rd");
String[] roles = new String[]{"user"};
us.addUser("admin", credential, roles);
loginService.setUserStore(us);
loginService.setName("user");
sh.setLoginService(loginService);
sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));
Expand All @@ -111,7 +99,7 @@ public void startServer() throws Exception {

server = new Server(Integer.parseInt(httpPort));
for (org.eclipse.jetty.server.Connector c : server.getConnectors()) {
c.setHost("127.0.0.1");
//c.setHost("127.0.0.1");
}

// Initializing the security handler
Expand Down
18 changes: 8 additions & 10 deletions OpenICF-java-framework/connector-server-jetty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@

<properties>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<jetty.version>9.4.51.v20230217</jetty.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down Expand Up @@ -125,14 +123,14 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reuseForks>false</reuseForks>
<shutdown>kill</shutdown>
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reuseForks>false</reuseForks>
<shutdown>kill</shutdown>
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 58f5531

Please sign in to comment.