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

Remove use of machine account in integration tests #2077

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testApiKeys() {

List<String> roles = apiClient.userService.getRoles();
assertFalse(roles.isEmpty());
assertTrue(roles.contains(TEST_TEAM.replace("team", Roles.TESTER)));
assertTrue(roles.contains("dev-" + Roles.TESTER));

UserService.ApiKeyResponse apiKey = horreumClient.userService.apiKeys().get(0);
assertFalse(apiKey.isRevoked);
Expand Down Expand Up @@ -376,8 +376,6 @@ protected static String resourceToString(String resourcePath) {

private static Test dummyTest;

private static final String TEST_USERNAME = "it-test-user", TEST_PASSWORD = "super-secret", TEST_TEAM = "it-team";

@Override
public void beforeEach(QuarkusTestMethodContext context) {
if (horreumClient == null) {
Expand All @@ -390,7 +388,7 @@ public void beforeEach(QuarkusTestMethodContext context) {
Assertions.assertNull(dummyTest);
Test test = new Test();
test.name = "test";
test.owner = TEST_TEAM;
test.owner = "dev-team";
test.description = "This is a dummy test";
dummyTest = horreumClient.testService.add(test);
Assertions.assertNotNull(dummyTest);
Expand All @@ -416,8 +414,8 @@ private void instantiateClient() {
if (horreumClient == null) {
horreumClient = new HorreumClient.Builder()
.horreumUrl("http://localhost:".concat(System.getProperty("quarkus.http.test-port")))
.horreumUser(TEST_USERNAME)
.horreumPassword(TEST_PASSWORD)
.horreumUser("horreum.bootstrap")
.horreumPassword(ItResource.HORREUM_BOOTSTRAP_PASSWORD)
.build();

Assertions.assertNotNull(horreumClient);
Expand All @@ -426,23 +424,6 @@ private void instantiateClient() {

@Override
public void beforeClass(Class<?> testClass) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this method defined even if it is empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. because HorreumClientIT implements QuarkusTestBeforeClassCallback and I didn't want to change the class declaration.

HorreumClient adminClient = new HorreumClient.Builder()
.horreumUrl("http://localhost:".concat(System.getProperty("quarkus.http.test-port", "8081")))
.horreumUser("horreum.bootstrap")
.horreumPassword(ItResource.HORREUM_BOOTSTRAP_PASSWORD)
.build();

adminClient.userService.addTeam(TEST_TEAM);

// create machine account to be used throughout the test
UserService.NewUser testUser = new UserService.NewUser();
testUser.user = new UserService.UserData("", TEST_USERNAME, "Test", "User", "test@example.com");
testUser.team = TEST_TEAM;
testUser.password = TEST_PASSWORD;
testUser.roles = List.of(Roles.MACHINE, Roles.TESTER, Roles.UPLOADER);
adminClient.userService.createUser(testUser);

adminClient.close();
}

@Override
Expand Down
Loading