Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Agustín Martínez Fayó <[email protected]>
Signed-off-by: ajay1135 <[email protected]>
  • Loading branch information
ajay1135 and amartinezfayo committed Jul 1, 2024
1 parent 7a512c1 commit 153943b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Server plugin: BundlePublisher "aws_rolesanywhere_trustanchor"

**Note: This plugin is only supported when an UpstreamAuthority plugin is used.**
> [!WARNING]
> This plugin is only supported when an UpstreamAuthority plugin is used.
The `aws_rolesanywhere_trustanchor` plugin puts the current trust bundle of the server
in a trust anchor, keeping it updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ func TestPublishMultiple(t *testing.T) {
require.Error(t, err)
require.Nil(t, resp)

// UpdateTrustAnchor was called, even though it failed, so its counter should be incremented.
require.Equal(t, 1, client.updateTrustAnchorCount)
// The UpdateTrustAnchor call failed, so its counter should not be incremented.
require.Equal(t, 0, client.updateTrustAnchorCount)

// Remove the updateTrustAnchorErr and try again.
client.updateTrustAnchorErr = nil
Expand All @@ -279,7 +279,7 @@ func TestPublishMultiple(t *testing.T) {
})
require.NoError(t, err)
require.NotNil(t, resp)
require.Equal(t, 2, client.updateTrustAnchorCount)
require.Equal(t, 1, client.updateTrustAnchorCount)

// Call PublishBundle with the same bundle.
resp, err = p.PublishBundle(context.Background(), &bundlepublisherv1.PublishBundleRequest{
Expand All @@ -289,7 +289,7 @@ func TestPublishMultiple(t *testing.T) {
require.NotNil(t, resp)

// The same bundle was used, the counter should be the same as before.
require.Equal(t, 2, client.updateTrustAnchorCount)
require.Equal(t, 1, client.updateTrustAnchorCount)

// Have a new bundle and call PublishBundle.
bundle = getTestBundle(t)
Expand All @@ -302,14 +302,15 @@ func TestPublishMultiple(t *testing.T) {

// PublishBundle was called with a different bundle, updateTrustAnchorCount should
// be incremented to be 3.
require.Equal(t, 3, client.updateTrustAnchorCount)
require.Equal(t, 2, client.updateTrustAnchorCount)

// Try to publish a bundle that's too large, and expect that we receive an error.
bundle = getLargeTestBundle(t)
bundle.SequenceNumber = 3
resp, err = p.PublishBundle(context.Background(), &bundlepublisherv1.PublishBundleRequest{
Bundle: bundle,
})
require.Nil(t, resp)
require.Error(t, err)
}

Expand All @@ -324,15 +325,14 @@ type fakeClient struct {
}

func (c *fakeClient) UpdateTrustAnchor(_ context.Context, params *rolesanywhere.UpdateTrustAnchorInput, _ ...func(*rolesanywhere.Options)) (*rolesanywhere.UpdateTrustAnchorOutput, error) {
c.updateTrustAnchorCount++

if c.updateTrustAnchorErr != nil {
return nil, c.updateTrustAnchorErr
}

require.Equal(c.t, c.expectTrustAnchorID, params.TrustAnchorId, "trust anchor id mismatch")
trustAnchorArn := "trustAnchorArn"
trustAnchorName := "trustAnchorName"
c.updateTrustAnchorCount++
return &rolesanywhere.UpdateTrustAnchorOutput{
TrustAnchor: &rolesanywheretypes.TrustAnchorDetail{
TrustAnchorArn: &trustAnchorArn,
Expand Down

0 comments on commit 153943b

Please sign in to comment.