33import com .mongodb .client .MongoClient ;
44import com .mongodb .client .MongoClients ;
55import io .papermc .bibliothek .BibliothekApplication ;
6+ import org .evomaster .client .java .controller .AuthUtils ;
67import org .evomaster .client .java .controller .EmbeddedSutController ;
78import org .evomaster .client .java .controller .InstrumentedSutStarter ;
89import org .evomaster .client .java .controller .api .dto .auth .AuthenticationDto ;
1314import org .springframework .boot .SpringApplication ;
1415import org .springframework .context .ConfigurableApplicationContext ;
1516import org .testcontainers .containers .GenericContainer ;
17+ import org .testcontainers .containers .startupcheck .OneShotStartupCheckStrategy ;
1618
1719
20+ import java .time .Duration ;
21+ import java .util .Arrays ;
1822import java .util .List ;
1923import java .util .Map ;
2024import java .util .Collections ;
@@ -52,6 +56,7 @@ public static void main(String[] args) {
5256 private static final GenericContainer mongodbContainer = new GenericContainer ("mongo:" + MONGODB_VERSION )
5357 .withTmpFs (Collections .singletonMap ("/data/db" , "rw" ))
5458 .withExposedPorts (MONGODB_PORT );
59+ // .withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofSeconds(90)));
5560
5661 private String mongoDbUrl ;
5762
@@ -70,9 +75,11 @@ public EmbeddedEvoMasterController(int port) {
7075 public String startSut () {
7176
7277 mongodbContainer .start ();
78+
7379 mongoDbUrl = "mongodb://" + mongodbContainer .getContainerIpAddress () + ":" + mongodbContainer .getMappedPort (MONGODB_PORT ) + "/" + MONGODB_DATABASE_NAME ;
7480 mongoClient = MongoClients .create (mongoDbUrl );
7581
82+ //mongodbContainer.setStartupCheckStrategy( new OneShotStartupCheckStrategy() );
7683
7784
7885 ctx = SpringApplication .run (BibliothekApplication .class ,
@@ -125,7 +132,28 @@ public List<DbSpecification> getDbSpecifications() {
125132 @ Override
126133 public List <AuthenticationDto > getInfoForAuthentication () {
127134 //TODO might need to setup JWT headers here
128- return null ;
135+ System .out .println ("HERE" );
136+
137+ // @Onur Setting JWT Authentication here.
138+ return Arrays .asList (
139+ AuthUtils .getForJWT (
140+ "User1" ,
141+ "/api/auth_token/auth1" ,
142+ """
143+ {"userId": "User1", "password":"User1_Password123"}
144+ """ .trim ().stripIndent (),
145+ "/token/authToken1" ),
146+ AuthUtils .getForJWT (
147+ "User2" ,
148+ "/api/auth_token/auth2" ,
149+ """
150+ {"userId": "User2", "password":"User2_Password456"}
151+ """ .trim ().stripIndent (),
152+ "/token/authToken2" )
153+ );
154+
155+
156+ //return null;
129157 }
130158
131159
0 commit comments