Skip to content

Commit

Permalink
feat: add filter for azure repos /pull-request endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiverciuc committed Nov 13, 2024
1 parent 927dbf4 commit 53872c7
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client-templates/azure-repos/accept.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,22 @@
"scheme": "basic",
"token": "${BROKER_CLIENT_VALIDATION_BASIC_AUTH}"
}
},
{
"//": "get pull-request info",
"method": "GET",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"origin": "https://${AZURE_REPOS_HOST}/${AZURE_REPOS_ORG}",
"valid": [
{
"queryParam": "api-version",
"values": ["7.1", ""]
}
],
"auth": {
"scheme": "basic",
"token": "${BROKER_CLIENT_VALIDATION_BASIC_AUTH}"
}
}
]
}
16 changes: 16 additions & 0 deletions defaultFilters/azure-repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,22 @@
"scheme": "basic",
"token": "${BROKER_CLIENT_VALIDATION_BASIC_AUTH}"
}
},
{
"//": "get pull-request info",
"method": "GET",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"origin": "https://${AZURE_REPOS_HOST}/${AZURE_REPOS_ORG}",
"valid": [
{
"queryParam": "api-version",
"values": ["7.1", ""]
}
],
"auth": {
"scheme": "basic",
"token": "${BROKER_CLIENT_VALIDATION_BASIC_AUTH}"
}
}
]
}
228 changes: 228 additions & 0 deletions test/unit/__snapshots__/runtime-rules-hotloading.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
Object {
"//": "get file content. restrict by file types",
"method": "GET",
Expand Down Expand Up @@ -8026,6 +8045,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
Object {
"//": "get core api's location for sanity check",
"auth": Object {
Expand Down Expand Up @@ -16591,6 +16629,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -24413,6 +24470,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
Object {
"//": "allow info refs (for git clone)",
"auth": Object {
Expand Down Expand Up @@ -32374,6 +32450,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
Object {
"//": "allow info refs (for git clone)",
"auth": Object {
Expand Down Expand Up @@ -40409,6 +40504,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
Object {
"//": "allow info refs (for git clone)",
"auth": Object {
Expand Down Expand Up @@ -48402,6 +48516,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -48822,6 +48955,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -64576,6 +64728,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -72386,6 +72557,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -80196,6 +80386,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -88006,6 +88215,25 @@ Object {
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullRequests/:pullRef/iterations",
},
Object {
"//": "get pull-request info",
"auth": Object {
"scheme": "basic",
"token": "\${BROKER_CLIENT_VALIDATION_BASIC_AUTH}",
},
"method": "GET",
"origin": "https://\${AZURE_REPOS_HOST}/\${AZURE_REPOS_ORG}",
"path": "/:owner/_apis/git/repositories/:repo/pullrequests/:pullRef",
"valid": Array [
Object {
"queryParam": "api-version",
"values": Array [
"7.1",
"",
],
},
],
},
],
"public": Array [
Object {
Expand Down
27 changes: 27 additions & 0 deletions test/unit/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,33 @@ describe('filters', () => {
const filterResponseUrl = filterResponse ? filterResponse.url : '';
expect(filterResponseUrl).toMatch(url);
});

it('should allow fetching pr info', () => {
const url = '/test-owner/_apis/git/repositories/test-repo/pullRequests/1';

const filterResponse = filter({
url,
method: 'GET',
});

expect(filterResponse).not.toEqual(false);
const filterResponseUrl = filterResponse ? filterResponse.url : '';
expect(filterResponseUrl).toMatch(url);
});

it('should allow fetching pr info with api-version', () => {
const url =
'/test-owner/_apis/git/repositories/test-repo/pullrequests/1?api-version=7.1';

const filterResponse = filter({
url,
method: 'GET',
});

expect(filterResponse).not.toEqual(false);
const filterResponseUrl = filterResponse ? filterResponse.url : '';
expect(filterResponseUrl).toMatch(url);
});
});

describe('for gitlab', () => {
Expand Down

0 comments on commit 53872c7

Please sign in to comment.