Skip to content

Commit

Permalink
explictly set the SMB protocol when user doesnt specify
Browse files Browse the repository at this point in the history
  • Loading branch information
magodo committed Oct 27, 2021
1 parent a2a23ec commit ce9f6d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion storage/2020-08-04/file/shares/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ func (client Client) CreatePreparer(ctx context.Context, accountName, shareName
"x-ms-share-quota": input.QuotaInGB,
}

protocol := SMB
if input.EnabledProtocol != "" {
headers["x-ms-enabled-protocols"] = input.EnabledProtocol
protocol = input.EnabledProtocol
}
headers["x-ms-enabled-protocols"] = protocol

headers = metadata.SetIntoHeaders(headers, input.MetaData)

Expand Down
3 changes: 3 additions & 0 deletions storage/2020-08-04/file/shares/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func TestSharesLifecycle(t *testing.T) {
if share.ShareQuota != 1 {
t.Fatalf("Expected Quota to be 1 but got: %d", share.ShareQuota)
}
if share.EnabledProtocol != SMB {
t.Fatalf("Expected EnabledProtocol to SMB but got: %s", share.EnabledProtocol)
}

_, err = sharesClient.SetProperties(ctx, accountName, shareName, 5)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions storage/2020-08-04/file/shares/properties_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ func (client Client) GetPropertiesResponder(resp *http.Response) (result GetProp
result.ShareQuota = quota
}

protocolRaw := resp.Header.Get("x-ms-enabled-protocols")
if protocolRaw != "" {
result.EnabledProtocol = ShareProtocol(protocolRaw)
protocol := SMB
if protocolRaw := resp.Header.Get("x-ms-enabled-protocols"); protocolRaw != "" {
protocol = ShareProtocol(protocolRaw)
}
result.EnabledProtocol = protocol
}

err = autorest.Respond(
Expand Down

0 comments on commit ce9f6d4

Please sign in to comment.