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

[Pipeline] Change pipeline auth method #3745

Merged
merged 7 commits into from
Mar 12, 2024
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
19 changes: 10 additions & 9 deletions build/jobs/add-aad-test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ steps:
$tenantId = "$(tenant-id)"

# Get admin token
$username = "$(tenant-admin-user-name)"
$password_raw = "$(tenant-admin-user-password)"

$username = "$(tenant-admin-service-principal-name)"
$clientId = "$(tenant-admin-service-principal-id)"
$password_raw = "$(tenant-admin-service-principal-password)"
$password = ConvertTo-SecureString -AsPlainText $password_raw -Force
$adminCredential = New-Object PSCredential $username,$password
$adminCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $clientId, $password

$adTokenUrl = "https://login.microsoftonline.com/$tenantId/oauth2/token"
$resource = "https://graph.windows.net/"

$body = @{
grant_type = "password"
username = $username
password = $password_raw
resource = $resource
client_id = "1950a258-227b-4e31-a9cf-717495945fc2" # Microsoft Azure PowerShell
grant_type = "client_credentials"
client_id = $clientId
client_secret = $password_raw
resource = $resource
}

# If a deleted keyvault exists, remove it first
Expand All @@ -54,7 +55,7 @@ steps:
}

Write-Host "Got access token"
Connect-AzureAD -TenantId $tenantId -AadAccessToken $response.access_token -AccountId $username
Connect-AzureAD -TenantId $tenantId -AadAccessToken $response.access_token -AccountId $clientId

