Skip to content

Commit aecb72f

Browse files
Blobs GA Final APIView comments (Azure#19906)
* capitalize Cors -> CORS * capitalize Cors -> CORS * capitalize Cors -> CORS * cleanup and remove other services * cleanup and remove other services * fixed failing test * fixed failing test * fixed failing test * fixed failing test * changelog
1 parent 8ce26f7 commit aecb72f

File tree

16 files changed

+70
-104
lines changed

16 files changed

+70
-104
lines changed

sdk/storage/azblob/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* `CpkScopeInfo` -> `CPKScopeInfo`
2424
* `RuleId` -> `RuleID`
2525
* `PolicyId` -> `PolicyID`
26+
* `CorsRule` -> `CORSRule`
27+
* Remove `AccountServices` it is now hardcoded to blobs
2628

2729
### Other Changes
2830

sdk/storage/azblob/appendblob/client_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,6 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlockPermanentDelete() {
17711771
Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
17721772
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
17731773
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true, PermanentDelete: true}).String(),
1774-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
17751774
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
17761775
}.SignWithSharedKey(credential)
17771776
_require.Nil(err)
@@ -1881,7 +1880,6 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlockPermanentDeleteWithoutPerm
18811880
Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
18821881
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
18831882
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(),
1884-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
18851883
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
18861884
}.SignWithSharedKey(credential)
18871885
_require.Nil(err)

sdk/storage/azblob/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "go",
44
"TagPrefix": "go/storage/azblob",
5-
"Tag": "go/storage/azblob_cf2a55eeaa"
5+
"Tag": "go/storage/azblob_46e572d43a"
66
}

sdk/storage/azblob/blob/client_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ func (s *BlobUnrecordedTestsSuite) TestCreateBlobClientWithSnapshotAndSAS() {
118118
Protocol: sas.ProtocolHTTPS,
119119
ExpiryTime: currentTime,
120120
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(),
121-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
122121
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
123122
}.SignWithSharedKey(credential)
124123
_require.Nil(err)
@@ -159,7 +158,6 @@ func (s *BlobUnrecordedTestsSuite) TestCreateBlobClientWithSnapshotAndSASUsingCo
159158
Protocol: sas.ProtocolHTTPS,
160159
ExpiryTime: currentTime,
161160
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(),
162-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
163161
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
164162
}.SignWithSharedKey(credential)
165163
_require.Nil(err)
@@ -3032,7 +3030,6 @@ func (s *BlobRecordedTestsSuite) TestPermanentDelete() {
30323030
Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
30333031
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
30343032
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true, PermanentDelete: true}).String(),
3035-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
30363033
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
30373034
}.SignWithSharedKey(credential)
30383035
_require.Nil(err)
@@ -3143,7 +3140,6 @@ func (s *BlobRecordedTestsSuite) TestPermanentDeleteWithoutPermission() {
31433140
Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
31443141
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
31453142
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(),
3146-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
31473143
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
31483144
}.SignWithSharedKey(credential)
31493145
_require.Nil(err)

