-
Notifications
You must be signed in to change notification settings - Fork 352
[ci-visibility] Use correct repository URL for git metadata upload #3253
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
Merged
juan-fernandez
merged 1 commit into
master
from
juan-fernandez/use-correct-repository-url
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -59,6 +59,23 @@ describe('CI Visibility Exporter', () => { | |
| ciVisibilityExporter._resolveCanUseCiVisProtocol(true) | ||
| ciVisibilityExporter.sendGitMetadata() | ||
| }) | ||
| it('should use the input repository URL', (done) => { | ||
| nock(`http://localhost:${port}`) | ||
| .post('/api/v2/git/repository/search_commits') | ||
| .reply(200, function () { | ||
| const { meta: { repository_url: repositoryUrl } } = JSON.parse(this.req.requestBodyBuffers.toString()) | ||
| expect(repositoryUrl).to.equal('https://[email protected]') | ||
| done() | ||
| }) | ||
| .post('/api/v2/git/repository/packfile') | ||
| .reply(202, '') | ||
|
|
||
| const url = new URL(`http://localhost:${port}`) | ||
| const ciVisibilityExporter = new CiVisibilityExporter({ url, isGitUploadEnabled: true }) | ||
|
|
||
| ciVisibilityExporter._resolveCanUseCiVisProtocol(true) | ||
| ciVisibilityExporter.sendGitMetadata('https://[email protected]') | ||
| }) | ||
| }) | ||
|
|
||
| describe('getItrConfiguration', () => { | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ describe('git_metadata', () => { | |
| .reply(204) | ||
|
|
||
| isShallowRepositoryStub.returns(true) | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(unshallowRepositoryStub).to.have.been.called | ||
| expect(err).to.be.null | ||
| expect(scope.isDone()).to.be.true | ||
|
|
@@ -88,7 +88,7 @@ describe('git_metadata', () => { | |
| .post('/api/v2/git/repository/packfile') | ||
| .reply(204) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err).to.be.null | ||
| expect(scope.isDone()).to.be.true | ||
| done() | ||
|
|
@@ -104,7 +104,7 @@ describe('git_metadata', () => { | |
|
|
||
| getCommitsToUploadStub.returns([]) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err).to.be.null | ||
| // to check that it is not called | ||
| expect(scope.isDone()).to.be.false | ||
|
|
@@ -120,7 +120,7 @@ describe('git_metadata', () => { | |
| .post('/api/v2/git/repository/packfile') | ||
| .reply(204) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| // eslint-disable-next-line | ||
| expect(err.message).to.contain('Error fetching commits to exclude: Error from https://api.test.com/api/v2/git/repository/search_commits: 404 Not Found. Response from the endpoint: "Not found SHA"') | ||
| // to check that it is not called | ||
|
|
@@ -137,7 +137,7 @@ describe('git_metadata', () => { | |
| .post('/api/v2/git/repository/packfile') | ||
| .reply(204) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err.message).to.contain("Can't parse commits to exclude response: Invalid commit type response") | ||
| // to check that it is not called | ||
| expect(scope.isDone()).to.be.false | ||
|
|
@@ -153,7 +153,7 @@ describe('git_metadata', () => { | |
| .post('/api/v2/git/repository/packfile') | ||
| .reply(204) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err.message).to.contain("Can't parse commits to exclude response: Invalid commit format") | ||
| // to check that it is not called | ||
| expect(scope.isDone()).to.be.false | ||
|
|
@@ -169,7 +169,7 @@ describe('git_metadata', () => { | |
| .post('/api/v2/git/repository/packfile') | ||
| .reply(502) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err.message).to.contain('Could not upload packfiles: status code 502') | ||
| expect(scope.isDone()).to.be.true | ||
| done() | ||
|
|
@@ -196,7 +196,7 @@ describe('git_metadata', () => { | |
| secondTemporaryPackFile | ||
| ]) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err).to.be.null | ||
| expect(scope.isDone()).to.be.true | ||
| done() | ||
|
|
@@ -215,7 +215,7 @@ describe('git_metadata', () => { | |
| 'not there either' | ||
| ]) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err.message).to.contain('Could not read "not-there"') | ||
| expect(scope.isDone()).to.be.false | ||
| done() | ||
|
|
@@ -231,7 +231,7 @@ describe('git_metadata', () => { | |
|
|
||
| generatePackFilesForCommitsStub.returns([]) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err.message).to.contain('Failed to generate packfiles') | ||
| expect(scope.isDone()).to.be.false | ||
| done() | ||
|
|
@@ -247,7 +247,7 @@ describe('git_metadata', () => { | |
|
|
||
| getRepositoryUrlStub.returns('') | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err.message).to.contain('Repository URL is empty') | ||
| expect(scope.isDone()).to.be.false | ||
| done() | ||
|
|
@@ -265,7 +265,7 @@ describe('git_metadata', () => { | |
| .post('/api/v2/git/repository/packfile') | ||
| .reply(204) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), false, '', (err) => { | ||
| expect(err).to.be.null | ||
| expect(scope.isDone()).to.be.true | ||
| done() | ||
|
|
@@ -282,9 +282,35 @@ describe('git_metadata', () => { | |
| done() | ||
| }) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), true, (err) => { | ||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), true, '', (err) => { | ||
| expect(err).to.be.null | ||
| expect(scope.isDone()).to.be.true | ||
| }) | ||
| }) | ||
|
|
||
| it('should use the input repository url and not call getRepositoryUrl', (done) => { | ||
| let resolvePromise | ||
| const requestPromise = new Promise(resolve => { | ||
| resolvePromise = resolve | ||
| }) | ||
| const scope = nock('https://api.test.com') | ||
| .post('/evp_proxy/v2/api/v2/git/repository/search_commits') | ||
| .reply(200, function () { | ||
| const { meta: { repository_url: repositoryUrl } } = JSON.parse(this.req.requestBodyBuffers.toString()) | ||
| resolvePromise(repositoryUrl) | ||
| return JSON.stringify({ data: [] }) | ||
| }) | ||
| .post('/evp_proxy/v2/api/v2/git/repository/packfile') | ||
| .reply(204) | ||
|
|
||
| gitMetadata.sendGitMetadata(new URL('https://api.test.com'), true, 'https://[email protected]', (err) => { | ||
| expect(err).to.be.null | ||
| expect(scope.isDone()).to.be.true | ||
| requestPromise.then((repositoryUrl) => { | ||
| expect(getRepositoryUrlStub).not.to.have.been.called | ||
| expect(repositoryUrl).to.equal('https://[email protected]') | ||
| done() | ||
| }) | ||
| }) | ||
| }) | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.