Write-Host "Connected to Azure AD"
Import-Module $(System.DefaultWorkingDirectory)/samples/scripts/PowerShell/FhirServer/FhirServer.psd1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ function Grant-ClientAppDelegatedPermissions {
$resource = "https://graph.microsoft.com/"

$body = @{
grant_type = "password"
username = $TenantAdminCredential.GetNetworkCredential().UserName
password = $TenantAdminCredential.GetNetworkCredential().Password
grant_type = "client_credentials"
client_id = $TenantAdminCredential.GetNetworkCredential().UserName
client_secret = $TenantAdminCredential.GetNetworkCredential().Password
resource = $resource
client_id = "1950a258-227b-4e31-a9cf-717495945fc2" # Microsoft Azure PowerShell
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public BasicAuthTests(HttpIntegrationTestFixture fixture)
_convertDataEnabled = convertDataConfiguration?.Enabled ?? false;
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
fhibf marked this conversation as resolved.
Show resolved Hide resolved
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithNoCreatePermissions_WhenCreatingAResource_TheServerShouldReturnForbidden()
{
Expand All @@ -57,7 +57,7 @@ public async Task GivenAUserWithNoCreatePermissions_WhenCreatingAResource_TheSer
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.CreateAsync(Samples.GetDefaultObservation().ToPoco<Observation>()));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithNoWritePermissions_WhenUpdatingAResource_TheServerShouldReturnForbidden()
{
Expand All @@ -69,7 +69,7 @@ public async Task GivenAUserWithNoWritePermissions_WhenUpdatingAResource_TheServ
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.UpdateAsync(createdResource));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithNoHardDeletePermissions_WhenHardDeletingAResource_TheServerShouldReturnForbidden()
{
Expand All @@ -79,7 +79,7 @@ public async Task GivenAUserWithNoHardDeletePermissions_WhenHardDeletingAResourc
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.HardDeleteAsync(createdResource));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithHardDeletePermissions_WhenHardDeletingAResource_TheServerShouldReturnSuccess()
{
Expand All @@ -104,7 +104,7 @@ async Task<FhirClientException> ExecuteAndValidateNotFoundStatus(Func<Task> acti
}
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithUpdatePermissions_WhenUpdatingAResource_TheServerShouldReturnSuccess()
{
Expand Down Expand Up @@ -179,7 +179,7 @@ public async Task GivenAClientWithWrongAudience_WhenCreatingAResource_TheServerS
Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode);
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithReadPermissions_WhenGettingAResource_TheServerShouldReturnSuccess()
{
Expand All @@ -196,7 +196,7 @@ public async Task GivenAUserWithReadPermissions_WhenGettingAResource_TheServerSh
Assert.Equal(createdResource.Meta.LastUpdated, readResource.Meta.LastUpdated);
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithNoExportPermissions_WhenExportResources_TheServerShouldReturnForbidden()
{
Expand All @@ -207,7 +207,7 @@ public async Task GivenAUserWithNoExportPermissions_WhenExportResources_TheServe
Assert.Equal(HttpStatusCode.Forbidden, fhirException.StatusCode);
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAUserWithExportPermissions_WhenExportResources_TheServerShouldReturnSuccess()
{
Expand Down Expand Up @@ -245,7 +245,7 @@ public async Task GivenAUserWithConvertDataPermissions_WhenConvertData_TheServer
Assert.NotEmpty(result);
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenUserWithNoProfileAdminPermission_WhenCreateProfileDefinitionResource_ThenServerShouldReturnForbidden()
{
Expand All @@ -255,7 +255,7 @@ public async Task GivenUserWithNoProfileAdminPermission_WhenCreateProfileDefinit
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.CreateAsync<ValueSet>(resource));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenUserWithNoProfileAdminPermission_WhenUpdateProfileDefinitionResource_ThenServerShouldReturnForbidden()
{
Expand All @@ -265,7 +265,7 @@ public async Task GivenUserWithNoProfileAdminPermission_WhenUpdateProfileDefinit
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.UpdateAsync<ValueSet>(resource));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenUserWithNoProfileAdminPermission_WhenConditionalCreateProfileDefinitionResource_ThenServerShouldReturnForbidden()
{
Expand All @@ -275,7 +275,7 @@ public async Task GivenUserWithNoProfileAdminPermission_WhenConditionalCreatePro
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.CreateAsync<ValueSet>(resource, "identifier=boo"));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenUserWithNoProfileAdminPermission_WhenConditionalUpdateProfileDefinitionResource_ThenServerShouldReturnForbidden()
{
Expand All @@ -286,7 +286,7 @@ public async Task GivenUserWithNoProfileAdminPermission_WhenConditionalUpdatePro
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.UpdateAsync<ValueSet>(resource, weakETag));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenUserWithNoProfileAdminPermission_WhenDeleteProfileDefinitionResource_ThenServerShouldReturnForbidden()
{
Expand All @@ -296,7 +296,7 @@ public async Task GivenUserWithNoProfileAdminPermission_WhenDeleteProfileDefinit
await RunRequestsSupposedToFailWithForbiddenAccessAsync(async () => await tempClient.DeleteAsync<ValueSet>(resource));
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenUserWithProfileAdminPermission_WhenCUDActionOnProfileDefinitionResource_ThenServerShouldReturnOk()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public async Task GivenAValidBundle_WhenSubmittingABatchTwiceWithAndWithoutChang
BundleTestsUtil.ValidateOperationOutcome(resourceAfterPostingSameBundle.Entry[9].Response.Status, resourceAfterPostingSameBundle.Entry[9].Response.Outcome as OperationOutcome, _statusCodeMap[HttpStatusCode.NotFound], "Resource type 'Patient' with id '12334' couldn't be found.", IssueType.NotFound);
}

[Theory]
[SkippableTheory(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
[Trait(Traits.Category, Categories.Authorization)]
[InlineData(FhirBundleProcessingLogic.Parallel)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public async Task GivenAValidBundleWithUnauthorizedUser_WhenSubmittingATransacti
ValidateOperationOutcome(expectedDiagnostics, expectedCodeType, fhirException.OperationOutcome);
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Priority, Priority.One)]
[Trait(Traits.Category, Categories.Authorization)]
public async Task GivenAValidBundleWithForbiddenUser_WhenSubmittingATransaction_ThenOperationOutcomeWithForbiddenStatusIsReturned()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public async Task GivenIncrementalImportInvalidResource_WhenImportData_ThenError
}
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Category, Categories.Authorization)]
public async Task GivenAUserWithoutImportPermissions_WhenImportData_ThenServerShouldReturnForbidden_WithNoImportNotification()
{
Expand Down Expand Up @@ -420,7 +420,7 @@ private static string PrepareResource(string id, string version, string lastUpda
return ndJson;
}

[Theory]
[SkippableTheory(Skip = "Auth Refactoring")]
[InlineData(true)]
[InlineData(false)]
[Trait(Traits.Category, Categories.Authorization)]
Expand Down Expand Up @@ -449,7 +449,7 @@ public async Task GivenAUserWithImportPermissions_WhenImportData_TheServerShould
}
}

[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
[Trait(Traits.Category, Categories.Authorization)]
public async Task GivenAUserWithoutImportPermissions_WhenImportData_ThenServerShouldReturnForbidden()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public async Task GivenACombinationOfChainingReverseChainSearchExpressionOverARe
}

[HttpIntegrationFixtureArgumentSets(DataStore.CosmosDb, Format.Json)]
[Fact]
[SkippableFact(Skip = "Auth Refactoring")]
public async Task GivenANonSelectiveChainingQueryInCosmosDb_WhenSearched_ThenAnErrorShouldBeThrown()
{
string query = $"subject:Patient.gender=male";
Expand Down
Loading