-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,559 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains 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
13 changes: 13 additions & 0 deletions
13
Tasks/Common/artifacts-common/Strings/resources.resjson/en-US/resources.resjson
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"loc.messages.CredProvider_AlreadyExistsNotUpdating": "Not updating an existing credential provider installation at '%s'. If there are package related authentication failures in later steps, consider setting the input 'updateCredentialProvider' to true to force update.", | ||
"loc.messages.CredProvider_Error_FailedCopy": "Failed to copy from '%s' to '%s' while installing the credential provider. Ensure that the destination directory is not in use and that the agent account has permission to write to it.", | ||
"loc.messages.CredProvider_Error_FailedRemoveDir": "Failed to remove the directory '%s' while installing the credential provider. Ensure that this directory is not in use and that the agent account has permission to delete this directory.", | ||
"loc.messages.CredProvider_Error_InvalidServiceConnection": "The service connection for '%s' is not valid.", | ||
"loc.messages.CredProvider_Error_InvalidServiceConnection_ApiKey": "The service connection for '%s' is not valid. ApiKey service connections are not supported in this task. Instead, use -ApiKey (NuGet) or --api-key (dotnet) when invoking the tool itself. See the task documentation for more details.", | ||
"loc.messages.CredProvider_InstallingNetCoreTo": "Installing the Azure Artifacts Credential Provider (.NET Core) to '%s'. This credential provider is compatible with dotnet SDK 2.1.400 or later.", | ||
"loc.messages.CredProvider_InstallingNetFxTo": "Installing the Azure Artifacts Credential Provider (.NET Framework) to '%s'. This credential provider is compatible with nuget.exe 4.8.0.5385 or later, and MSBuild 15.8.166.59604 or later.", | ||
"loc.messages.CredProvider_SettingUpForOrgFeeds": "Setting up the credential provider to use the identity '%s' for feeds in your organization/collection starting with:", | ||
"loc.messages.CredProvider_SettingUpForServiceConnections": "Setting up the credential provider for these service connections:", | ||
"loc.messages.ServiceConnections_Error_FailedToParseServiceEndpoint_MissingParameter": "Failed to parse the service endpoint '%s' because it was missing the parameter '%s'", | ||
"loc.messages.ServiceConnections_Error_FailedToParseServiceEndpoint_BadScheme": "Failed to parse the service endpoint '%s' because the auth scheme '%s' was invalid" | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { packagingAccessMappingUtilsTests } from "./packagingAccessMappingUtilsTests"; | ||
import { credentialProviderUtilsTests } from "./credentialProviderUtilsTests"; | ||
import { serviceConnectionUtilsTests } from "./serviceConnectionUtilsTests"; | ||
|
||
describe("artifacts-common suite", function() { | ||
describe("packagingAccessMappingUtils", packagingAccessMappingUtilsTests); | ||
describe("credentialProviderUtils", credentialProviderUtilsTests); | ||
describe("serviceConnectionUtils", serviceConnectionUtilsTests); | ||
}); |
110 changes: 110 additions & 0 deletions
110
Tasks/Common/artifacts-common/Tests/credentialProviderUtilsTests.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import * as assert from "assert"; | ||
import { buildExternalFeedEndpointsJson } from "../credentialProviderUtils"; | ||
import { ServiceConnectionAuthType, TokenServiceConnection, ApiKeyServiceConnection, UsernamePasswordServiceConnection } from "../serviceConnectionUtils"; | ||
|
||
export function credentialProviderUtilsTests() { | ||
|
||
beforeEach(() => { | ||
}); | ||
|
||
afterEach(() => { | ||
}); | ||
|
||
it("buildExternalFeedEndpointsJson null returns null", (done: MochaDone) => { | ||
assert.equal(buildExternalFeedEndpointsJson(null), null); | ||
done(); | ||
}); | ||
|
||
it("buildExternalFeedEndpointsJson empty returns null", (done: MochaDone) => { | ||
assert.equal(buildExternalFeedEndpointsJson([]), null); | ||
done(); | ||
}); | ||
|
||
it("buildExternalFeedEndpointsJson token", (done: MochaDone) => { | ||
const json = buildExternalFeedEndpointsJson([ | ||
<TokenServiceConnection>{ | ||
packageSource: { | ||
uri: "https://contoso.com/nuget/v3/index.json" | ||
}, | ||
authType: ServiceConnectionAuthType.Token, | ||
token: "sometoken" | ||
} | ||
]) | ||
|
||
assert.equal(json, "{\"endpointCredentials\":[{\"endpoint\":\"https://contoso.com/nuget/v3/index.json\",\"password\":\"sometoken\"}]}"); | ||
|
||
done(); | ||
}); | ||
|
||
it("buildExternalFeedEndpointsJson usernamepassword", (done: MochaDone) => { | ||
const json = buildExternalFeedEndpointsJson([ | ||
<UsernamePasswordServiceConnection>{ | ||
packageSource: { | ||
uri: "https://fabrikam.com/nuget/v3/index.json" | ||
}, | ||
authType: ServiceConnectionAuthType.UsernamePassword, | ||
username: "someusername", | ||
password: "somepassword" | ||
} | ||
]) | ||
|
||
assert.equal(json, "{\"endpointCredentials\":[{\"endpoint\":\"https://fabrikam.com/nuget/v3/index.json\",\"username\":\"someusername\",\"password\":\"somepassword\"}]}"); | ||
|
||
done(); | ||
}); | ||
|
||
it("buildExternalFeedEndpointsJson token + usernamepassword", (done: MochaDone) => { | ||
const json = buildExternalFeedEndpointsJson([ | ||
<TokenServiceConnection>{ | ||
packageSource: { | ||
uri: "https://contoso.com/nuget/v3/index.json" | ||
}, | ||
authType: ServiceConnectionAuthType.Token, | ||
token: "sometoken" | ||
}, | ||
<UsernamePasswordServiceConnection>{ | ||
packageSource: { | ||
uri: "https://fabrikam.com/nuget/v3/index.json" | ||
}, | ||
authType: ServiceConnectionAuthType.UsernamePassword, | ||
username: "someusername", | ||
password: "somepassword" | ||
} | ||
]) | ||
|
||
assert.equal(json, "{\"endpointCredentials\":[{\"endpoint\":\"https://contoso.com/nuget/v3/index.json\",\"password\":\"sometoken\"},{\"endpoint\":\"https://fabrikam.com/nuget/v3/index.json\",\"username\":\"someusername\",\"password\":\"somepassword\"}]}"); | ||
|
||
done(); | ||
}); | ||
|
||
it("buildExternalFeedEndpointsJson apikey throws", (done: MochaDone) => { | ||
assert.throws(() => { | ||
buildExternalFeedEndpointsJson([ | ||
<ApiKeyServiceConnection>{ | ||
packageSource: { | ||
uri: "https://contoso.com/nuget/v3/index.json" | ||
}, | ||
authType: ServiceConnectionAuthType.ApiKey, | ||
apiKey: "someapikey" | ||
} | ||
]) | ||
}); | ||
|
||
done(); | ||
}); | ||
|
||
it("buildExternalFeedEndpointsJson otherauthtype throws", (done: MochaDone) => { | ||
assert.throws(() => { | ||
buildExternalFeedEndpointsJson([ | ||
{ | ||
packageSource: { | ||
uri: "https://contoso.com/nuget/v3/index.json" | ||
}, | ||
authType: <any>"unsupportedauthtype", | ||
} | ||
]) | ||
}); | ||
|
||
done(); | ||
}); | ||
} |
132 changes: 132 additions & 0 deletions
132
Tasks/Common/artifacts-common/Tests/packagingAccessMappingUtilsTests.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import * as assert from "assert"; | ||
import { getPackagingAccessMappings, PackagingAccessMapping } from "../packagingAccessMappingUtils"; | ||
|
||
export function packagingAccessMappingUtilsTests() { | ||
const standardDefaultAccessMappingMoniker = "PublicAccessMapping"; | ||
|
||
function getAccessMappings(newDomain) { | ||
let publicAccessPoint = "https://contoso.pkgs.visualstudio.com/" | ||
if (newDomain) { | ||
publicAccessPoint = "https://pkgs.dev.azure.com/contoso/"; | ||
} | ||
return [ | ||
{ | ||
displayName: "Host Guid Access Mapping", | ||
moniker: "HostGuidAccessMapping", | ||
accessPoint: "https://pkgsprodscussu0.pkgs.visualstudio.com/", | ||
serviceOwner: "00000000-0000-0000-0000-000000000000", | ||
virtualDirectory: "Aa731d82f-a042-44ad-a928-61581ea38485" | ||
}, | ||
{ | ||
displayName: "Public Access Mapping", | ||
moniker: "PublicAccessMapping", | ||
accessPoint: publicAccessPoint, | ||
serviceOwner: "00000000-0000-0000-0000-000000000000", | ||
virtualDirectory: "" | ||
}, | ||
{ | ||
displayName: "VSTS Access Mapping", | ||
moniker: "VstsAccessMapping", | ||
accessPoint: "https://contoso.pkgs.visualstudio.com/", | ||
serviceOwner: "00000000-0000-0000-0000-000000000000", | ||
virtualDirectory: "" | ||
}, | ||
{ | ||
displayName: "Codex Access Mapping", | ||
moniker: "CodexAccessMapping", | ||
accessPoint: "https://pkgs.dev.azure.com/contoso/", | ||
serviceOwner: "00000000-0000-0000-0000-000000000000", | ||
virtualDirectory: "" | ||
}]; | ||
} | ||
|
||
|
||
beforeEach(() => { | ||
}); | ||
|
||
afterEach(() => { | ||
}); | ||
|
||
it("getPackagingAccessMappings pkgs.visualstudio.com default", (done: MochaDone) => { | ||
const mappings = getPackagingAccessMappings({ | ||
defaultAccessMappingMoniker: standardDefaultAccessMappingMoniker, | ||
accessMappings: getAccessMappings(false)}); | ||
|
||
assert.deepEqual(mappings, <PackagingAccessMapping[]>[ | ||
{ | ||
uri: "https://pkgsprodscussu0.pkgs.visualstudio.com/Aa731d82f-a042-44ad-a928-61581ea38485/", | ||
isPublic: false, | ||
isDefault: false | ||
}, | ||
{ | ||
uri: "https://contoso.pkgs.visualstudio.com/", | ||
isPublic: true, | ||
isDefault: true | ||
}, | ||
{ | ||
uri: "https://contoso.pkgs.visualstudio.com/", | ||
isPublic: true, | ||
isDefault: false | ||
}, | ||
{ | ||
uri: "https://pkgs.dev.azure.com/contoso/", | ||
isPublic: true, | ||
isDefault: false | ||
} | ||
]); | ||
|
||
done(); | ||
}); | ||
|
||
it("getPackagingAccessMappings pkgs.dev.azure.com default", (done: MochaDone) => { | ||
const mappings = getPackagingAccessMappings({ | ||
defaultAccessMappingMoniker: standardDefaultAccessMappingMoniker, | ||
accessMappings: getAccessMappings(true)}); | ||
|
||
assert.deepEqual(mappings, <PackagingAccessMapping[]>[ | ||
{ | ||
uri: "https://pkgsprodscussu0.pkgs.visualstudio.com/Aa731d82f-a042-44ad-a928-61581ea38485/", | ||
isPublic: false, | ||
isDefault: false | ||
}, | ||
{ | ||
uri: "https://pkgs.dev.azure.com/contoso/", | ||
isPublic: true, | ||
isDefault: true | ||
}, | ||
{ | ||
uri: "https://contoso.pkgs.visualstudio.com/", | ||
isPublic: true, | ||
isDefault: false | ||
}, | ||
{ | ||
uri: "https://pkgs.dev.azure.com/contoso/", | ||
isPublic: true, | ||
isDefault: false | ||
} | ||
]); | ||
|
||
done(); | ||
}); | ||
|
||
it("getPackagingAccessMappings adds trailing slash if missing", (done: MochaDone) => { | ||
const mappings = getPackagingAccessMappings({ | ||
defaultAccessMappingMoniker: standardDefaultAccessMappingMoniker, | ||
accessMappings: [ | ||
{ | ||
moniker: "MissingSlashAccessMapping", | ||
accessPoint: "http://pkgs.dev.azure.com/contoso" | ||
} | ||
]}); | ||
|
||
assert.deepEqual(mappings, [ | ||
{ | ||
uri: "http://pkgs.dev.azure.com/contoso/", | ||
isPublic: false, | ||
isDefault: false | ||
} | ||
]); | ||
|
||
done(); | ||
}); | ||
} |
Oops, something went wrong.