Skip to content

Commit

Permalink
fix(experimentalIdentityAndAuth): check effective auth schemes equali…
Browse files Browse the repository at this point in the history
…ty including order
  • Loading branch information
Steven Yuan authored and syall committed Nov 6, 2023
1 parent b6c6733 commit 0254ed2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import software.amazon.smithy.model.knowledge.ServiceIndex.AuthSchemeMode;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.typescript.codegen.CodegenUtils;
import software.amazon.smithy.typescript.codegen.ConfigField;
import software.amazon.smithy.typescript.codegen.Dependency;
Expand Down Expand Up @@ -149,4 +150,23 @@ public static Map<String, HttpAuthSchemeParameter> collectHttpAuthSchemeParamete
}
return httpAuthSchemeParameters;
}

public static boolean areHttpAuthSchemesEqual(
Map<ShapeId, Trait> httpAuthSchemes1,
Map<ShapeId, Trait> httpAuthSchemes2
) {
if (httpAuthSchemes1.size() != httpAuthSchemes2.size()) {
return false;
}
var iter1 = httpAuthSchemes1.entrySet().iterator();
var iter2 = httpAuthSchemes2.entrySet().iterator();
while (iter1.hasNext() && iter2.hasNext()) {
var entry1 = iter1.next();
var entry2 = iter2.next();
if (!entry1.equals(entry2)) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void generateDefaultHttpAuthSchemeProviderFunction() {
serviceShape, operationShapeId, AuthSchemeMode.NO_AUTH_AWARE);
// Skip operation generation if operation auth schemes are equivalent to the default service
// auth schemes.
if (serviceAuthSchemes.equals(operationAuthSchemes)) {
if (AuthUtils.areHttpAuthSchemesEqual(serviceAuthSchemes, operationAuthSchemes)) {
continue;
}
w.openBlock("case $S: {", "};", operationShapeId.getName(), () -> {
Expand Down

0 comments on commit 0254ed2

Please sign in to comment.