Skip to content

Commit

Permalink
fix: Don't assume that all service bindings existed before (#2405)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostbuster91 committed Sep 26, 2024
1 parent a7c3fd5 commit 866dae7
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,27 @@ public List<ValidationEvent> evaluate(Differences differences) {
}
// Validate Operation effective auth schemes
for (ServiceShape newServiceShape : newOperationServiceBindings) {
ServiceShape oldServiceShape = oldModel.expectShape(newServiceShape.getId(), ServiceShape.class);
OperationShape oldOperationShape = change.getOldShape();
List<ShapeId> oldAuthSchemes = oldServiceIndex
.getEffectiveAuthSchemes(oldServiceShape, oldOperationShape)
.keySet()
.stream()
.collect(Collectors.toList());
List<ShapeId> newAuthSchemes = newServiceIndex
.getEffectiveAuthSchemes(newServiceShape, newOperationShape)
.keySet()
.stream()
.collect(Collectors.toList());
validateMigration(
newOperationShape,
oldAuthSchemes,
newAuthSchemes,
events);
oldModel.getShape(newServiceShape.getId())
.filter(Shape::isServiceShape)
.map(s -> (ServiceShape) s)
.ifPresent(oldServiceShape -> {
OperationShape oldOperationShape = change.getOldShape();
List<ShapeId> oldAuthSchemes = oldServiceIndex
.getEffectiveAuthSchemes(oldServiceShape, oldOperationShape)
.keySet()
.stream()
.collect(Collectors.toList());
List<ShapeId> newAuthSchemes = newServiceIndex
.getEffectiveAuthSchemes(newServiceShape, newOperationShape)
.keySet()
.stream()
.collect(Collectors.toList());
validateMigration(
newOperationShape,
oldAuthSchemes,
newAuthSchemes,
events);
});
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$version: "2.0"

metadata suppressions = [
{
id: "ModifiedTrait.Update.smithy.api#auth"
namespace: "ns.foo"
}
]

namespace ns.foo

@auth([])
@httpBearerAuth
service Service {
operations: [
Operation
]
}

@auth([])
operation Operation {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$version: "2.0"

metadata suppressions = [
{
id: "ModifiedTrait.Update.smithy.api#auth"
namespace: "ns.foo"
}
]

namespace ns.foo

@auth([httpBearerAuth])
@httpBearerAuth
service Service {
operations: [
Operation
]
}

@auth([httpBearerAuth])
@httpBearerAuth
service NewService {
operations: [
Operation
]
}


@auth([httpBearerAuth])
operation Operation {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[NOTE] ns.foo#NewService: Added service `ns.foo#NewService` | AddedShape

0 comments on commit 866dae7

Please sign in to comment.