forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
162 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 59 additions & 14 deletions
73
test-poc/framework/src/main/java/org/keycloak/test/framework/database/DatabaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,76 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public interface DatabaseConfig { | ||
public class DatabaseConfig { | ||
|
||
default String vendor() { | ||
return ""; | ||
private String vendor; | ||
private String containerImage; | ||
private String urlHost; | ||
private String username; | ||
private String password; | ||
|
||
public String getVendor() { | ||
return vendor; | ||
} | ||
|
||
public DatabaseConfig vendor(String vendor) { | ||
this.vendor = vendor; | ||
return this; | ||
} | ||
|
||
public String getContainerImage() { | ||
return containerImage; | ||
} | ||
|
||
public DatabaseConfig containerImage(String containerImage) { | ||
this.containerImage = containerImage; | ||
return this; | ||
} | ||
|
||
public String getUrlHost() { | ||
return urlHost; | ||
} | ||
|
||
default String containerImage() { | ||
return ""; | ||
public DatabaseConfig urlHost(String urlHost) { | ||
this.urlHost = urlHost; | ||
return this; | ||
} | ||
|
||
default String urlHost() { | ||
return ""; | ||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
default String username() { | ||
return ""; | ||
public DatabaseConfig username(String username) { | ||
this.username = username; | ||
return this; | ||
} | ||
|
||
default String password() { | ||
return ""; | ||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
default boolean isExternal() { | ||
return false; | ||
public DatabaseConfig password(String password) { | ||
this.password = password; | ||
return this; | ||
} | ||
|
||
public Map<String, String> toConfig() { | ||
Map<String, String> config = new HashMap<>(); | ||
if (vendor != null) { | ||
config.put("db", vendor); | ||
} | ||
if (urlHost != null) { | ||
config.put("db-url-host", urlHost); | ||
} | ||
if (username != null) { | ||
config.put("db-username", username); | ||
} | ||
if (password != null) { | ||
config.put("db-password", password); | ||
} | ||
return config; | ||
} | ||
|
||
} |
4 changes: 0 additions & 4 deletions
4
...c/framework/src/main/java/org/keycloak/test/framework/database/DefaultDatabaseConfig.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...framework/src/main/java/org/keycloak/test/framework/database/DefaultDatabaseSupplier.java
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
...framework/src/main/java/org/keycloak/test/framework/database/DevFileDatabaseSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
public class DevFileDatabaseSupplier extends AbstractDatabaseSupplier { | ||
|
||
@Override | ||
TestDatabase getTestDatabase() { | ||
DatabaseConfig databaseConfig = new DatabaseConfig().vendor("dev-file"); | ||
return new TestDatabase(databaseConfig); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
.../framework/src/main/java/org/keycloak/test/framework/database/DevMemDatabaseSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
public class DevMemDatabaseSupplier extends AbstractDatabaseSupplier { | ||
|
||
@Override | ||
TestDatabase getTestDatabase() { | ||
DatabaseConfig databaseConfig = new DatabaseConfig().vendor("dev-mem"); | ||
return new TestDatabase(databaseConfig); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...ramework/src/main/java/org/keycloak/test/framework/database/PostgresDatabaseSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
public class PostgresDatabaseSupplier extends AbstractDatabaseSupplier { | ||
|
||
@Override | ||
TestDatabase getTestDatabase() { | ||
DatabaseConfig databaseConfig = new DatabaseConfig() | ||
.vendor("postgres") | ||
.username("keycloak") | ||
.password("keycloak") | ||
.containerImage("the-postgres-container:the-version"); | ||
return new TestDatabase(databaseConfig); | ||
} | ||
|
||
} |
21 changes: 15 additions & 6 deletions
21
test-poc/framework/src/main/java/org/keycloak/test/framework/database/TestDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
import java.util.Map; | ||
|
||
public class TestDatabase { | ||
|
||
private DatabaseConfig databaseConfig; | ||
|
||
public TestDatabase(DatabaseConfig config) { | ||
databaseConfig = config; | ||
public TestDatabase(DatabaseConfig databaseConfig) { | ||
this.databaseConfig = databaseConfig; | ||
} | ||
|
||
public void start() { | ||
|
||
if (databaseConfig.getContainerImage() != null) { | ||
// TODO Start container | ||
} | ||
} | ||
|
||
public void stop() { | ||
|
||
if (databaseConfig.getContainerImage() != null) { | ||
// TODO Stop container | ||
} else if (databaseConfig.getVendor().equals("dev-mem")) { | ||
// TODO Stop in-mem H2 database | ||
} | ||
} | ||
|
||
public DatabaseConfig getDatabaseConfig() { | ||
return databaseConfig; | ||
public Map<String, String> getServerConfig() { | ||
return databaseConfig.toConfig(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
test-poc/framework/src/main/java/org/keycloak/test/framework/server/KeycloakTestServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
.../framework/src/main/java/org/keycloak/test/framework/server/RemoteKeycloakTestServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.