sdk/storage/azblob/blockblob/client_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,6 @@ func (s *BlockBlobUnrecordedTestsSuite) TestSetTierOnCopyBlockBlobFromURL() {
13161316
Protocol: sas.ProtocolHTTPS,
13171317
ExpiryTime: expiryTime,
13181318
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(),
1319-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
13201319
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
13211320
}.SignWithSharedKey(credential)
13221321
_require.Nil(err)
@@ -2861,7 +2860,6 @@ func (s *BlockBlobUnrecordedTestsSuite) TestFilterBlobsWithTags() {
28612860
// Protocol: SASProtocolHTTPS,
28622861
// ExpiryTime: time.Now().UTC().Add(48 * time.Hour),
28632862
// Permissions: AccountSASPermissions{Read: true, List: true, Write: true, DeletePreviousVersion: true, Tag: true, FilterByTags: true, Create: true}.String(),
2864-
// Services: AccountSASServices{Blob: true}.String(),
28652863
// ResourceTypes: AccountSASResourceTypes{Service: true, Container: true, Object: true}.String(),
28662864
// }.Sign(credential)
28672865
// if err != nil {

sdk/storage/azblob/internal/generated/autorest.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,34 @@ directive:
354354
```
355355

356356
### Change CPK acronym to be all caps
357+
357358
``` yaml
358359
directive:
359360
- from: source-file-go
360361
where: $
361362
transform: >-
362363
return $.
363364
replace(/Cpk/g, "CPK");
365+
```
366+
367+
### Change CORS acronym to be all caps
368+
369+
``` yaml
370+
directive:
371+
- from: source-file-go
372+
where: $
373+
transform: >-
374+
return $.
375+
replace(/Cors/g, "CORS");
376+
```
377+
378+
### Change cors xml to be correct
379+
380+
``` yaml
381+
directive:
382+
- from: source-file-go
383+
where: $
384+
transform: >-
385+
return $.
386+
replace(/xml:"CORS>CORSRule"/g, "xml:\"Cors>CorsRule\"");
364387
```

sdk/storage/azblob/internal/generated/zz_models.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/azblob/internal/generated/zz_models_serde.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/azblob/pageblob/client_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4037,7 +4037,6 @@ func (s *PageBlobRecordedTestsSuite) TestPageBlockPermanentDelete() {
40374037
Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
40384038
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
40394039
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true, PermanentDelete: true}).String(),
4040-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
40414040
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
40424041
}.SignWithSharedKey(credential)
40434042
_require.Nil(err)
@@ -4155,7 +4154,6 @@ func (s *PageBlobRecordedTestsSuite) TestPageBlockPermanentDeleteWithoutPermissi
41554154
Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
41564155
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
41574156
Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(),
4158-
Services: to.Ptr(sas.AccountServices{Blob: true}).String(),
41594157
ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(),
41604158
}.SignWithSharedKey(credential)
41614159
_require.Nil(err)

sdk/storage/azblob/sas/account.go

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ type AccountSignatureValues struct {
3131
ExpiryTime time.Time `param:"se"` // Not specified if IsZero
3232
Permissions string `param:"sp"` // Create by initializing a AccountSASPermissions and then call String()
3333
IPRange IPRange `param:"sip"`
34-
Services string `param:"ss"` // Create by initializing AccountSASServices and then call String()
34+
services string `param:"ss"` // will always be "b"
3535
ResourceTypes string `param:"srt"` // Create by initializing AccountSASResourceTypes and then call String()
3636
}
3737

3838
// SignWithSharedKey uses an account's shared key credential to sign this signature values to produce
3939
// the proper SAS query parameters.
4040
func (v AccountSignatureValues) SignWithSharedKey(sharedKeyCredential *SharedKeyCredential) (QueryParameters, error) {
4141
// https://docs.microsoft.com/en-us/rest/api/storageservices/Constructing-an-Account-SAS
42-
if v.ExpiryTime.IsZero() || v.Permissions == "" || v.ResourceTypes == "" || v.Services == "" {
42+
if v.ExpiryTime.IsZero() || v.Permissions == "" || v.ResourceTypes == "" {
4343
return QueryParameters{}, errors.New("account SAS is missing at least one of these: ExpiryTime, Permissions, Service, or ResourceType")
4444
}
4545
if v.Version == "" {
@@ -56,7 +56,7 @@ func (v AccountSignatureValues) SignWithSharedKey(sharedKeyCredential *SharedKey
5656
stringToSign := strings.Join([]string{
5757
sharedKeyCredential.AccountName(),
5858
v.Permissions,
59-
v.Services,
59+
"b", // blob service
6060
v.ResourceTypes,
6161
startTime,
6262
expiryTime,
@@ -80,7 +80,7 @@ func (v AccountSignatureValues) SignWithSharedKey(sharedKeyCredential *SharedKey
8080
ipRange: v.IPRange,
8181

8282
// Account-specific SAS parameters
83-
services: v.Services,
83+
services: v.services,
8484
resourceTypes: v.ResourceTypes,
8585

8686
// Calculated SAS signature
@@ -180,28 +180,6 @@ func parseAccountPermissions(s string) (AccountPermissions, error) {
180180
return p, nil
181181
}
182182

183-
// AccountServices type simplifies creating the services string for an Azure Storage Account SAS.
184-
// Initialize an instance of this type and then call its String method to set AccountSASSignatureValues' Services field.
185-
type AccountServices struct {
186-
Blob, Queue, File bool
187-
}
188-
189-
// String produces the SAS services string for an Azure Storage account.
190-
// Call this method to set AccountSASSignatureValues' Services field.
191-
func (s *AccountServices) String() string {
192-
var buffer bytes.Buffer
193-
if s.Blob {
194-
buffer.WriteRune('b')
195-
}
196-
if s.Queue {
197-
buffer.WriteRune('q')
198-
}
199-
if s.File {
200-
buffer.WriteRune('f')
201-
}
202-
return buffer.String()
203-
}
204-
205183
// AccountResourceTypes type simplifies creating the resource types string for an Azure Storage Account SAS.
206184
// Initialize an instance of this type and then call its String method to set AccountSASSignatureValues' ResourceTypes field.
207185
type AccountResourceTypes struct {

0 commit comments

Comments
 (0)