Skip to content
Prev Previous commit
Next Next commit
Add more tests
  • Loading branch information
eerhardt committed Mar 18, 2025
commit af56738b292908322568f33d1c20e090985db11a
51 changes: 51 additions & 0 deletions tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,57 @@ param webpubsub_outputs_name string
""");
}

[Fact]
public Task CosmosDBSupport()
{
return RoleAssignmentTest("cosmos",
builder =>
{
var redis = builder.AddAzureCosmosDB("cosmos");

builder.AddProject<Project>("api", launchProfileName: null)
.WithReference(redis);
},
"""
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param cosmos_outputs_name string

resource api_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: take('api_identity-${uniqueString(resourceGroup().id)}', 128)
location: location
}

resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-08-15' existing = {
name: cosmos_outputs_name
}

resource cosmos_roleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2024-08-15' existing = {
name: '00000000-0000-0000-0000-000000000002'
parent: cosmos
}

resource cosmos_roleAssignment 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2024-08-15' = {
name: guid(api_identity.id, cosmos_roleDefinition.id, cosmos.id)
properties: {
principalId: api_identity.properties.principalId
roleDefinitionId: cosmos_roleDefinition.id
scope: cosmos.id
}
parent: cosmos
}

output id string = api_identity.id

output clientId string = api_identity.properties.clientId

output principalId string = api_identity.properties.principalId

output principalName string = api_identity.name
""");
}

[Fact]
public Task RedisSupport()
{
Expand Down
Loading