Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ jobs:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
LEEWAY_REMOTE_CACHE_BUCKET: ${{needs.configuration.outputs.leeway_cache_bucket}}
IMAGE_REPO_BASE: ${{needs.configuration.outputs.image_repo_base}}/build

# SCM tokens for integration tests
GITPOD_TEST_TOKEN_BITBUCKET: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET }}"
GITPOD_TEST_TOKEN_BITBUCKET_SERVER: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET_SERVER }}"
GITPOD_TEST_TOKEN_BITBUCKET_SERVER_WRITE: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET_SERVER_WRITE }}"
GITPOD_TEST_TOKEN_BITBUCKET_SERVER_READ: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET_SERVER_READ }}"
GITPOD_TEST_TOKEN_GITHUB: "${{ secrets.GITPOD_TEST_TOKEN_GITHUB }}"
GITPOD_TEST_TOKEN_GITLAB: "${{ secrets.GITPOD_TEST_TOKEN_GITLAB }}"
GITPOD_TEST_TOKEN_AZURE_DEVOPS: "${{ secrets.GITPOD_TEST_TOKEN_AZURE_DEVOPS }}"
run: |
[[ "$PR_NO_CACHE" = "true" ]] && CACHE="none" || CACHE="remote"
[[ "$PR_NO_TEST" = "true" ]] && TEST="--dont-test" || TEST=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ class TestBitbucketServerApi {
};
}

@test.skip async test_currentUsername_ok() {
@test async test_currentUsername_ok() {
const result = await this.api.currentUsername(process.env["GITPOD_TEST_TOKEN_BITBUCKET_SERVER"]!);
expect(result).to.equal("AlexTugarev");
expect(result).to.equal("admin-tester");
}

@test.skip async test_getUserProfile_ok() {
const result = await this.api.getUserProfile(process.env["GITPOD_TEST_TOKEN_BITBUCKET_SERVER"]!, "AlexTugarev");
@test async test_getUserProfile_ok() {
const result = await this.api.getUserProfile(process.env["GITPOD_TEST_TOKEN_BITBUCKET_SERVER"]!, "alex");
expect(result).to.deep.include({
id: 105, // Identity.authId
name: "AlexTugarev", // Identity.authName
slug: "alextugarev", // used in URLs
id: 53, // Identity.authId
name: "alex", // Identity.authName
slug: "alex", // used in URLs
displayName: "Alex Tugarev",
});
}
Expand All @@ -97,7 +97,7 @@ class TestBitbucketServerApi {
const result = await this.api.getRepos(process.env["GITPOD_TEST_TOKEN_BITBUCKET_SERVER"]!, {
permission: "REPO_READ",
});
expect(result.length).to.be.equal(9177);
expect(result.length).to.be.equal(10_000);

// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=0&limit=1000 - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=1002&limit=1000 - OK
Expand Down Expand Up @@ -174,35 +174,6 @@ class TestBitbucketServerApi {
// ✓ test_getRepos_searchString_wildcards_are_not_supported (172ms)
}

@test async test_getRepos_searchString_single_char_is_ignored() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This didn't really make sense to me as a test, because single chars are not ignored with BBS.

const result = await this.api.getRepos(process.env["GITPOD_TEST_TOKEN_BITBUCKET_SERVER"]!, {
permission: "REPO_READ",
searchString: "t",
});
expect(result.length).to.be.equal(9177);

// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=0&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=1000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=2000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=3000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=4000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=5000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=6000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=7000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=8000&name=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=0&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=1000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=2000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=3000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=4000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=5000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=6000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=7000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=8000&projectname=t - OK
// BBS: GET https://bitbucket.gitpod-dev.com/rest/api/1.0/repos?permission=REPO_READ&limit=1000&start=9000&projectname=t - OK
// ✓ test_getRepos_searchString_single_char_is_ignored (7329ms)
}

@test async test_getRepos_searchString_unmatched() {
const result = await this.api.getRepos(process.env["GITPOD_TEST_TOKEN_BITBUCKET_SERVER"]!, {
permission: "REPO_READ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class BitbucketServerApi {
}

/**
* If `searchString` is provided, this tries to match projects and repositorys by name,
* If `searchString` is provided, this tries to match projects and repositories by name,
* otherwise it returns the first n repositories.
*
* Based on:
Expand All @@ -333,7 +333,7 @@ export class BitbucketServerApi {
query: {
permission?: "REPO_READ" | "REPO_WRITE" | "REPO_ADMIN";
/**
* If projects and repositorys are matched by by name, otherwise it returns the first n repositories.
* If projects and repositories are matched by name, otherwise it returns the first n repositories.
*/
searchString?: string;
/**
Expand Down Expand Up @@ -402,6 +402,7 @@ export class BitbucketServerApi {
start = pageResult.nextPageStart;
}
}

return result;
};

Expand All @@ -425,7 +426,7 @@ export class BitbucketServerApi {

return Array.from(results.values());
} else {
return await fetchRepos(baseParams);
return fetchRepos(baseParams);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AuthProviderParams } from "../auth/auth-provider";
import { HostContextProvider } from "../auth/host-context-provider";
import { DevData } from "../dev/dev-data";
import { TokenProvider } from "../user/token-provider";
import { BitbucketApiFactory } from "./bitbucket-api-factory";
import { BasicAuthBitbucketApiFactory, BitbucketApiFactory } from "./bitbucket-api-factory";
import { BitbucketRepositoryProvider } from "./bitbucket-repository-provider";
import { BitbucketTokenHelper } from "./bitbucket-token-handler";
const expect = chai.expect;
Expand Down Expand Up @@ -50,7 +50,7 @@ class TestBitbucketRepositoryProvider {
bind(TokenProvider).toConstantValue(<TokenProvider>{
getTokenForHost: async () => DevData.createBitbucketTestToken(),
});
bind(BitbucketApiFactory).toSelf().inSingletonScope();
bind(BitbucketApiFactory).to(BasicAuthBitbucketApiFactory).inSingletonScope();
bind(HostContextProvider).toConstantValue({
get: (hostname: string) => {
authProvider: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class BitbucketRepositoryProvider implements RepositoryProvider {
workspace: workspaceSlug,
// name includes searchString
q: `name ~ "${searchString}"`,
// sort by most recently updatd first
// sort by most recently updated first
sort: "-updated_on",
// limit to the first 10 results per workspace
pagelen: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,8 @@ export class GithubRepositoryProvider implements RepositoryProvider {
}
}`;

let repos: RepositoryInfo[] = [];

const result = await this.githubQueryApi.runQuery<SearchReposQueryResponse>(user, repoSearchQuery);
repos = result.data.search.edges.map((edge) => {
const repos: RepositoryInfo[] = result.data.search.edges.map((edge) => {
return {
name: edge.node.name,
url: edge.node.url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class TestGitlabContextParser {
};
static readonly BLO_BLA_ERROR_DATA = {
host: "gitlab.com",
lastUpdate: undefined,
lastUpdate: "",
errorMessage: 'GitLab responded: "404 Project Not Found"',
owner: "blo",
repoName: "bla",
userIsOwner: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class GitlabRepositoryProvider implements RepositoryProvider {
const result = await this.gitlab.run<GitLab.Project[]>(user, async (gitlab) => {
return gitlab.Projects.all({
membership: true,
// note: GitLab returns an empty project set when there isn't an exact match and the search length is <3
search: searchString,
perPage: limit,
simple: true,
Expand Down
Loading