Skip to content

Commit

Permalink
Makes a slight modification to the arrangement of
Browse files Browse the repository at this point in the history
TestRemoteRelationProviderRoleConsumingSide around the arg copying for
macaroon comparison. We observed panics in CI testing.
  • Loading branch information
manadart committed Oct 18, 2023
1 parent 6dd3be0 commit d71a9f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/testing/macaroonsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func MacaroonsEqual(c *gc.C, ms1, ms2 []macaroon.Slice) error {
func MacaroonEquals(c *gc.C, m1, m2 *macaroon.Macaroon) {
c.Assert(m1.Id(), jc.DeepEquals, m2.Id())
c.Assert(m1.Signature(), jc.DeepEquals, m2.Signature())
c.Assert(m1.Location(), jc.DeepEquals, m2.Location())
c.Assert(m1.Location(), gc.Equals, m2.Location())
}

func NewMacaroon(id string) (*macaroon.Macaroon, error) {
Expand Down
22 changes: 10 additions & 12 deletions worker/firewaller/firewaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,18 +1038,16 @@ func (s *InstanceModeSuite) TestRemoteRelationProviderRoleConsumingSide(c *gc.C)
c.Check(version, gc.Equals, 0)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "WatchEgressAddressesForRelations")
expected := params.RemoteEntityArgs{
Args: []params.RemoteEntityArg{{
Token: relToken,
}},
}
// Extract macaroons so we can compare them separately
// (as they can't be compared using DeepEquals due to 'UnmarshaledAs')
rArgs := arg.(params.RemoteEntityArgs)
newMacs := rArgs.Args[0].Macaroons
rArgs.Args[0].Macaroons = nil
apitesting.MacaroonEquals(c, newMacs[0], mac)
c.Check(arg, gc.DeepEquals, expected)

rArgs := arg.(params.RemoteEntityArgs).Args
c.Assert(rArgs, gc.HasLen, 1)
c.Check(rArgs[0].Token, gc.Equals, relToken)

macs := rArgs[0].Macaroons
c.Assert(macs, gc.HasLen, 1)
c.Assert(macs[0], gc.NotNil)
apitesting.MacaroonEquals(c, macs[0], mac)

c.Assert(result, gc.FitsTypeOf, &params.StringsWatchResults{})
*(result.(*params.StringsWatchResults)) = params.StringsWatchResults{
Results: []params.StringsWatchResult{{StringsWatcherId: "1"}},
Expand Down

0 comments on commit d71a9f7

Please sign in to comment.