Skip to content

Commit

Permalink
frontend: Fix status code for subscription PUT
Browse files Browse the repository at this point in the history
By my read of the Subscription Lifecycle API Reference [1], we
should favor 200 OK over 201 Created when creating or updating
a subscription.

[1]
https://github.com/cloud-and-ai-microsoft/resource-provider-contract/blob/master/v1.0/subscription-lifecycle-api-reference.md#response
  • Loading branch information
Matthew Barnes committed Dec 3, 2024
1 parent ba21701 commit 9cebd53
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ func (f *Frontend) ArmSubscriptionPut(writer http.ResponseWriter, request *http.
"state": string(subscription.State),
})

_, err = arm.WriteJSONResponse(writer, http.StatusCreated, subscription)
_, err = arm.WriteJSONResponse(writer, http.StatusOK, subscription)
if err != nil {
f.logger.Error(err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/pkg/frontend/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestSubscriptionsPUT(t *testing.T) {
Properties: nil,
},
subDoc: nil,
expectedStatusCode: http.StatusCreated,
expectedStatusCode: http.StatusOK,
},
{
name: "PUT Subscription - Doc Exists",
Expand All @@ -159,7 +159,7 @@ func TestSubscriptionsPUT(t *testing.T) {
Properties: nil,
},
},
expectedStatusCode: http.StatusCreated,
expectedStatusCode: http.StatusOK,
},
{
name: "PUT Subscription - Invalid Subscription",
Expand Down

0 comments on commit 9cebd53

Please sign in to comment.