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

ADM-709:[backend][docs]:Verify buildkite and obtain buildkite data with new API #889

Merged
merged 27 commits into from
Jan 11, 2024

Conversation

Andrea2000728
Copy link

Summary

add two api:

1.Verify the BuildKite token
2.getBuildKiteInfo

Before

Description

Screenshots
If applicable, add screenshots to help explain behavior of your code.

After

Description

Screenshots
If applicable, add screenshots to help explain behavior of your code.

Note

Null

Copy link

codacy-production bot commented Jan 8, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (ca482f0) 5051 5051 100.00%
Head commit (7007521) 10258 (+5207) 10258 (+5207) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#889) 60 60 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Copy link

github-actions bot commented Jan 8, 2024

Hi @Andrea2000728! 👋
Thank you for submitting a pull request! We appreciate your contribution and will review your changes as soon as possible.

Copy link
Collaborator

@guzhongren guzhongren left a comment

Choose a reason for hiding this comment

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

refactor with the comments

@@ -35,6 +36,26 @@ public BuildKiteResponseDTO getBuildKiteInfo(@PathVariable String pipelineType,
return buildKiteService.fetchPipelineInfo(pipelineParam);
}

@PostMapping("/{pipelineType}/verify")
public ResponseEntity<Void> verifyBuildKiteToken(@PathVariable String pipelineType,
Copy link
Collaborator

Choose a reason for hiding this comment

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

pipelineType should be a enum

}

@PostMapping("/{pipelineType}/info")
public ResponseEntity<BuildKiteResponseDTO> fetchBuildKiteInfo(@PathVariable String pipelineType,
Copy link
Collaborator

Choose a reason for hiding this comment

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

pipelineType to a enum

Copy link
Collaborator

Choose a reason for hiding this comment

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

and remove /info in the path

Copy link
Author

Choose a reason for hiding this comment

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

"/{xxxxType}/info" We have designed this API to all follow this form (pipeline board source). also the old api hasn't been removed yet, we can distinguish by this.

Comment on lines 556 to 567
void shouldReturnTrueWhenTokenIsCorrect() {
BuildKiteTokenInfo buildKiteTokenInfo = BuildKiteTokenInfo.builder()
.scopes(List.of("read_builds", "read_organizations", "read_pipelines"))
.build();

when(buildKiteFeignClient.getTokenInfo(any())).thenReturn(buildKiteTokenInfo);
buildKiteService.getBuildKiteVerify("mock_token");

verify(buildKiteFeignClient, times(1)).getTokenInfo(anyString());
}

@Test
Copy link
Collaborator

Choose a reason for hiding this comment

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

given a new line between given when then

Comment on lines 590 to 604
PipelineParam pipelineParam = PipelineParam.builder()
.token("test_token")
.startTime("startTime")
.endTime("endTime")
.build();
ObjectMapper mapper = new ObjectMapper();
List<BuildKitePipelineDTO> pipelineDTOS = mapper.readValue(
new File("src/test/java/heartbeat/controller/pipeline/buildKitePipelineInfoData.json"),
new TypeReference<>() {
});

when(buildKiteFeignClient.getBuildKiteOrganizationsInfo(any()))
.thenReturn(List.of(BuildKiteOrganizationsInfo.builder().name("XXXX").slug("XXXX").build()));
when(buildKiteFeignClient.getPipelineInfo("Bearer test_token", "XXXX", "1", "100", "startTime", "endTime"))
.thenReturn(pipelineDTOS);
Copy link
Collaborator

Choose a reason for hiding this comment

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

those part should be in when, combine it

@@ -12,6 +12,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
Copy link
Collaborator

Choose a reason for hiding this comment

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

refactor this file with given when then

@@ -189,6 +190,7 @@ responses:{
]
}]
}
当 pipelineList 为空时, responses 204
Copy link
Collaborator

Choose a reason for hiding this comment

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

covert it into english

@Andrea2000728
Copy link
Author

refactor with the comments

all done

@BoBoDai BoBoDai self-requested a review January 11, 2024 03:52
@Andrea2000728 Andrea2000728 merged commit 54df641 into main Jan 11, 2024
43 checks passed
@Andrea2000728 Andrea2000728 deleted the ADM-709 branch January 11, 2024 04:10
@Andrea2000728 Andrea2000728 restored the ADM-709 branch January 11, 2024 04:10
neomgb pushed a commit that referenced this pull request Jan 12, 2024
…th new API (#889)

* ADM-709:[backend]feat: add verify token and get info for buildKite controller


Co-authored-by: Andrea <Andrea2000728>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants