Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nt-csharp into 503-adding-oauth2-token-provider
  • Loading branch information
LennartKleymann committed Nov 17, 2023
2 parents a8843db + ebe4223 commit b5679d3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
26 changes: 26 additions & 0 deletions Client.UnitTests/DeploymentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,31 @@ public async Task ShouldSendMultipleDeployResourceAndGetResponseAsExpected()
Assert.AreEqual("nameRequirement", decisionRequirementsMetadata.DmnDecisionRequirementsName);
Assert.AreEqual("id", decisionRequirementsMetadata.DmnDecisionRequirementsId);
}

[Test]
public async Task ShouldSetTenantIdAsExpected()
{
// given
var expectedRequest = new DeployResourceRequest
{
TenantId = "1234",
Resources =
{
new Resource
{
Content = ByteString.FromStream(File.OpenRead(_demoProcessPath)),
Name = _demoProcessPath
}
}
};

// when
await ZeebeClient.NewDeployCommand().AddResourceFile(_demoProcessPath).AddTenantId("1234").Send();

// then
var actualRequest = TestService.Requests[typeof(DeployResourceRequest)][0];

Assert.AreEqual(expectedRequest, actualRequest);
}
}
}
2 changes: 1 addition & 1 deletion Client/Api/Commands/IDeployResourceCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ IDeployResourceCommandBuilderStep2 AddResourceStream(
IDeployResourceCommandBuilderStep2 AddResourceFile(string filename);
}

public interface IDeployResourceCommandBuilderStep2 : IDeployResourceCommandStep1, IFinalCommandWithRetryStep<IDeployResourceResponse>
public interface IDeployResourceCommandBuilderStep2 : IDeployResourceCommandStep1, ITenantIdCommandStep<IDeployResourceCommandBuilderStep2>, IFinalCommandWithRetryStep<IDeployResourceResponse>
{
// the place for new optional parameters
}
Expand Down
13 changes: 13 additions & 0 deletions Client/Api/Commands/ITenantIdCommandStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Zeebe.Client.Api.Commands
{
public interface ITenantIdCommandStep<out T>
{
/// <summary>
/// Set the tenantId for the resource.
/// </summary>
/// <param name="tenantId">the tenantId to associate to this resource</param>
/// <returns>The builder for this command. Call <see cref="IFinalCommandStep{T}.Send"/> to complete the command and send it
/// to the broker.</returns>
T AddTenantId(string tenantId);
}
}
2 changes: 1 addition & 1 deletion Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This release is based on the Zeebe 8.3.0 release (https://github.com/zeebe-io/ze
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" version="3.25.0" />
<PackageReference Include="Google.Protobuf" version="3.25.1" />
<PackageReference Include="Grpc" version="2.46.6" />
<PackageReference Include="Grpc.Auth" Version="2.59.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.59.0" />
Expand Down
6 changes: 6 additions & 0 deletions Client/Impl/Commands/DeployResourceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public IDeployResourceCommandBuilderStep2 AddResourceStringUtf8(string resourceS
return this;
}

public IDeployResourceCommandBuilderStep2 AddTenantId(string tenantId)
{
request.TenantId = tenantId;
return this;
}

public async Task<IDeployResourceResponse> Send(TimeSpan? timeout = null, CancellationToken token = default)
{
var asyncReply = gatewayClient.DeployResourceAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);
Expand Down

0 comments on commit b5679d3

Please sign in to comment.