* Basic CPK-V/CPK-N Code

* Minor Fix

* Rev - 1 | Fixed Comment

* Added CPK in retry download
This commit is contained in:
Mohit Sharma 2020-11-19 15:05:57 +05:30 коммит произвёл GitHub
Родитель e5968b22f5
Коммит b336354e28
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
27 изменённых файлов: 1419 добавлений и 708 удалений

Просмотреть файл

@ -16,8 +16,8 @@ import (
// blockWriter provides methods to upload blocks that represent a file to a server and commit them.
// This allows us to provide a local implementation that fakes the server for hermetic testing.
type blockWriter interface {
StageBlock(context.Context, string, io.ReadSeeker, LeaseAccessConditions, []byte) (*BlockBlobStageBlockResponse, error)
CommitBlockList(context.Context, []string, BlobHTTPHeaders, Metadata, BlobAccessConditions, AccessTierType, BlobTagsMap) (*BlockBlobCommitBlockListResponse, error)
StageBlock(context.Context, string, io.ReadSeeker, LeaseAccessConditions, []byte, ClientProvidedKeyOptions) (*BlockBlobStageBlockResponse, error)
CommitBlockList(context.Context, []string, BlobHTTPHeaders, Metadata, BlobAccessConditions, AccessTierType, BlobTagsMap, ClientProvidedKeyOptions) (*BlockBlobCommitBlockListResponse, error)
}
// copyFromReader copies a source io.Reader to blob storage using concurrent uploads.
@ -184,7 +184,7 @@ func (c *copier) write(chunk copierChunk) error {
return err
}
_, err := c.to.StageBlock(c.ctx, chunk.id, bytes.NewReader(chunk.buffer), LeaseAccessConditions{}, nil)
_, err := c.to.StageBlock(c.ctx, chunk.id, bytes.NewReader(chunk.buffer), LeaseAccessConditions{}, nil, c.o.ClientProvidedKeyOptions)
if err != nil {
return fmt.Errorf("write error: %w", err)
}
@ -201,11 +201,11 @@ func (c *copier) close() error {
}
var err error
c.result, err = c.to.CommitBlockList(c.ctx, c.id.issued(), c.o.BlobHTTPHeaders, c.o.Metadata, c.o.AccessConditions, c.o.BlobAccessTier, c.o.BlobTagsMap)
c.result, err = c.to.CommitBlockList(c.ctx, c.id.issued(), c.o.BlobHTTPHeaders, c.o.Metadata, c.o.AccessConditions, c.o.BlobAccessTier, c.o.BlobTagsMap, c.o.ClientProvidedKeyOptions)
return err
}
// id allows the creation of unique IDs based on UUID4 + an int32. This autoincrements.
// id allows the creation of unique IDs based on UUID4 + an int32. This auto-increments.
type id struct {
u [64]byte
num uint32

Просмотреть файл

@ -37,7 +37,7 @@ func newFakeBlockWriter() *fakeBlockWriter {
return f
}
func (f *fakeBlockWriter) StageBlock(ctx context.Context, blockID string, r io.ReadSeeker, cond LeaseAccessConditions, md5 []byte) (*BlockBlobStageBlockResponse, error) {
func (f *fakeBlockWriter) StageBlock(ctx context.Context, blockID string, r io.ReadSeeker, cond LeaseAccessConditions, md5 []byte, cpk ClientProvidedKeyOptions) (*BlockBlobStageBlockResponse, error) {
n := atomic.AddInt32(&f.block, 1)
if n == f.errOnBlock {
return nil, io.ErrNoProgress
@ -58,7 +58,7 @@ func (f *fakeBlockWriter) StageBlock(ctx context.Context, blockID string, r io.R
return &BlockBlobStageBlockResponse{}, nil
}
func (f *fakeBlockWriter) CommitBlockList(ctx context.Context, blockIDs []string, headers BlobHTTPHeaders, meta Metadata, access BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlockBlobCommitBlockListResponse, error) {
func (f *fakeBlockWriter) CommitBlockList(ctx context.Context, blockIDs []string, headers BlobHTTPHeaders, meta Metadata, access BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap, options ClientProvidedKeyOptions) (*BlockBlobCommitBlockListResponse, error) {
dst, err := os.OpenFile(filepath.Join(f.path, finalFileName), os.O_CREATE+os.O_WRONLY, 0600)
if err != nil {
return nil, err

Просмотреть файл

@ -58,9 +58,12 @@ type UploadToBlockBlobOptions struct {
// BlobAccessTier indicates the tier of blob
BlobAccessTier AccessTierType
// BlobTagsStg
// BlobTagsMap
BlobTagsMap BlobTagsMap
// ClientProvidedKeyOptions indicates the client provided key by name and/or by value to encrypt/decrypt data.
ClientProvidedKeyOptions ClientProvidedKeyOptions
// Parallelism indicates the maximum number of blocks to upload in parallel (0=default)
Parallelism uint16
}
@ -91,7 +94,7 @@ func uploadReaderAtToBlockBlob(ctx context.Context, reader io.ReaderAt, readerSi
if o.Progress != nil {
body = pipeline.NewRequestBodyProgress(body, o.Progress)
}
return blockBlobURL.Upload(ctx, body, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier, o.BlobTagsMap)
return blockBlobURL.Upload(ctx, body, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier, o.BlobTagsMap, o.ClientProvidedKeyOptions)
}
var numBlocks = uint16(((readerSize - 1) / o.BlockSize) + 1)
@ -127,7 +130,7 @@ func uploadReaderAtToBlockBlob(ctx context.Context, reader io.ReaderAt, readerSi
// Block IDs are unique values to avoid issue if 2+ clients are uploading blocks
// at the same time causing PutBlockList to get a mix of blocks from all the clients.
blockIDList[blockNum] = base64.StdEncoding.EncodeToString(newUUID().bytes())
_, err := blockBlobURL.StageBlock(ctx, blockIDList[blockNum], body, o.AccessConditions.LeaseAccessConditions, nil)
_, err := blockBlobURL.StageBlock(ctx, blockIDList[blockNum], body, o.AccessConditions.LeaseAccessConditions, nil, o.ClientProvidedKeyOptions)
return err
},
})
@ -135,7 +138,7 @@ func uploadReaderAtToBlockBlob(ctx context.Context, reader io.ReaderAt, readerSi
return nil, err
}
// All put blocks were successful, call Put Block List to finalize the blob
return blockBlobURL.CommitBlockList(ctx, blockIDList, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier, o.BlobTagsMap)
return blockBlobURL.CommitBlockList(ctx, blockIDList, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier, o.BlobTagsMap, o.ClientProvidedKeyOptions)
}
// UploadBufferToBlockBlob uploads a buffer in blocks to a block blob.
@ -170,6 +173,9 @@ type DownloadFromBlobOptions struct {
// AccessConditions indicates the access conditions used when making HTTP GET requests against the blob.
AccessConditions BlobAccessConditions
// ClientProvidedKeyOptions indicates the client provided key by name and/or by value to encrypt/decrypt data.
ClientProvidedKeyOptions ClientProvidedKeyOptions
// Parallelism indicates the maximum number of blocks to download in parallel (0=default)
Parallelism uint16
@ -189,7 +195,7 @@ func downloadBlobToWriterAt(ctx context.Context, blobURL BlobURL, offset int64,
count = initialDownloadResponse.ContentLength() - offset // if we have the length, use it
} else {
// If we don't have the length at all, get it
dr, err := blobURL.Download(ctx, 0, CountToEnd, o.AccessConditions, false)
dr, err := blobURL.Download(ctx, 0, CountToEnd, o.AccessConditions, false, o.ClientProvidedKeyOptions)
if err != nil {
return err
}
@ -212,7 +218,7 @@ func downloadBlobToWriterAt(ctx context.Context, blobURL BlobURL, offset int64,
ChunkSize: o.BlockSize,
Parallelism: o.Parallelism,
Operation: func(chunkStart int64, count int64, ctx context.Context) error {
dr, err := blobURL.Download(ctx, chunkStart+offset, count, o.AccessConditions, false)
dr, err := blobURL.Download(ctx, chunkStart+offset, count, o.AccessConditions, false, o.ClientProvidedKeyOptions)
if err != nil {
return err
}
@ -258,7 +264,7 @@ func DownloadBlobToFile(ctx context.Context, blobURL BlobURL, offset int64, coun
if count == CountToEnd {
// Try to get Azure blob's size
props, err := blobURL.GetProperties(ctx, o.AccessConditions)
props, err := blobURL.GetProperties(ctx, o.AccessConditions, o.ClientProvidedKeyOptions)
if err != nil {
return err
}
@ -361,12 +367,13 @@ type UploadStreamToBlockBlobOptions struct {
// BufferSize sizes the buffer used to read data from source. If < 1 MiB, defaults to 1 MiB.
BufferSize int
// MaxBuffers defines the number of simultaneous uploads will be performed to upload the file.
MaxBuffers int
BlobHTTPHeaders BlobHTTPHeaders
Metadata Metadata
AccessConditions BlobAccessConditions
BlobAccessTier AccessTierType
BlobTagsMap BlobTagsMap
MaxBuffers int
BlobHTTPHeaders BlobHTTPHeaders
Metadata Metadata
AccessConditions BlobAccessConditions
BlobAccessTier AccessTierType
BlobTagsMap BlobTagsMap
ClientProvidedKeyOptions ClientProvidedKeyOptions
}
func (u *UploadStreamToBlockBlobOptions) defaults() {

Просмотреть файл

@ -1,7 +1,6 @@
package azblob
import (
"errors"
"net"
"net/url"
"strings"
@ -135,11 +134,6 @@ func (up BlobURLParts) URL() url.URL {
rawQuery := up.UnparsedParams
// Check: Both snapshot and version id cannot be present in the request URL.
if up.Snapshot != "" && up.VersionID != "" {
errors.New("Snapshot and versioning cannot be enabled simultaneously")
}
//If no snapshot is initially provided, fill it in from the SAS query properties to help the user
if up.Snapshot == "" && !up.SAS.snapshotTime.IsZero() {
up.Snapshot = up.SAS.snapshotTime.Format(SnapshotTimeFormat)

33
azblob/request_common.go Normal file
Просмотреть файл

@ -0,0 +1,33 @@
package azblob
// ClientProvidedKeyOptions contains headers which may be be specified from service version 2019-02-02
// or higher to encrypts the data on the service-side with the given key. Use of customer-provided keys
// must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection
// must be established to transfer the key.
// Note: Azure Storage does not store or manage customer provided encryption keys. Keys are securely discarded
// as soon as possible after theyve been used to encrypt or decrypt the blob data.
// https://docs.microsoft.com/en-us/azure/storage/common/storage-service-encryption
// https://docs.microsoft.com/en-us/azure/storage/common/customer-managed-keys-overview
type ClientProvidedKeyOptions struct {
// A Base64-encoded AES-256 encryption key value.
EncryptionKey *string
// The Base64-encoded SHA256 of the encryption key.
EncryptionKeySha256 *string
// Specifies the algorithm to use when encrypting data using the given key. Must be AES256.
EncryptionAlgorithm EncryptionAlgorithmType
// Specifies the name of the encryption scope to use to encrypt the data provided in the request
// https://docs.microsoft.com/en-us/azure/storage/blobs/encryption-scope-overview
// https://docs.microsoft.com/en-us/azure/key-vault/general/overview
EncryptionScope *string
}
// NewClientProvidedKeyOptions function.
// By default the value of encryption algorithm params is "AES256" for service version 2019-02-02 or higher.
func NewClientProvidedKeyOptions(ek *string, eksha256 *string, es *string) (cpk ClientProvidedKeyOptions) {
cpk = ClientProvidedKeyOptions{}
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, cpk.EncryptionScope = ek, eksha256, EncryptionAlgorithmAES256, es
return cpk
}

Просмотреть файл

@ -61,8 +61,11 @@ const (
// ServiceCodeIncrementalCopyBlobMismatch means the specified source blob is different than the copy source of the existing incremental copy blob.
ServiceCodeIncrementalCopyBlobMismatch ServiceCodeType = "IncrementalCopyBlobMismatch"
// ServiceCodeIncrementalCopyOfEralierVersionSnapshotNotAllowed means the specified snapshot is earlier than the last snapshot copied into the incremental copy blob.
ServiceCodeIncrementalCopyOfEralierVersionSnapshotNotAllowed ServiceCodeType = "IncrementalCopyOfEralierVersionSnapshotNotAllowed"
// ServiceCodeFeatureEncryptionMismatch means the given customer specified encryption does not match the encryption used to encrypt the blob.
ServiceCodeFeatureEncryptionMismatch ServiceCodeType = "BlobCustomerSpecifiedEncryptionMismatch"
// ServiceCodeIncrementalCopyOfEarlierVersionSnapshotNotAllowed means the specified snapshot is earlier than the last snapshot copied into the incremental copy blob.
ServiceCodeIncrementalCopyOfEarlierVersionSnapshotNotAllowed ServiceCodeType = "IncrementalCopyOfEarlierVersionSnapshotNotAllowed"
// ServiceCodeIncrementalCopySourceMustBeSnapshot means the source for incremental copy request must be a snapshot.
ServiceCodeIncrementalCopySourceMustBeSnapshot ServiceCodeType = "IncrementalCopySourceMustBeSnapshot"

Просмотреть файл

@ -56,14 +56,14 @@ func (ab AppendBlobURL) GetAccountInfo(ctx context.Context) (*BlobGetAccountInfo
// Create creates a 0-length append blob. Call AppendBlock to append data to an append blob.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-blob.
func (ab AppendBlobURL) Create(ctx context.Context, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, blobTagsMap BlobTagsMap) (*AppendBlobCreateResponse, error) {
func (ab AppendBlobURL) Create(ctx context.Context, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, blobTagsMap BlobTagsMap, cpk ClientProvidedKeyOptions) (*AppendBlobCreateResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch := ac.ModifiedAccessConditions.pointers()
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
return ab.abClient.Create(ctx, 0, nil,
&h.ContentType, &h.ContentEncoding, &h.ContentLanguage, h.ContentMD5,
&h.CacheControl, metadata, ac.LeaseAccessConditions.pointers(), &h.ContentDisposition,
nil, nil, EncryptionAlgorithmNone, // CPK-V
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
cpk.EncryptionScope, // CPK-N
ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch,
nil, // Blob ifTags
nil,
@ -75,7 +75,7 @@ func (ab AppendBlobURL) Create(ctx context.Context, h BlobHTTPHeaders, metadata
// This method panics if the stream is not at position 0.
// Note that the http client closes the body stream after the request is sent to the service.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/append-block.
func (ab AppendBlobURL) AppendBlock(ctx context.Context, body io.ReadSeeker, ac AppendBlobAccessConditions, transactionalMD5 []byte) (*AppendBlobAppendBlockResponse, error) {
func (ab AppendBlobURL) AppendBlock(ctx context.Context, body io.ReadSeeker, ac AppendBlobAccessConditions, transactionalMD5 []byte, cpk ClientProvidedKeyOptions) (*AppendBlobAppendBlockResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
ifAppendPositionEqual, ifMaxSizeLessThanOrEqual := ac.AppendPositionAccessConditions.pointers()
count, err := validateSeekableStreamAt0AndGetCount(body)
@ -87,8 +87,8 @@ func (ab AppendBlobURL) AppendBlock(ctx context.Context, body io.ReadSeeker, ac
nil, // CRC
ac.LeaseAccessConditions.pointers(),
ifMaxSizeLessThanOrEqual, ifAppendPositionEqual,
nil, nil, EncryptionAlgorithmNone, // CPK
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
cpk.EncryptionScope, // CPK-N
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags
nil)
@ -96,14 +96,14 @@ func (ab AppendBlobURL) AppendBlock(ctx context.Context, body io.ReadSeeker, ac
// AppendBlockFromURL copies a new block of data from source URL to the end of the existing append blob.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/append-block-from-url.
func (ab AppendBlobURL) AppendBlockFromURL(ctx context.Context, sourceURL url.URL, offset int64, count int64, destinationAccessConditions AppendBlobAccessConditions, sourceAccessConditions ModifiedAccessConditions, transactionalMD5 []byte) (*AppendBlobAppendBlockFromURLResponse, error) {
func (ab AppendBlobURL) AppendBlockFromURL(ctx context.Context, sourceURL url.URL, offset int64, count int64, destinationAccessConditions AppendBlobAccessConditions, sourceAccessConditions ModifiedAccessConditions, transactionalMD5 []byte, cpk ClientProvidedKeyOptions) (*AppendBlobAppendBlockFromURLResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := destinationAccessConditions.ModifiedAccessConditions.pointers()
sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatchETag, sourceIfNoneMatchETag := sourceAccessConditions.pointers()
ifAppendPositionEqual, ifMaxSizeLessThanOrEqual := destinationAccessConditions.AppendPositionAccessConditions.pointers()
return ab.abClient.AppendBlockFromURL(ctx, sourceURL.String(), 0, httpRange{offset: offset, count: count}.pointers(),
transactionalMD5, nil, nil, nil,
nil, nil, EncryptionAlgorithmNone, // CPK
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
cpk.EncryptionScope, // CPK-N
destinationAccessConditions.LeaseAccessConditions.pointers(),
ifMaxSizeLessThanOrEqual, ifAppendPositionEqual,
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,

Просмотреть файл

@ -98,13 +98,13 @@ func SerializeBlobTags(blobTagsMap BlobTagsMap) BlobTags {
return BlobTags{BlobTagSet: blobTagSet}
}
// DownloadBlob reads a range of bytes from a blob. The response also includes the blob's properties and metadata.
// Download reads a range of bytes from a blob. The response also includes the blob's properties and metadata.
// Passing azblob.CountToEnd (0) for count will download the blob from the offset to the end.
// Note: Snapshot/VersionId are optional parameters which are part of request URL query params.
// These parameters can be explicitly set by calling WithSnapshot(snapshot string)/WithVersionID(versionID string)
// Therefore it not required to pass these here.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/get-blob.
func (b BlobURL) Download(ctx context.Context, offset int64, count int64, ac BlobAccessConditions, rangeGetContentMD5 bool) (*DownloadResponse, error) {
func (b BlobURL) Download(ctx context.Context, offset int64, count int64, ac BlobAccessConditions, rangeGetContentMD5 bool, cpk ClientProvidedKeyOptions) (*DownloadResponse, error) {
var xRangeGetContentMD5 *bool
if rangeGetContentMD5 {
xRangeGetContentMD5 = &rangeGetContentMD5
@ -113,7 +113,7 @@ func (b BlobURL) Download(ctx context.Context, offset int64, count int64, ac Blo
dr, err := b.blobClient.Download(ctx, nil, nil, nil,
httpRange{offset: offset, count: count}.pointers(),
ac.LeaseAccessConditions.pointers(), xRangeGetContentMD5, nil,
nil, nil, EncryptionAlgorithmNone, // CPK
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags
nil)
@ -128,7 +128,7 @@ func (b BlobURL) Download(ctx context.Context, offset int64, count int64, ac Blo
}, err
}
// DeleteBlob marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection.
// Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection.
// Note 1: that deleting a blob also deletes all its snapshots.
// Note 2: Snapshot/VersionId are optional parameters which are part of request URL query params.
// These parameters can be explicitly set by calling WithSnapshot(snapshot string)/WithVersionID(versionID string)
@ -142,7 +142,7 @@ func (b BlobURL) Delete(ctx context.Context, deleteOptions DeleteSnapshotsOption
nil)
}
// The Set Tags operation enables users to set tags on a blob or specific blob version, but not snapshot.
// SetTags operation enables users to set tags on a blob or specific blob version, but not snapshot.
// Each call to this operation replaces all existing tags attached to the blob.
// To remove all tags from the blob, call this operation with no tags set.
// https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tags
@ -151,7 +151,7 @@ func (b BlobURL) SetTags(ctx context.Context, timeout *int32, versionID *string,
return b.blobClient.SetTags(ctx, timeout, versionID, transactionalContentMD5, transactionalContentCrc64, requestID, ifTags, &tags)
}
// The Get Tags operation enables users to get tags on a blob or specific blob version, or snapshot.
// GetTags operation enables users to get tags on a blob or specific blob version, or snapshot.
// https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-tags
func (b BlobURL) GetTags(ctx context.Context, timeout *int32, requestID *string, snapshot *string, versionID *string, ifTags *string) (*BlobTags, error) {
return b.blobClient.GetTags(ctx, timeout, requestID, snapshot, versionID, ifTags)
@ -176,23 +176,23 @@ func (b BlobURL) SetTier(ctx context.Context, tier AccessTierType, lac LeaseAcce
nil, RehydratePriorityNone, nil, lac.pointers())
}
// GetBlobProperties returns the blob's properties.
// GetProperties returns the blob's properties.
// Note: Snapshot/VersionId are optional parameters which are part of request URL query params.
// These parameters can be explicitly set by calling WithSnapshot(snapshot string)/WithVersionID(versionID string)
// Therefore it not required to pass these here.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/get-blob-properties.
func (b BlobURL) GetProperties(ctx context.Context, ac BlobAccessConditions) (*BlobGetPropertiesResponse, error) {
func (b BlobURL) GetProperties(ctx context.Context, ac BlobAccessConditions, cpk ClientProvidedKeyOptions) (*BlobGetPropertiesResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
return b.blobClient.GetProperties(ctx, nil,
nil, // Blob versioning
nil, ac.LeaseAccessConditions.pointers(),
nil, nil, EncryptionAlgorithmNone, // CPK
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags
nil)
}
// SetBlobHTTPHeaders changes a blob's HTTP headers.
// SetHTTPHeaders changes a blob's HTTP headers.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/set-blob-properties.
func (b BlobURL) SetHTTPHeaders(ctx context.Context, h BlobHTTPHeaders, ac BlobAccessConditions) (*BlobSetHTTPHeadersResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
@ -203,13 +203,13 @@ func (b BlobURL) SetHTTPHeaders(ctx context.Context, h BlobHTTPHeaders, ac BlobA
&h.ContentDisposition, nil)
}
// SetBlobMetadata changes a blob's metadata.
// SetMetadata changes a blob's metadata.
// https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata.
func (b BlobURL) SetMetadata(ctx context.Context, metadata Metadata, ac BlobAccessConditions) (*BlobSetMetadataResponse, error) {
func (b BlobURL) SetMetadata(ctx context.Context, metadata Metadata, ac BlobAccessConditions, cpk ClientProvidedKeyOptions) (*BlobSetMetadataResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
return b.blobClient.SetMetadata(ctx, nil, metadata, ac.LeaseAccessConditions.pointers(),
nil, nil, EncryptionAlgorithmNone, // CPK-V
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
cpk.EncryptionScope, // CPK-N
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags
nil)
@ -217,14 +217,14 @@ func (b BlobURL) SetMetadata(ctx context.Context, metadata Metadata, ac BlobAcce
// CreateSnapshot creates a read-only snapshot of a blob.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/snapshot-blob.
func (b BlobURL) CreateSnapshot(ctx context.Context, metadata Metadata, ac BlobAccessConditions) (*BlobCreateSnapshotResponse, error) {
func (b BlobURL) CreateSnapshot(ctx context.Context, metadata Metadata, ac BlobAccessConditions, cpk ClientProvidedKeyOptions) (*BlobCreateSnapshotResponse, error) {
// CreateSnapshot does NOT panic if the user tries to create a snapshot using a URL that already has a snapshot query parameter
// because checking this would be a performance hit for a VERY unusual path and I don't think the common case should suffer this
// performance hit.
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
return b.blobClient.CreateSnapshot(ctx, nil, metadata,
nil, nil, EncryptionAlgorithmNone, // CPK-V
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
cpk.EncryptionScope, // CPK-N
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags
ac.LeaseAccessConditions.pointers(), nil)

Просмотреть файл

@ -64,7 +64,7 @@ func (bb BlockBlobURL) GetAccountInfo(ctx context.Context) (*BlobGetAccountInfoR
// This method panics if the stream is not at position 0.
// Note that the http client closes the body stream after the request is sent to the service.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-blob.
func (bb BlockBlobURL) Upload(ctx context.Context, body io.ReadSeeker, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlockBlobUploadResponse, error) {
func (bb BlockBlobURL) Upload(ctx context.Context, body io.ReadSeeker, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap, cpk ClientProvidedKeyOptions) (*BlockBlobUploadResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
count, err := validateSeekableStreamAt0AndGetCount(body)
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
@ -74,8 +74,8 @@ func (bb BlockBlobURL) Upload(ctx context.Context, body io.ReadSeeker, h BlobHTT
return bb.bbClient.Upload(ctx, body, count, nil, nil,
&h.ContentType, &h.ContentEncoding, &h.ContentLanguage, h.ContentMD5,
&h.CacheControl, metadata, ac.LeaseAccessConditions.pointers(), &h.ContentDisposition,
nil, nil, EncryptionAlgorithmNone, // CPK-V
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
cpk.EncryptionScope, // CPK-N
tier, ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags
nil,
@ -86,25 +86,25 @@ func (bb BlockBlobURL) Upload(ctx context.Context, body io.ReadSeeker, h BlobHTT
// StageBlock uploads the specified block to the block blob's "staging area" to be later committed by a call to CommitBlockList.
// Note that the http client closes the body stream after the request is sent to the service.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-block.
func (bb BlockBlobURL) StageBlock(ctx context.Context, base64BlockID string, body io.ReadSeeker, ac LeaseAccessConditions, transactionalMD5 []byte) (*BlockBlobStageBlockResponse, error) {
func (bb BlockBlobURL) StageBlock(ctx context.Context, base64BlockID string, body io.ReadSeeker, ac LeaseAccessConditions, transactionalMD5 []byte, cpk ClientProvidedKeyOptions) (*BlockBlobStageBlockResponse, error) {
count, err := validateSeekableStreamAt0AndGetCount(body)
if err != nil {
return nil, err
}
return bb.bbClient.StageBlock(ctx, base64BlockID, count, body, transactionalMD5, nil, nil, ac.pointers(),
nil, nil, EncryptionAlgorithmNone, // CPK-V
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
cpk.EncryptionScope, // CPK-N
nil)
}
// StageBlockFromURL copies the specified block from a source URL to the block blob's "staging area" to be later committed by a call to CommitBlockList.
// If count is CountToEnd (0), then data is read from specified offset to the end.
// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/put-block-from-url.
func (bb BlockBlobURL) StageBlockFromURL(ctx context.Context, base64BlockID string, sourceURL url.URL, offset int64, count int64, destinationAccessConditions LeaseAccessConditions, sourceAccessConditions ModifiedAccessConditions) (*BlockBlobStageBlockFromURLResponse, error) {
func (bb BlockBlobURL) StageBlockFromURL(ctx context.Context, base64BlockID string, sourceURL url.URL, offset int64, count int64, destinationAccessConditions LeaseAccessConditions, sourceAccessConditions ModifiedAccessConditions, cpk ClientProvidedKeyOptions) (*BlockBlobStageBlockFromURLResponse, error) {
sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatchETag, sourceIfNoneMatchETag := sourceAccessConditions.pointers()
return bb.bbClient.StageBlockFromURL(ctx, base64BlockID, 0, sourceURL.String(), httpRange{offset: offset, count: count}.pointers(), nil, nil, nil,
nil, nil, EncryptionAlgorithmNone, // CPK
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
cpk.EncryptionScope, // CPK-N
destinationAccessConditions.pointers(), sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatchETag, sourceIfNoneMatchETag, nil)
}
@ -114,14 +114,14 @@ func (bb BlockBlobURL) StageBlockFromURL(ctx context.Context, base64BlockID stri
// by uploading only those blocks that have changed, then committing the new and existing
// blocks together. Any blocks not specified in the block list and permanently deleted.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-block-list.
func (bb BlockBlobURL) CommitBlockList(ctx context.Context, base64BlockIDs []string, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlockBlobCommitBlockListResponse, error) {
func (bb BlockBlobURL) CommitBlockList(ctx context.Context, base64BlockIDs []string, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap, cpk ClientProvidedKeyOptions) (*BlockBlobCommitBlockListResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
return bb.bbClient.CommitBlockList(ctx, BlockLookupList{Latest: base64BlockIDs}, nil,
&h.CacheControl, &h.ContentType, &h.ContentEncoding, &h.ContentLanguage, h.ContentMD5, nil, nil,
metadata, ac.LeaseAccessConditions.pointers(), &h.ContentDisposition,
nil, nil, EncryptionAlgorithmNone, // CPK
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
cpk.EncryptionScope, // CPK-N
tier,
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags

Просмотреть файл

@ -14,7 +14,7 @@ const (
// PageBlobPageBytes indicates the number of bytes in a page (512).
PageBlobPageBytes = 512
// PageBlobMaxPutPagesBytes indicates the maximum number of bytes that can be sent in a call to PutPage.
// PageBlobMaxUploadPagesBytes indicates the maximum number of bytes that can be sent in a call to PutPage.
PageBlobMaxUploadPagesBytes = 4 * 1024 * 1024 // 4MB
)
@ -56,16 +56,16 @@ func (pb PageBlobURL) GetAccountInfo(ctx context.Context) (*BlobGetAccountInfoRe
return pb.blobClient.GetAccountInfo(ctx)
}
// Create creates a page blob of the specified length. Call PutPage to upload data data to a page blob.
// Create creates a page blob of the specified length. Call PutPage to upload data to a page blob.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-blob.
func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int64, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier PremiumPageBlobAccessTierType, blobTagsMap BlobTagsMap) (*PageBlobCreateResponse, error) {
func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int64, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier PremiumPageBlobAccessTierType, blobTagsMap BlobTagsMap, cpk ClientProvidedKeyOptions) (*PageBlobCreateResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
return pb.pbClient.Create(ctx, 0, size, nil, tier,
&h.ContentType, &h.ContentEncoding, &h.ContentLanguage, h.ContentMD5, &h.CacheControl,
metadata, ac.LeaseAccessConditions.pointers(), &h.ContentDisposition,
nil, nil, EncryptionAlgorithmNone, // CPK-V
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
cpk.EncryptionScope, // CPK-N
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob tags
&sequenceNumber, nil,
@ -77,7 +77,7 @@ func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int
// This method panics if the stream is not at position 0.
// Note that the http client closes the body stream after the request is sent to the service.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-page.
func (pb PageBlobURL) UploadPages(ctx context.Context, offset int64, body io.ReadSeeker, ac PageBlobAccessConditions, transactionalMD5 []byte) (*PageBlobUploadPagesResponse, error) {
func (pb PageBlobURL) UploadPages(ctx context.Context, offset int64, body io.ReadSeeker, ac PageBlobAccessConditions, transactionalMD5 []byte, cpk ClientProvidedKeyOptions) (*PageBlobUploadPagesResponse, error) {
count, err := validateSeekableStreamAt0AndGetCount(body)
if err != nil {
return nil, err
@ -87,8 +87,8 @@ func (pb PageBlobURL) UploadPages(ctx context.Context, offset int64, body io.Rea
return pb.pbClient.UploadPages(ctx, body, count, transactionalMD5, nil, nil,
PageRange{Start: offset, End: offset + count - 1}.pointers(),
ac.LeaseAccessConditions.pointers(),
nil, nil, EncryptionAlgorithmNone, // CPK
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
cpk.EncryptionScope, // CPK-N
ifSequenceNumberLessThanOrEqual, ifSequenceNumberLessThan, ifSequenceNumberEqual,
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
nil, // Blob ifTags
@ -100,14 +100,14 @@ func (pb PageBlobURL) UploadPages(ctx context.Context, offset int64, body io.Rea
// The destOffset specifies the start offset of data in page blob will be written to.
// The count must be a multiple of 512 bytes.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-page-from-url.
func (pb PageBlobURL) UploadPagesFromURL(ctx context.Context, sourceURL url.URL, sourceOffset int64, destOffset int64, count int64, transactionalMD5 []byte, destinationAccessConditions PageBlobAccessConditions, sourceAccessConditions ModifiedAccessConditions) (*PageBlobUploadPagesFromURLResponse, error) {
func (pb PageBlobURL) UploadPagesFromURL(ctx context.Context, sourceURL url.URL, sourceOffset int64, destOffset int64, count int64, transactionalMD5 []byte, destinationAccessConditions PageBlobAccessConditions, sourceAccessConditions ModifiedAccessConditions, cpk ClientProvidedKeyOptions) (*PageBlobUploadPagesFromURLResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := destinationAccessConditions.ModifiedAccessConditions.pointers()
sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatchETag, sourceIfNoneMatchETag := sourceAccessConditions.pointers()
ifSequenceNumberLessThanOrEqual, ifSequenceNumberLessThan, ifSequenceNumberEqual := destinationAccessConditions.SequenceNumberAccessConditions.pointers()
return pb.pbClient.UploadPagesFromURL(ctx, sourceURL.String(), *PageRange{Start: sourceOffset, End: sourceOffset + count - 1}.pointers(), 0,
*PageRange{Start: destOffset, End: destOffset + count - 1}.pointers(), transactionalMD5, nil, nil,
nil, nil, EncryptionAlgorithmNone, // CPK-V
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
cpk.EncryptionScope, // CPK-N
destinationAccessConditions.LeaseAccessConditions.pointers(),
ifSequenceNumberLessThanOrEqual, ifSequenceNumberLessThan, ifSequenceNumberEqual,
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
@ -117,14 +117,14 @@ func (pb PageBlobURL) UploadPagesFromURL(ctx context.Context, sourceURL url.URL,
// ClearPages frees the specified pages from the page blob.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-page.
func (pb PageBlobURL) ClearPages(ctx context.Context, offset int64, count int64, ac PageBlobAccessConditions) (*PageBlobClearPagesResponse, error) {
func (pb PageBlobURL) ClearPages(ctx context.Context, offset int64, count int64, ac PageBlobAccessConditions, cpk ClientProvidedKeyOptions) (*PageBlobClearPagesResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
ifSequenceNumberLessThanOrEqual, ifSequenceNumberLessThan, ifSequenceNumberEqual := ac.SequenceNumberAccessConditions.pointers()
return pb.pbClient.ClearPages(ctx, 0, nil,
PageRange{Start: offset, End: offset + count - 1}.pointers(),
ac.LeaseAccessConditions.pointers(),
nil, nil, EncryptionAlgorithmNone, // CPK
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
cpk.EncryptionScope, // CPK-N
ifSequenceNumberLessThanOrEqual, ifSequenceNumberLessThan,
ifSequenceNumberEqual, ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag, nil)
}
@ -170,15 +170,15 @@ func (pb PageBlobURL) GetPageRangesDiff(ctx context.Context, offset int64, count
// Resize resizes the page blob to the specified size (which must be a multiple of 512).
// For more information, see https://docs.microsoft.com/rest/api/storageservices/set-blob-properties.
func (pb PageBlobURL) Resize(ctx context.Context, size int64, ac BlobAccessConditions) (*PageBlobResizeResponse, error) {
func (pb PageBlobURL) Resize(ctx context.Context, size int64, ac BlobAccessConditions, cpk ClientProvidedKeyOptions) (*PageBlobResizeResponse, error) {
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
return pb.pbClient.Resize(ctx, size, nil, ac.LeaseAccessConditions.pointers(),
nil, nil, EncryptionAlgorithmNone, // CPK
nil, // CPK-N
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
cpk.EncryptionScope, // CPK-N
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag, nil)
}
// SetSequenceNumber sets the page blob's sequence number.
// UpdateSequenceNumber sets the page blob's sequence number.
func (pb PageBlobURL) UpdateSequenceNumber(ctx context.Context, action SequenceNumberActionType, sequenceNumber int64,
ac BlobAccessConditions) (*PageBlobUpdateSequenceNumberResponse, error) {
sn := &sequenceNumber
@ -191,7 +191,7 @@ func (pb PageBlobURL) UpdateSequenceNumber(ctx context.Context, action SequenceN
sn, nil)
}
// StartIncrementalCopy begins an operation to start an incremental copy from one page blob's snapshot to this page blob.
// StartCopyIncremental begins an operation to start an incremental copy from one page blob's snapshot to this page blob.
// The snapshot is copied such that only the differential changes between the previously copied snapshot are transferred to the destination.
// The copied snapshots are complete copies of the original snapshot and can be read or copied from as usual.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/incremental-copy-blob and

Просмотреть файл

@ -56,6 +56,8 @@ type RetryReaderOptions struct {
// from the same "thread" (goroutine) as Read. Concurrent Close calls from other goroutines may instead produce network errors
// which will be retried.
TreatEarlyCloseAsError bool
ClientProvidedKeyOptions ClientProvidedKeyOptions
}
// retryReader implements io.ReaderCloser methods.

Просмотреть файл

@ -114,6 +114,7 @@ const (
// ServiceCodeResourceNotFound means the specified resource does not exist (404).
ServiceCodeResourceNotFound ServiceCodeType = "ResourceNotFound"
// ServiceCodeNoAuthenticationInformation means the specified authentication for the resource does not exist (401).
ServiceCodeNoAuthenticationInformation ServiceCodeType = "NoAuthenticationInformation"
// ServiceCodeServerBusy means the server is currently unable to receive requests. Please retry your request or Ingress/egress is over the account limit or operations per second is over the account limit (503).

Просмотреть файл

@ -24,7 +24,7 @@ func (s *aztestsSuite) TestSetBlobTags(c *chk.C) {
"blob": "sdk",
"sdk": "go",
}
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
blobSetTagsResponse, err := blobURL.SetTags(ctx, nil, nil, nil, nil, nil, nil, blobTagsMap)
@ -50,12 +50,12 @@ func (s *aztestsSuite) TestSetBlobTagsWithVID(c *chk.C) {
"Python": "CSharp",
"Javascript": "Android",
}
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
versionId1 := blockBlobUploadResp.VersionID()
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
versionId2 := blockBlobUploadResp.VersionID()
@ -84,12 +84,12 @@ func (s *aztestsSuite) TestSetBlobTagsWithVID2(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
versionId1 := blockBlobUploadResp.VersionID()
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
versionId2 := blockBlobUploadResp.VersionID()
@ -139,7 +139,7 @@ func (s *aztestsSuite) TestUploadBlockBlobWithSpecialCharactersInTags(c *chk.C)
"tag2": "+-./:=_",
"+-./:=_1": "+-./:=_",
}
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
@ -169,7 +169,7 @@ func (s *aztestsSuite) TestStageBlockWithTags(c *chk.C) {
for index, d := range data {
base64BlockIDs[index] = blockIDIntToBase64(index)
resp, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(d), LeaseAccessConditions{}, nil)
resp, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(d), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
if err != nil {
c.Fail()
}
@ -182,12 +182,12 @@ func (s *aztestsSuite) TestStageBlockWithTags(c *chk.C) {
"blob": "sdk",
"sdk": "go",
}
commitResp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
commitResp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(commitResp.VersionID(), chk.NotNil)
versionId := commitResp.VersionID()
contentResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
contentResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
contentData, err := ioutil.ReadAll(contentResp.Body(RetryReaderOptions{}))
c.Assert(contentData, chk.DeepEquals, []uint8(strings.Join(data, "")))
@ -230,7 +230,7 @@ func (s *aztestsSuite) TestStageBlockFromURLWithTags(c *chk.C) {
"Javascript": "Android",
}
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
@ -251,7 +251,7 @@ func (s *aztestsSuite) TestStageBlockFromURLWithTags(c *chk.C) {
srcBlobURLWithSAS := srcBlobParts.URL()
blockID1, blockID2 := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 0))), base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 1)))
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 4*1024*1024, LeaseAccessConditions{}, ModifiedAccessConditions{})
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 4*1024*1024, LeaseAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(stageResp1.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp1.ContentMD5(), chk.Not(chk.Equals), "")
@ -259,7 +259,7 @@ func (s *aztestsSuite) TestStageBlockFromURLWithTags(c *chk.C) {
c.Assert(stageResp1.Version(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.Date().IsZero(), chk.Equals, false)
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 4*1024*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{})
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 4*1024*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(stageResp2.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp2.ContentMD5(), chk.Not(chk.Equals), "")
@ -273,12 +273,12 @@ func (s *aztestsSuite) TestStageBlockFromURLWithTags(c *chk.C) {
c.Assert(blockList.CommittedBlocks, chk.HasLen, 0)
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
listResp, err := destBlob.CommitBlockList(ctx, []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
listResp, err := destBlob.CommitBlockList(ctx, []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
//versionId := listResp.VersionID()
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -313,7 +313,7 @@ func (s *aztestsSuite) TestCopyBlockBlobFromURLWithTags(c *chk.C) {
"Javascript": "Android",
}
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
@ -344,7 +344,7 @@ func (s *aztestsSuite) TestCopyBlockBlobFromURLWithTags(c *chk.C) {
c.Assert(resp.ContentMD5(), chk.DeepEquals, sourceDataMD5Value[:])
c.Assert(string(resp.CopyStatus()), chk.DeepEquals, "success")
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -372,15 +372,15 @@ func (s *aztestsSuite) TestGetPropertiesReturnsTagsCount(c *chk.C) {
"blob": "sdk",
"sdk": "go",
}
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
getPropertiesResponse, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
getPropertiesResponse, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(getPropertiesResponse.TagCount(), chk.Equals, int64(3))
downloadResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(downloadResp, chk.NotNil)
c.Assert(downloadResp.r.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "3")
@ -399,11 +399,11 @@ func (s *aztestsSuite) TestSetBlobTagForSnapshot(c *chk.C) {
_, err := blobURL.SetTags(ctx, nil, nil, nil, nil, nil, nil, blobTagsMap)
c.Assert(err, chk.IsNil)
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.TagCount(), chk.Equals, int64(3))
}
@ -419,7 +419,7 @@ func (s *aztestsSuite) TestCreatePageBlobWithTags(c *chk.C) {
"sdk": "go",
}
blob, _ := createNewPageBlob(c, container)
putResp, err := blob.UploadPages(ctx, 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil)
putResp, err := blob.UploadPages(ctx, 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(putResp.Response().StatusCode, chk.Equals, 201)
c.Assert(putResp.LastModified().IsZero(), chk.Equals, false)
@ -431,7 +431,7 @@ func (s *aztestsSuite) TestCreatePageBlobWithTags(c *chk.C) {
c.Assert(err, chk.IsNil)
c.Assert(setTagResp.StatusCode(), chk.Equals, 204)
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{})
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(gpResp, chk.NotNil)
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "3")
@ -445,7 +445,7 @@ func (s *aztestsSuite) TestCreatePageBlobWithTags(c *chk.C) {
c.Assert(err, chk.IsNil)
c.Assert(setTagResp.StatusCode(), chk.Equals, 204)
gpResp, err = blob.GetProperties(ctx, BlobAccessConditions{})
gpResp, err = blob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(gpResp, chk.NotNil)
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "2")
@ -462,11 +462,11 @@ func (s *aztestsSuite) TestSetTagOnPageBlob(c *chk.C) {
"blob": "sdk",
"sdk": "go",
}
resp, err := blob.Create(ctx, PageBlobPageBytes*10, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, blobTagsMap)
resp, err := blob.Create(ctx, PageBlobPageBytes*10, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, blobTagsMap, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{})
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(gpResp, chk.NotNil)
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "3")
@ -480,7 +480,7 @@ func (s *aztestsSuite) TestSetTagOnPageBlob(c *chk.C) {
c.Assert(err, chk.IsNil)
c.Assert(setTagResp.StatusCode(), chk.Equals, 204)
gpResp, err = blob.GetProperties(ctx, BlobAccessConditions{})
gpResp, err = blob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(gpResp, chk.NotNil)
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "2")
@ -492,11 +492,11 @@ func (s *aztestsSuite) TestCreateAppendBlobWithTags(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
blobProp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
createResp, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: blobProp.ETag()}}, nil)
blobProp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
createResp, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: blobProp.ETag()}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(createResp.VersionID(), chk.NotNil)
blobProp, _ = blobURL.GetProperties(ctx, BlobAccessConditions{})
blobProp, _ = blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(createResp.VersionID(), chk.Equals, blobProp.VersionID())
c.Assert(createResp.LastModified(), chk.DeepEquals, blobProp.LastModified())
c.Assert(createResp.ETag(), chk.Equals, blobProp.ETag())
@ -546,21 +546,21 @@ func (s *aztestsSuite) TestFindBlobsByTags(c *chk.C) {
"tag3": "thirdtag",
}
blobURL11, _ := getBlockBlobURL(c, containerURL1)
_, err := blobURL11.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap1)
_, err := blobURL11.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap1, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
blobURL12, _ := getBlockBlobURL(c, containerURL1)
_, err = blobURL12.Upload(ctx, bytes.NewReader([]byte("another random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap2)
_, err = blobURL12.Upload(ctx, bytes.NewReader([]byte("another random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap2, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
blobURL21, _ := getBlockBlobURL(c, containerURL2)
_, err = blobURL21.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL21.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
blobURL22, _ := getBlockBlobURL(c, containerURL2)
_, err = blobURL22.Upload(ctx, bytes.NewReader([]byte("another random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap2)
_, err = blobURL22.Upload(ctx, bytes.NewReader([]byte("another random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap2, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
blobURL31, _ := getBlockBlobURL(c, containerURL3)
_, err = blobURL31.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL31.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
where := "\"tag4\"='fourthtag'"
@ -612,7 +612,7 @@ func (s *aztestsSuite) TestFilterBlobsUsingAccountSAS(c *chk.C) {
}
blobURL := containerURL.NewBlockBlobURL("temp")
_, err = blobURL.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
c.Fail()
}

Просмотреть файл

@ -21,11 +21,11 @@ func (s *aztestsSuite) TestGetBlobPropertiesUsingVID(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
blobProp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
createResp, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: blobProp.ETag()}}, nil)
blobProp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
createResp, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: blobProp.ETag()}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(createResp.VersionID(), chk.NotNil)
blobProp, _ = blobURL.GetProperties(ctx, BlobAccessConditions{})
blobProp, _ = blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(createResp.VersionID(), chk.Equals, blobProp.VersionID())
c.Assert(createResp.LastModified(), chk.DeepEquals, blobProp.LastModified())
c.Assert(createResp.ETag(), chk.Equals, blobProp.ETag())
@ -38,7 +38,7 @@ func (s *aztestsSuite) TestSetBlobMetadataReturnsVID(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, blobName := createNewBlockBlob(c, containerURL)
metadata := Metadata{"test_key_1": "test_value_1", "test_key_2": "2019"}
resp, err := blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{})
resp, err := blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.VersionID(), chk.NotNil)
@ -58,11 +58,11 @@ func (s *aztestsSuite) TestCreateAndDownloadBlobSpecialCharactersWithVID(c *chk.
for i := 0; i < len(data); i++ {
blobName := "abc" + string(data[i])
blobURL := containerURL.NewBlockBlobURL(blobName)
resp, err := blobURL.Upload(ctx, strings.NewReader(string(data[i])), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
resp, err := blobURL.Upload(ctx, strings.NewReader(string(data[i])), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.VersionID(), chk.NotNil)
dResp, err := blobURL.WithVersionID(resp.VersionID()).Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
dResp, err := blobURL.WithVersionID(resp.VersionID()).Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
d1, err := ioutil.ReadAll(dResp.Body(RetryReaderOptions{}))
c.Assert(dResp.Version(), chk.Not(chk.Equals), "")
@ -79,12 +79,12 @@ func (s *aztestsSuite) TestDeleteSpecificBlobVersion(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.VersionID(), chk.NotNil)
versionID1 := blockBlobUploadResp.VersionID()
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp.VersionID(), chk.NotNil)
@ -115,12 +115,12 @@ func (s *aztestsSuite) TestDeleteSpecificBlobVersionWithBlobSAS(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, blobName := getBlockBlobURL(c, containerURL)
resp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
resp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
versionId := resp.VersionID()
c.Assert(versionId, chk.NotNil)
resp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
resp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.VersionID(), chk.NotNil)
@ -154,12 +154,12 @@ func (s *aztestsSuite) TestDownloadSpecificBlobVersion(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp, chk.NotNil)
versionId1 := blockBlobUploadResp.VersionID()
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(blockBlobUploadResp, chk.NotNil)
versionId2 := blockBlobUploadResp.VersionID()
@ -167,14 +167,14 @@ func (s *aztestsSuite) TestDownloadSpecificBlobVersion(c *chk.C) {
// Download previous version of snapshot.
blobURL = blobURL.WithVersionID(versionId1)
blockBlobDeleteResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
blockBlobDeleteResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(blockBlobDeleteResp.Response().Body)
c.Assert(string(data), chk.Equals, "data")
// Download current version of snapshot.
blobURL = blobURL.WithVersionID(versionId2)
blockBlobDeleteResp, err = blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
blockBlobDeleteResp, err = blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err = ioutil.ReadAll(blockBlobDeleteResp.Response().Body)
c.Assert(string(data), chk.Equals, "updated_data")
@ -185,11 +185,11 @@ func (s *aztestsSuite) TestCreateBlobSnapshotReturnsVID(c *chk.C) {
containerURL, _ := createNewContainer(c, bsu)
defer delContainer(c, containerURL)
blobURL := containerURL.NewBlockBlobURL(generateBlobName())
uploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
uploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadResp.VersionID(), chk.NotNil)
csResp, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
csResp, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(csResp.VersionID(), chk.NotNil)
lbResp, err := containerURL.ListBlobsFlatSegment(ctx, Marker{}, ListBlobsSegmentOptions{
@ -229,7 +229,7 @@ func (s *aztestsSuite) TestCopyBlobFromURLWithSASReturnsVID(c *chk.C) {
srcBlob := container.NewBlockBlobURL(generateBlobName())
destBlob := container.NewBlockBlobURL(generateBlobName())
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
c.Assert(uploadSrcResp.Response().Header.Get("x-ms-version-id"), chk.NotNil)
@ -257,7 +257,7 @@ func (s *aztestsSuite) TestCopyBlobFromURLWithSASReturnsVID(c *chk.C) {
c.Assert(string(resp.CopyStatus()), chk.DeepEquals, "success")
c.Assert(resp.VersionID(), chk.NotNil)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -287,13 +287,13 @@ func (s *aztestsSuite) TestCreateBlockBlobReturnsVID(c *chk.C) {
blobURL := containerURL.NewBlockBlobURL(generateBlobName())
// Prepare source blob for copy.
uploadResp, err := blobURL.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
uploadResp, err := blobURL.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
c.Assert(uploadResp.rawResponse.Header.Get("x-ms-version"), chk.Equals, ServiceVersion)
c.Assert(uploadResp.Response().Header.Get("x-ms-version-id"), chk.NotNil)
csResp, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
csResp, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(csResp.Response().StatusCode, chk.Equals, 201)
c.Assert(csResp.Response().Header.Get("x-ms-version-id"), chk.NotNil)
@ -337,7 +337,7 @@ func (s *aztestsSuite) TestPutBlockListReturnsVID(c *chk.C) {
for index, d := range data {
base64BlockIDs[index] = blockIDIntToBase64(index)
resp, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(d), LeaseAccessConditions{}, nil)
resp, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(d), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
if err != nil {
c.Fail()
}
@ -345,11 +345,11 @@ func (s *aztestsSuite) TestPutBlockListReturnsVID(c *chk.C) {
c.Assert(resp.Version(), chk.Not(chk.Equals), "")
}
commitResp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
commitResp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(commitResp.VersionID(), chk.NotNil)
contentResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
contentResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
contentData, err := ioutil.ReadAll(contentResp.Body(RetryReaderOptions{}))
c.Assert(contentData, chk.DeepEquals, []uint8(strings.Join(data, "")))
@ -365,7 +365,7 @@ func (s *aztestsSuite) TestCreatePageBlobReturnsVID(c *chk.C) {
defer delContainer(c, container)
blob, _ := createNewPageBlob(c, container)
putResp, err := blob.UploadPages(context.Background(), 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil)
putResp, err := blob.UploadPages(context.Background(), 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(putResp.Response().StatusCode, chk.Equals, 201)
c.Assert(putResp.LastModified().IsZero(), chk.Equals, false)
@ -373,7 +373,7 @@ func (s *aztestsSuite) TestCreatePageBlobReturnsVID(c *chk.C) {
c.Assert(putResp.Version(), chk.Not(chk.Equals), "")
c.Assert(putResp.rawResponse.Header.Get("x-ms-version-id"), chk.NotNil)
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{})
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(gpResp, chk.NotNil)
}

Просмотреть файл

@ -0,0 +1,738 @@
package azblob
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"encoding/binary"
"io/ioutil"
"strconv"
"strings"
"time"
chk "gopkg.in/check.v1" // go get gopkg.in/check.v1
)
/*
Azure Storage supports following operations support of sending customer-provided encryption keys on a request:
Put Blob, Put Block List, Put Block, Put Block from URL, Put Page, Put Page from URL, Append Block,
Set Blob Properties, Set Blob Metadata, Get Blob, Get Blob Properties, Get Blob Metadata, Snapshot Blob.
*/
var testEncryptedKey = "MDEyMzQ1NjcwMTIzNDU2NzAxMjM0NTY3MDEyMzQ1Njc="
var testEncryptedHash = "3QFFFpRA5+XANHqwwbT4yXDmrT/2JaLt/FKHjzhOdoE="
var testEncryptedScope = ""
var testCPK = NewClientProvidedKeyOptions(&testEncryptedKey, &testEncryptedHash, &testEncryptedScope)
var testEncryptedScope1 = "blobgokeytestscope"
var testCPK1 = ClientProvidedKeyOptions{EncryptionScope: &testEncryptedScope1}
func blockIDBinaryToBase64(blockID []byte) string {
return base64.StdEncoding.EncodeToString(blockID)
}
func blockIDBase64ToBinary(blockID string) []byte {
binary, _ := base64.StdEncoding.DecodeString(blockID)
return binary
}
// blockIDIntToBase64 functions convert an int block ID to a base-64 string and vice versa
func blockIDIntToBase64(blockID int) string {
binaryBlockID := (&[4]byte{})[:] // All block IDs are 4 bytes long
binary.LittleEndian.PutUint32(binaryBlockID, uint32(blockID))
return blockIDBinaryToBase64(binaryBlockID)
}
//func blockIDBase64ToInt(blockID string) int {
// blockIDBase64ToBinary(blockID)
// return int(binary.LittleEndian.Uint32(blockIDBase64ToBinary(blockID)))
//}
func (s *aztestsSuite) TestPutBlockAndPutBlockListWithCPK(c *chk.C) {
bsu := getBSU()
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
blobURL := container.NewBlockBlobURL(generateBlobName())
words := []string{"AAA ", "BBB ", "CCC "}
base64BlockIDs := make([]string, len(words))
for index, word := range words {
base64BlockIDs[index] = blockIDIntToBase64(index)
_, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(word), LeaseAccessConditions{}, nil, testCPK)
c.Assert(err, chk.IsNil)
}
resp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(resp.ETag(), chk.NotNil)
c.Assert(resp.LastModified(), chk.NotNil)
c.Assert(resp.IsServerEncrypted(), chk.Equals, "true")
c.Assert(resp.EncryptionKeySha256(), chk.DeepEquals, *(testCPK.EncryptionKeySha256))
// Get blob content without encryption key should fail the request.
_, err = blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
// Download blob to do data integrity check.
getResp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
b := bytes.Buffer{}
reader := getResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK})
b.ReadFrom(reader)
reader.Close() // The client must close the response body when finished with it
c.Assert(b.String(), chk.Equals, "AAA BBB CCC ")
c.Assert(getResp.ETag(), chk.Equals, resp.ETag())
c.Assert(getResp.LastModified(), chk.DeepEquals, resp.LastModified())
}
func (s *aztestsSuite) TestPutBlockAndPutBlockListWithCPKByScope(c *chk.C) {
bsu := getBSU()
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
blobURL := container.NewBlockBlobURL(generateBlobName())
words := []string{"AAA ", "BBB ", "CCC "}
base64BlockIDs := make([]string, len(words))
for index, word := range words {
base64BlockIDs[index] = blockIDIntToBase64(index)
_, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(word), LeaseAccessConditions{}, nil, testCPK1)
c.Assert(err, chk.IsNil)
}
resp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(resp.ETag(), chk.NotNil)
c.Assert(resp.LastModified(), chk.NotNil)
c.Assert(resp.IsServerEncrypted(), chk.Equals, "true")
c.Assert(resp.EncryptionScope(), chk.Equals, *(testCPK1.EncryptionScope))
getResp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.NotNil)
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 409)
c.Assert(serr.ServiceCode(), chk.Equals, ServiceCodeFeatureEncryptionMismatch)
getResp, err = blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
b := bytes.Buffer{}
reader := getResp.Body(RetryReaderOptions{})
b.ReadFrom(reader)
reader.Close() // The client must close the response body when finished with it
c.Assert(b.String(), chk.Equals, "AAA BBB CCC ")
c.Assert(getResp.ETag(), chk.Equals, resp.ETag())
c.Assert(getResp.LastModified(), chk.DeepEquals, resp.LastModified())
c.Assert(getResp.LastModified(), chk.DeepEquals, resp.LastModified())
c.Assert(getResp.r.rawResponse.Header.Get("x-ms-encryption-scope"), chk.Equals, *(testCPK1.EncryptionScope))
// Download blob to do data integrity check.
getResp, err = blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, testCPK1)
c.Assert(err, chk.IsNil)
b = bytes.Buffer{}
reader = getResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK1})
b.ReadFrom(reader)
reader.Close() // The client must close the response body when finished with it
c.Assert(b.String(), chk.Equals, "AAA BBB CCC ")
c.Assert(getResp.ETag(), chk.Equals, resp.ETag())
c.Assert(getResp.LastModified(), chk.DeepEquals, resp.LastModified())
c.Assert(getResp.r.rawResponse.Header.Get("x-ms-encryption-scope"), chk.Equals, *(testCPK1.EncryptionScope))
}
func (s *aztestsSuite) TestPutBlockFromURLAndCommitWithCPK(c *chk.C) {
bsu := getBSU()
credential, err := getGenericCredential("")
if err != nil {
c.Fatal("Invalid credential")
}
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
testSize := 2 * 1024 // 2KB
r, srcData := getRandomDataAndReader(testSize)
ctx := context.Background()
blobURL := container.NewBlockBlobURL(generateBlobName())
uploadSrcResp, err := blobURL.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
srcBlobParts := NewBlobURLParts(blobURL.URL())
srcBlobParts.SAS, err = BlobSASSignatureValues{
Protocol: SASProtocolHTTPS,
ExpiryTime: time.Now().UTC().Add(1 * time.Hour),
ContainerName: srcBlobParts.ContainerName,
BlobName: srcBlobParts.BlobName,
Permissions: BlobSASPermissions{Read: true}.String(),
}.NewSASQueryParameters(credential)
if err != nil {
c.Fatal(err)
}
srcBlobURLWithSAS := srcBlobParts.URL()
destBlob := container.NewBlockBlobURL(generateBlobName())
blockID1, blockID2 := blockIDIntToBase64(0), blockIDIntToBase64(1)
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 1*1024, LeaseAccessConditions{}, ModifiedAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(stageResp1.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp1.ContentMD5(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.RequestID(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.Version(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.Date().IsZero(), chk.Equals, false)
c.Assert(stageResp1.IsServerEncrypted(), chk.Equals, "true")
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 1*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(stageResp2.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp2.ContentMD5(), chk.Not(chk.Equals), "")
c.Assert(stageResp2.RequestID(), chk.Not(chk.Equals), "")
c.Assert(stageResp2.Version(), chk.Not(chk.Equals), "")
c.Assert(stageResp2.Date().IsZero(), chk.Equals, false)
c.Assert(stageResp2.IsServerEncrypted(), chk.Equals, "true")
blockList, err := destBlob.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
c.Assert(blockList.Response().StatusCode, chk.Equals, 200)
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
c.Assert(blockList.CommittedBlocks, chk.HasLen, 0)
listResp, err := destBlob.CommitBlockList(ctx, []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
c.Assert(listResp.IsServerEncrypted(), chk.Equals, "true")
blockList, err = destBlob.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
c.Assert(blockList.Response().StatusCode, chk.Equals, 200)
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 0)
c.Assert(blockList.CommittedBlocks, chk.HasLen, 2)
// Get blob content without encryption key should fail the request.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
// Download blob to do data integrity check.
downloadResp, err = destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, srcData)
}
func (s *aztestsSuite) TestPutBlockFromURLAndCommitWithCPKWithScope(c *chk.C) {
bsu := getBSU()
credential, err := getGenericCredential("")
if err != nil {
c.Fatal("Invalid credential")
}
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
testSize := 2 * 1024 // 2KB
r, srcData := getRandomDataAndReader(testSize)
ctx := context.Background()
blobURL := container.NewBlockBlobURL(generateBlobName())
uploadSrcResp, err := blobURL.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
srcBlobParts := NewBlobURLParts(blobURL.URL())
srcBlobParts.SAS, err = BlobSASSignatureValues{
Protocol: SASProtocolHTTPS,
ExpiryTime: time.Now().UTC().Add(1 * time.Hour),
ContainerName: srcBlobParts.ContainerName,
BlobName: srcBlobParts.BlobName,
Permissions: BlobSASPermissions{Read: true}.String(),
}.NewSASQueryParameters(credential)
if err != nil {
c.Fatal(err)
}
srcBlobURLWithSAS := srcBlobParts.URL()
destBlob := container.NewBlockBlobURL(generateBlobName())
blockID1, blockID2 := blockIDIntToBase64(0), blockIDIntToBase64(1)
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 1*1024, LeaseAccessConditions{}, ModifiedAccessConditions{}, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(stageResp1.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp1.ContentMD5(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.RequestID(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.Version(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.Date().IsZero(), chk.Equals, false)
c.Assert(stageResp1.IsServerEncrypted(), chk.Equals, "true")
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 1*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{}, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(stageResp2.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp2.ContentMD5(), chk.Not(chk.Equals), "")
c.Assert(stageResp2.RequestID(), chk.Not(chk.Equals), "")
c.Assert(stageResp2.Version(), chk.Not(chk.Equals), "")
c.Assert(stageResp2.Date().IsZero(), chk.Equals, false)
c.Assert(stageResp2.IsServerEncrypted(), chk.Equals, "true")
blockList, err := destBlob.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
c.Assert(blockList.Response().StatusCode, chk.Equals, 200)
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
c.Assert(blockList.CommittedBlocks, chk.HasLen, 0)
listResp, err := destBlob.CommitBlockList(ctx, []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
c.Assert(listResp.IsServerEncrypted(), chk.Equals, "true")
c.Assert(listResp.EncryptionScope(), chk.Equals, *(testCPK1.EncryptionScope))
blockList, err = destBlob.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
c.Assert(blockList.Response().StatusCode, chk.Equals, 200)
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 0)
c.Assert(blockList.CommittedBlocks, chk.HasLen, 2)
// Download blob to do data integrity check.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK1)
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, srcData)
c.Assert(downloadResp.r.rawResponse.Header.Get("x-ms-encryption-scope"), chk.Equals, *(testCPK1.EncryptionScope))
}
func (s *aztestsSuite) TestUploadBlobWithMD5WithCPK(c *chk.C) {
bsu := getBSU()
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
testSize := 1 * 1024 * 1024
r, srcData := getRandomDataAndReader(testSize)
md5Val := md5.Sum(srcData)
blobURL := container.NewBlockBlobURL(generateBlobName())
uploadSrcResp, err := blobURL.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
// Get blob content without encryption key should fail the request.
downloadResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
// Download blob to do data integrity check.
downloadResp, err = blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(downloadResp.ContentMD5(), chk.DeepEquals, md5Val[:])
data, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
c.Assert(data, chk.DeepEquals, srcData)
}
func (s *aztestsSuite) TestAppendBlockWithCPK(c *chk.C) {
bsu := getBSU()
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
appendBlobURL := container.NewAppendBlobURL(generateBlobName())
resp, err := appendBlobURL.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
words := []string{"AAA ", "BBB ", "CCC "}
for index, word := range words {
resp, err := appendBlobURL.AppendBlock(context.Background(), strings.NewReader(word), AppendBlobAccessConditions{}, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(err, chk.IsNil)
c.Assert(resp.Response().StatusCode, chk.Equals, 201)
c.Assert(resp.BlobAppendOffset(), chk.Equals, strconv.Itoa(index*4))
c.Assert(resp.BlobCommittedBlockCount(), chk.Equals, int32(index+1))
c.Assert(resp.ETag(), chk.Not(chk.Equals), ETagNone)
c.Assert(resp.LastModified().IsZero(), chk.Equals, false)
c.Assert(resp.ContentMD5(), chk.Not(chk.Equals), "")
c.Assert(resp.RequestID(), chk.Not(chk.Equals), "")
c.Assert(resp.Version(), chk.Not(chk.Equals), "")
c.Assert(resp.Date().IsZero(), chk.Equals, false)
c.Assert(resp.IsServerEncrypted(), chk.Equals, "true")
c.Assert(resp.EncryptionKeySha256(), chk.Equals, *(testCPK.EncryptionKeySha256))
}
// Get blob content without encryption key should fail the request.
_, err = appendBlobURL.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
// Download blob to do data integrity check.
downloadResp, err := appendBlobURL.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
c.Assert(string(data), chk.DeepEquals, "AAA BBB CCC ")
}
func (s *aztestsSuite) TestAppendBlockWithCPKByScope(c *chk.C) {
bsu := getBSU()
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
appendBlobURL := container.NewAppendBlobURL(generateBlobName())
resp, err := appendBlobURL.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
words := []string{"AAA ", "BBB ", "CCC "}
for index, word := range words {
resp, err := appendBlobURL.AppendBlock(context.Background(), strings.NewReader(word), AppendBlobAccessConditions{}, nil, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(err, chk.IsNil)
c.Assert(resp.Response().StatusCode, chk.Equals, 201)
c.Assert(resp.BlobAppendOffset(), chk.Equals, strconv.Itoa(index*4))
c.Assert(resp.BlobCommittedBlockCount(), chk.Equals, int32(index+1))
c.Assert(resp.ETag(), chk.Not(chk.Equals), ETagNone)
c.Assert(resp.LastModified().IsZero(), chk.Equals, false)
c.Assert(resp.ContentMD5(), chk.Not(chk.Equals), "")
c.Assert(resp.RequestID(), chk.Not(chk.Equals), "")
c.Assert(resp.Version(), chk.Not(chk.Equals), "")
c.Assert(resp.Date().IsZero(), chk.Equals, false)
c.Assert(resp.IsServerEncrypted(), chk.Equals, "true")
c.Assert(resp.EncryptionScope(), chk.Equals, *(testCPK1.EncryptionScope))
}
// Download blob to do data integrity check.
downloadResp, err := appendBlobURL.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(downloadResp.IsServerEncrypted(), chk.Equals, "true")
data, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK1}))
c.Assert(err, chk.IsNil)
c.Assert(string(data), chk.DeepEquals, "AAA BBB CCC ")
c.Assert(downloadResp.r.rawResponse.Header.Get("x-ms-encryption-scope"), chk.Equals, *(testCPK1.EncryptionScope))
}
func (s *aztestsSuite) TestAppendBlockFromURLWithCPK(c *chk.C) {
bsu := getBSU()
credential, err := getGenericCredential("")
if err != nil {
c.Fatal("Invalid credential")
}
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
testSize := 2 * 1024 * 1024 // 2MB
r, srcData := getRandomDataAndReader(testSize)
ctx := context.Background() // Use default Background context
blobURL := container.NewAppendBlobURL(generateName("src"))
destBlob := container.NewAppendBlobURL(generateName("dest"))
cResp1, err := blobURL.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(cResp1.StatusCode(), chk.Equals, 201)
resp, err := blobURL.AppendBlock(context.Background(), r, AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ETag(), chk.Not(chk.Equals), ETagNone)
c.Assert(resp.LastModified().IsZero(), chk.Equals, false)
c.Assert(resp.ContentMD5(), chk.Not(chk.Equals), "")
srcBlobParts := NewBlobURLParts(blobURL.URL())
srcBlobParts.SAS, err = BlobSASSignatureValues{
Protocol: SASProtocolHTTPS,
ExpiryTime: time.Now().UTC().Add(1 * time.Hour),
ContainerName: srcBlobParts.ContainerName,
BlobName: srcBlobParts.BlobName,
Permissions: BlobSASPermissions{Read: true}.String(),
}.NewSASQueryParameters(credential)
if err != nil {
c.Fatal(err)
}
srcBlobURLWithSAS := srcBlobParts.URL()
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(cResp2.StatusCode(), chk.Equals, 201)
appendResp, err := destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(appendResp.ETag(), chk.Not(chk.Equals), ETagNone)
c.Assert(appendResp.LastModified().IsZero(), chk.Equals, false)
c.Assert(appendResp.IsServerEncrypted(), chk.Equals, "true")
// Get blob content without encryption key should fail the request.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
// Download blob to do data integrity check.
downloadResp, err = destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, srcData)
}
func (s *aztestsSuite) TestPageBlockWithCPK(c *chk.C) {
bsu := getBSU()
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
testSize := 1 * 1024 * 1024
r, srcData := getRandomDataAndReader(testSize)
blobURL, _ := createNewPageBlobWithCPK(c, container, int64(testSize), testCPK)
uploadResp, err := blobURL.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
// Get blob content without encryption key should fail the request.
downloadResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
// Download blob to do data integrity check.
downloadResp, err = blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, srcData)
}
func (s *aztestsSuite) TestPageBlockWithCPKByScope(c *chk.C) {
bsu := getBSU()
container, _ := createNewContainer(c, bsu)
// defer delContainer(c, container)
testSize := 1 * 1024 * 1024
r, srcData := getRandomDataAndReader(testSize)
blobURL, _ := createNewPageBlobWithCPK(c, container, int64(testSize), testCPK1)
uploadResp, err := blobURL.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
c.Assert(uploadResp.EncryptionScope(), chk.Equals, *(testCPK1.EncryptionScope))
// Download blob to do data integrity check.
downloadResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK1)
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK1}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, srcData)
c.Assert(downloadResp.r.rawResponse.Header.Get("x-ms-encryption-scope"), chk.Equals, *(testCPK1.EncryptionScope))
}
func (s *aztestsSuite) TestPageBlockFromURLWithCPK(c *chk.C) {
bsu := getBSU()
credential, err := getGenericCredential("")
if err != nil {
c.Fatal("Invalid credential")
}
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
testSize := 1 * 1024 * 1024 // 1MB
r, srcData := getRandomDataAndReader(testSize)
ctx := context.Background() // Use default Background context
blobURL, _ := createNewPageBlobWithSize(c, container, int64(testSize))
destBlob, _ := createNewPageBlobWithCPK(c, container, int64(testSize), testCPK)
uploadResp, err := blobURL.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
srcBlobParts := NewBlobURLParts(blobURL.URL())
srcBlobParts.SAS, err = BlobSASSignatureValues{
Protocol: SASProtocolHTTPS,
ExpiryTime: time.Now().UTC().Add(1 * time.Hour),
ContainerName: srcBlobParts.ContainerName,
BlobName: srcBlobParts.BlobName,
Permissions: BlobSASPermissions{Read: true}.String(),
}.NewSASQueryParameters(credential)
if err != nil {
c.Fatal(err)
}
srcBlobURLWithSAS := srcBlobParts.URL()
resp, err := destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), nil, PageBlobAccessConditions{}, ModifiedAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(resp.ETag(), chk.NotNil)
c.Assert(resp.LastModified(), chk.NotNil)
c.Assert(resp.Response().StatusCode, chk.Equals, 201)
c.Assert(resp.IsServerEncrypted(), chk.Equals, "true")
// Download blob to do data integrity check.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(downloadResp.r.EncryptionKeySha256(), chk.Equals, *(testCPK.EncryptionKeySha256))
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, srcData)
}
func (s *aztestsSuite) TestUploadPagesFromURLWithMD5WithCPK(c *chk.C) {
bsu := getBSU()
credential, err := getGenericCredential("")
if err != nil {
c.Fatal("Invalid credential")
}
container, _ := createNewContainer(c, bsu)
defer delContainer(c, container)
testSize := 1 * 1024 * 1024
r, srcData := getRandomDataAndReader(testSize)
md5Value := md5.Sum(srcData)
srcBlob, _ := createNewPageBlobWithSize(c, container, int64(testSize))
uploadSrcResp1, err := srcBlob.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp1.Response().StatusCode, chk.Equals, 201)
srcBlobParts := NewBlobURLParts(srcBlob.URL())
srcBlobParts.SAS, err = BlobSASSignatureValues{
Protocol: SASProtocolHTTPS,
ExpiryTime: time.Now().UTC().Add(1 * time.Hour),
ContainerName: srcBlobParts.ContainerName,
BlobName: srcBlobParts.BlobName,
Permissions: BlobSASPermissions{Read: true}.String(),
}.NewSASQueryParameters(credential)
if err != nil {
c.Fatal(err)
}
srcBlobURLWithSAS := srcBlobParts.URL()
destBlob, _ := createNewPageBlobWithCPK(c, container, int64(testSize), testCPK)
uploadResp, err := destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), md5Value[:], PageBlobAccessConditions{}, ModifiedAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(uploadResp.ETag(), chk.NotNil)
c.Assert(uploadResp.LastModified(), chk.NotNil)
c.Assert(uploadResp.EncryptionKeySha256(), chk.Equals, *(testCPK.EncryptionKeySha256))
c.Assert(uploadResp.ContentMD5(), chk.DeepEquals, md5Value[:])
c.Assert(uploadResp.BlobSequenceNumber(), chk.Equals, int64(0))
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(downloadResp.r.EncryptionKeySha256(), chk.Equals, *(testCPK.EncryptionKeySha256))
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{ClientProvidedKeyOptions: testCPK}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, srcData)
_, badMD5 := getRandomDataAndReader(16)
_, err = destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), badMD5[:], PageBlobAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeMd5Mismatch)
}
func (s *aztestsSuite) TestGetSetBlobMetadataWithCPK(c *chk.C) {
bsu := getBSU()
containerURL, _ := createNewContainer(c, bsu)
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlobWithCPK(c, containerURL, testCPK)
metadata := Metadata{"key": "value", "another_key": "1234"}
// Set blob metadata without encryption key should fail the request.
_, err := blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
resp, err := blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(resp.EncryptionKeySha256(), chk.Equals, *(testCPK.EncryptionKeySha256))
// Get blob properties without encryption key should fail the request.
getResp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
getResp, err = blobURL.GetProperties(ctx, BlobAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(getResp.NewMetadata(), chk.HasLen, 2)
c.Assert(getResp.NewMetadata(), chk.DeepEquals, metadata)
_, err = blobURL.SetMetadata(ctx, Metadata{}, BlobAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
getResp, err = blobURL.GetProperties(ctx, BlobAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(getResp.NewMetadata(), chk.HasLen, 0)
}
func (s *aztestsSuite) TestGetSetBlobMetadataWithCPKByScope(c *chk.C) {
bsu := getBSU()
containerURL, _ := createNewContainer(c, bsu)
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlobWithCPK(c, containerURL, testCPK1)
metadata := Metadata{"key": "value", "another_key": "1234"}
// Set blob metadata without encryption key should fail the request.
_, err := blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
_, err = blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{}, testCPK1)
c.Assert(err, chk.IsNil)
getResp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(getResp.NewMetadata(), chk.HasLen, 2)
c.Assert(getResp.NewMetadata(), chk.DeepEquals, metadata)
_, err = blobURL.SetMetadata(ctx, Metadata{}, BlobAccessConditions{}, testCPK1)
c.Assert(err, chk.IsNil)
getResp, err = blobURL.GetProperties(ctx, BlobAccessConditions{}, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(getResp.NewMetadata(), chk.HasLen, 0)
}
func (s *aztestsSuite) TestBlobSnapshotWithCPK(c *chk.C) {
bsu := getBSU()
containerURL, _ := createNewContainer(c, bsu)
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlobWithCPK(c, containerURL, testCPK)
_, err := blobURL.Upload(ctx, strings.NewReader("113333555555"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, testCPK)
// Create Snapshot of an encrypted blob without encryption key should fail the request.
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
resp, err = blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(resp.IsServerEncrypted(), chk.Equals, "false")
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
dResp, err := snapshotURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK)
c.Assert(err, chk.IsNil)
c.Assert(dResp.r.EncryptionKeySha256(), chk.Equals, *(testCPK.EncryptionKeySha256))
_, err = snapshotURL.Delete(ctx, DeleteSnapshotsOptionNone, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
// Get blob properties of snapshot without encryption key should fail the request.
_, err = snapshotURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
c.Assert(err.(StorageError).Response().StatusCode, chk.Equals, 404)
}
func (s *aztestsSuite) TestBlobSnapshotWithCPKByScope(c *chk.C) {
bsu := getBSU()
containerURL, _ := createNewContainer(c, bsu)
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlobWithCPK(c, containerURL, testCPK)
_, err := blobURL.Upload(ctx, strings.NewReader("113333555555"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, testCPK1)
// Create Snapshot of an encrypted blob without encryption key should fail the request.
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
resp, err = blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, testCPK1)
c.Assert(err, chk.IsNil)
c.Assert(resp.IsServerEncrypted(), chk.Equals, "false")
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
_, err = snapshotURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, testCPK1)
c.Assert(err, chk.IsNil)
_, err = snapshotURL.Delete(ctx, DeleteSnapshotsOptionNone, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
// Get blob properties of snapshot without encryption key should fail the request.
_, err = snapshotURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
c.Assert(err.(StorageError).Response().StatusCode, chk.Equals, 404)
}

Просмотреть файл

@ -72,13 +72,13 @@ func Example() {
// Create the blob with string (plain text) content.
data := "Hello World!"
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
// Download the blob's contents and verify that it worked correctly
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -429,7 +429,7 @@ func ExampleContainerURL_SetContainerAccessPolicy() {
blobURL := containerURL.NewBlockBlobURL("HelloWorld.txt") // Blob names can be mixed case
// Create the blob and put some text in it
_, err = blobURL.Upload(ctx, strings.NewReader("Hello World!"), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, strings.NewReader("Hello World!"), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -493,27 +493,24 @@ func ExampleBlobAccessConditions() {
}
// Create the blob (unconditionally; succeeds)
upload, err := blobURL.Upload(ctx, strings.NewReader("Text-1"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
upload, err := blobURL.Upload(ctx, strings.NewReader("Text-1"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
showResult(upload, err)
// Download blob content if the blob has been modified since we uploaded it (fails):
showResult(blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: upload.LastModified()}}, false))
showResult(blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: upload.LastModified()}}, false, ClientProvidedKeyOptions{}))
// Download blob content if the blob hasn't been modified in the last 24 hours (fails):
showResult(blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: time.Now().UTC().Add(time.Hour * -24)}}, false))
showResult(blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: time.Now().UTC().Add(time.Hour * -24)}}, false, ClientProvidedKeyOptions{}))
// Upload new content if the blob hasn't changed since the version identified by ETag (succeeds):
upload, err = blobURL.Upload(ctx, strings.NewReader("Text-2"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: upload.ETag()}}, DefaultAccessTier, nil)
upload, err = blobURL.Upload(ctx, strings.NewReader("Text-2"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: upload.ETag()}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
showResult(upload, err)
// Download content if it has changed since the version identified by ETag (fails):
showResult(blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: upload.ETag()}}, false))
showResult(blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: upload.ETag()}}, false, ClientProvidedKeyOptions{}))
// Upload content if the blob doesn't already exist (fails):
showResult(blobURL.Upload(ctx, strings.NewReader("Text-3"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETagAny}}, DefaultAccessTier, nil))
showResult(blobURL.Upload(ctx, strings.NewReader("Text-3"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETagAny}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}))
}
// This examples shows how to create a container with metadata and then how to read & update the metadata.
@ -582,13 +579,13 @@ func ExampleMetadata_blobs() {
// NOTE: Metadata key names are always converted to lowercase before being sent to the Storage Service.
// Therefore, you should always use lowercase letters; especially when querying a map for a metadata key.
creatingApp, _ := os.Executable()
_, err = blobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{}, Metadata{"author": "Jeffrey", "app": creatingApp}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{}, Metadata{"author": "Jeffrey", "app": creatingApp}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
// Query the blob's properties and metadata
get, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
get, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -604,7 +601,7 @@ func ExampleMetadata_blobs() {
// Update the blob's metadata and write it back to the blob
metadata["editor"] = "Grant" // Add a new key/value; NOTE: The keyname is in all lowercase letters
_, err = blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{})
_, err = blobURL.SetMetadata(ctx, metadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -632,13 +629,13 @@ func ExampleBlobHTTPHeaders() {
_, err = blobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{
ContentType: "text/html; charset=utf-8",
ContentDisposition: "attachment",
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
// GetMetadata returns the blob's properties, HTTP headers, and metadata
get, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
get, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -704,14 +701,14 @@ func ExampleBlockBlobURL() {
base64BlockIDs[index] = blockIDIntToBase64(index) // Some people use UUIDs for block IDs
// Upload a block to this blob specifying the Block ID and its content (up to 100MB); this block is uncommitted.
_, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(word), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(word), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
}
// After all the blocks are uploaded, atomically commit them to the blob.
_, err = blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -727,7 +724,7 @@ func ExampleBlockBlobURL() {
// Download the blob in its entirety; download operations do not take blocks into account.
// NOTE: For really large blobs, downloading them like allocates a lot of memory.
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -754,20 +751,20 @@ func ExampleAppendBlobURL() {
appendBlobURL := NewAppendBlobURL(*u, NewPipeline(credential, PipelineOptions{}))
ctx := context.Background() // This example uses a never-expiring context
_, err = appendBlobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, nil)
_, err = appendBlobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
for i := 0; i < 5; i++ { // Append 5 blocks to the append blob
_, err := appendBlobURL.AppendBlock(ctx, strings.NewReader(fmt.Sprintf("Appending block #%d\n", i)), AppendBlobAccessConditions{}, nil)
_, err := appendBlobURL.AppendBlock(ctx, strings.NewReader(fmt.Sprintf("Appending block #%d\n", i)), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
}
// Download the entire append blob's contents and show it.
get, err := appendBlobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
get, err := appendBlobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -794,20 +791,20 @@ func ExamplePageBlobURL() {
blobURL := NewPageBlobURL(*u, NewPipeline(credential, PipelineOptions{}))
ctx := context.Background() // This example uses a never-expiring context
_, err = blobURL.Create(ctx, PageBlobPageBytes*4, 0, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
_, err = blobURL.Create(ctx, PageBlobPageBytes*4, 0, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
page := [PageBlobPageBytes]byte{}
copy(page[:], "Page 0")
_, err = blobURL.UploadPages(ctx, 0*PageBlobPageBytes, bytes.NewReader(page[:]), PageBlobAccessConditions{}, nil)
_, err = blobURL.UploadPages(ctx, 0*PageBlobPageBytes, bytes.NewReader(page[:]), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
copy(page[:], "Page 1")
_, err = blobURL.UploadPages(ctx, 2*PageBlobPageBytes, bytes.NewReader(page[:]), PageBlobAccessConditions{}, nil)
_, err = blobURL.UploadPages(ctx, 2*PageBlobPageBytes, bytes.NewReader(page[:]), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -820,7 +817,7 @@ func ExamplePageBlobURL() {
fmt.Printf("Start=%d, End=%d\n", pr.Start, pr.End)
}
_, err = blobURL.ClearPages(ctx, 0*PageBlobPageBytes, 1*PageBlobPageBytes, PageBlobAccessConditions{})
_, err = blobURL.ClearPages(ctx, 0*PageBlobPageBytes, 1*PageBlobPageBytes, PageBlobAccessConditions{}, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -833,7 +830,7 @@ func ExamplePageBlobURL() {
fmt.Printf("Start=%d, End=%d\n", pr.Start, pr.End)
}
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -864,22 +861,22 @@ func Example_blobSnapshots() {
ctx := context.Background() // This example uses a never-expiring context
// Create the original blob:
_, err = baseBlobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = baseBlobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
// Create a snapshot of the original blob & save its timestamp:
createSnapshot, err := baseBlobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
createSnapshot, err := baseBlobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
snapshot := createSnapshot.Snapshot()
// Modify the original blob & show it:
_, err = baseBlobURL.Upload(ctx, strings.NewReader("New text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = baseBlobURL.Upload(ctx, strings.NewReader("New text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
get, err := baseBlobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
get, err := baseBlobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
b := bytes.Buffer{}
reader := get.Body(RetryReaderOptions{})
b.ReadFrom(reader)
@ -888,7 +885,7 @@ func Example_blobSnapshots() {
// Show snapshot blob via original blob URI & snapshot time:
snapshotBlobURL := baseBlobURL.WithSnapshot(snapshot)
get, err = snapshotBlobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
get, err = snapshotBlobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
b.Reset()
reader = get.Body(RetryReaderOptions{})
b.ReadFrom(reader)
@ -965,13 +962,13 @@ func Example_progressUploadDownload() {
}), BlobHTTPHeaders{
ContentType: "text/html; charset=utf-8",
ContentDisposition: "attachment",
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
// Here's how to read the blob's data with progress reporting:
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
get, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -1014,7 +1011,7 @@ func ExampleBlobURL_startCopy() {
copyStatus := startCopy.CopyStatus()
for copyStatus == CopyStatusPending {
time.Sleep(time.Second * 2)
getMetadata, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
getMetadata, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -1097,7 +1094,7 @@ func ExampleBlobUrl_Download() {
contentLength := int64(0) // Used for progress reporting to report the total number of bytes being downloaded.
// Download returns an intelligent retryable stream around a blob; it returns an io.ReadCloser.
dr, err := blobURL.Download(context.TODO(), 0, -1, BlobAccessConditions{}, false)
dr, err := blobURL.Download(context.TODO(), 0, -1, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal(err)
}
@ -1251,7 +1248,7 @@ func ExampleListBlobsHierarchy() {
blobNames := []string{"a/1", "a/2", "b/1", "boaty_mcboatface"}
for _, blobName := range blobNames {
blobURL := containerURL.NewBlockBlobURL(blobName)
_, err := blobURL.Upload(ctx, strings.NewReader("test"), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, strings.NewReader("test"), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
log.Fatal("an error occurred while creating blobs for the example setup")

Просмотреть файл

@ -42,7 +42,7 @@ func performUploadStreamToBlockBlobTest(c *chk.C, blobSize, bufferSize, maxBuffe
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
// Download the blob to verify
downloadResponse, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
downloadResponse, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
// Assert that the content is correct

Просмотреть файл

@ -24,13 +24,13 @@ func (s *aztestsSuite) TestSnapshotSAS(c *chk.C) {
burl := containerURL.NewBlockBlobURL(blobName)
data := "Hello world!"
_, err = burl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = burl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
c.Fatal(err)
}
//Create a snapshot & URL
createSnapshot, err := burl.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
createSnapshot, err := burl.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
if err != nil {
c.Fatal(err)
}
@ -70,7 +70,7 @@ func (s *aztestsSuite) TestSnapshotSAS(c *chk.C) {
sburl := NewBlockBlobURL(snapParts.URL(), p)
//Test the snapshot
downloadResponse, err := sburl.Download(ctx, 0, 0, BlobAccessConditions{}, false)
downloadResponse, err := sburl.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
c.Fatal(err)
}
@ -92,7 +92,7 @@ func (s *aztestsSuite) TestSnapshotSAS(c *chk.C) {
//If this succeeds, it means a normal SAS token was created.
fsburl := containerURL.NewBlockBlobURL("failsnap")
_, err = fsburl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = fsburl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
c.Fatal(err) //should succeed to create the blob via normal auth means
}

Просмотреть файл

@ -166,7 +166,7 @@ func createNewContainerWithSuffix(c *chk.C, bsu ServiceURL, suffix string) (cont
func createNewBlockBlob(c *chk.C, container ContainerURL) (blob BlockBlobURL, name string) {
blob, name = getBlockBlobURL(c, container)
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(cResp.StatusCode(), chk.Equals, 201)
@ -174,20 +174,39 @@ func createNewBlockBlob(c *chk.C, container ContainerURL) (blob BlockBlobURL, na
return
}
func createNewBlockBlobWithCPK(c *chk.C, container ContainerURL, cpk ClientProvidedKeyOptions) (blob BlockBlobURL, name string) {
blob, name = getBlockBlobURL(c, container)
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{},
nil, BlobAccessConditions{}, DefaultAccessTier, nil, cpk)
c.Assert(err, chk.IsNil)
c.Assert(cResp.StatusCode(), chk.Equals, 201)
return
}
func createNewAppendBlob(c *chk.C, container ContainerURL) (blob AppendBlobURL, name string) {
blob, name = getAppendBlobURL(c, container)
resp, err := blob.Create(ctx, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
resp, err := blob.Create(ctx, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
return
}
func createNewAppendBlobWithCPK(c *chk.C, container ContainerURL, cpk ClientProvidedKeyOptions) (blob AppendBlobURL, name string) {
blob, name = getAppendBlobURL(c, container)
resp, err := blob.Create(ctx, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, cpk)
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
return
}
func createNewPageBlob(c *chk.C, container ContainerURL) (blob PageBlobURL, name string) {
blob, name = getPageBlobURL(c, container)
resp, err := blob.Create(ctx, PageBlobPageBytes*10, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
resp, err := blob.Create(ctx, PageBlobPageBytes*10, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
return
@ -196,8 +215,16 @@ func createNewPageBlob(c *chk.C, container ContainerURL) (blob PageBlobURL, name
func createNewPageBlobWithSize(c *chk.C, container ContainerURL, sizeInBytes int64) (blob PageBlobURL, name string) {
blob, name = getPageBlobURL(c, container)
resp, err := blob.Create(ctx, sizeInBytes, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
resp, err := blob.Create(ctx, sizeInBytes, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
return
}
func createNewPageBlobWithCPK(c *chk.C, container ContainerURL, sizeInBytes int64, cpk ClientProvidedKeyOptions) (blob PageBlobURL, name string) {
blob, name = getPageBlobURL(c, container)
resp, err := blob.Create(ctx, sizeInBytes, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, cpk)
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
return
@ -207,7 +234,7 @@ func createBlockBlobWithPrefix(c *chk.C, container ContainerURL, prefix string)
name = prefix + generateName(blobPrefix)
blob = container.NewBlockBlobURL(name)
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(cResp.StatusCode(), chk.Equals, 201)
@ -371,7 +398,7 @@ func disableSoftDelete(c *chk.C, bsu ServiceURL) {
}
func validateUpload(c *chk.C, blobURL BlockBlobURL) {
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, _ := ioutil.ReadAll(resp.Response().Body)
c.Assert(data, chk.HasLen, 0)

Просмотреть файл

@ -20,11 +20,11 @@ func (s *aztestsSuite) TestAppendBlock(c *chk.C) {
blob := container.NewAppendBlobURL(generateBlobName())
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
appendResp, err := blob.AppendBlock(context.Background(), getReaderToRandomBytes(1024), AppendBlobAccessConditions{}, nil)
appendResp, err := blob.AppendBlock(context.Background(), getReaderToRandomBytes(1024), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(appendResp.Response().StatusCode, chk.Equals, 201)
c.Assert(appendResp.BlobAppendOffset(), chk.Equals, "0")
@ -36,7 +36,7 @@ func (s *aztestsSuite) TestAppendBlock(c *chk.C) {
c.Assert(appendResp.Version(), chk.Not(chk.Equals), "")
c.Assert(appendResp.Date().IsZero(), chk.Equals, false)
appendResp, err = blob.AppendBlock(context.Background(), getReaderToRandomBytes(1024), AppendBlobAccessConditions{}, nil)
appendResp, err = blob.AppendBlock(context.Background(), getReaderToRandomBytes(1024), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(appendResp.BlobAppendOffset(), chk.Equals, "1024")
c.Assert(appendResp.BlobCommittedBlockCount(), chk.Equals, int32(2))
@ -49,14 +49,14 @@ func (s *aztestsSuite) TestAppendBlockWithMD5(c *chk.C) {
// set up blob to test
blob := container.NewAppendBlobURL(generateBlobName())
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.StatusCode(), chk.Equals, 201)
// test append block with valid MD5 value
readerToBody, body := getRandomDataAndReader(1024)
md5Value := md5.Sum(body)
appendResp, err := blob.AppendBlock(context.Background(), readerToBody, AppendBlobAccessConditions{}, md5Value[:])
appendResp, err := blob.AppendBlock(context.Background(), readerToBody, AppendBlobAccessConditions{}, md5Value[:], ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(appendResp.Response().StatusCode, chk.Equals, 201)
c.Assert(appendResp.BlobAppendOffset(), chk.Equals, "0")
@ -71,7 +71,7 @@ func (s *aztestsSuite) TestAppendBlockWithMD5(c *chk.C) {
// test append block with bad MD5 value
readerToBody, body = getRandomDataAndReader(1024)
_, badMD5 := getRandomDataAndReader(16)
appendResp, err = blob.AppendBlock(context.Background(), readerToBody, AppendBlobAccessConditions{}, badMD5[:])
appendResp, err = blob.AppendBlock(context.Background(), readerToBody, AppendBlobAccessConditions{}, badMD5[:], ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeMd5Mismatch)
}
@ -91,10 +91,10 @@ func (s *aztestsSuite) TestAppendBlockFromURL(c *chk.C) {
destBlob := container.NewAppendBlobURL(generateName("appenddest"))
// Prepare source blob for copy.
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(cResp1.StatusCode(), chk.Equals, 201)
appendResp, err := srcBlob.AppendBlock(context.Background(), r, AppendBlobAccessConditions{}, nil)
appendResp, err := srcBlob.AppendBlock(context.Background(), r, AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(appendResp.Response().StatusCode, chk.Equals, 201)
c.Assert(appendResp.BlobAppendOffset(), chk.Equals, "0")
@ -123,10 +123,10 @@ func (s *aztestsSuite) TestAppendBlockFromURL(c *chk.C) {
srcBlobURLWithSAS := srcBlobParts.URL()
// Append block from URL.
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(cResp2.StatusCode(), chk.Equals, 201)
appendFromURLResp, err := destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, nil)
appendFromURLResp, err := destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(appendFromURLResp.Response().StatusCode, chk.Equals, 201)
c.Assert(appendFromURLResp.BlobAppendOffset(), chk.Equals, "0")
@ -139,7 +139,7 @@ func (s *aztestsSuite) TestAppendBlockFromURL(c *chk.C) {
c.Assert(appendFromURLResp.Date().IsZero(), chk.Equals, false)
// Check data integrity through downloading.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -163,10 +163,10 @@ func (s *aztestsSuite) TestAppendBlockFromURLWithMD5(c *chk.C) {
destBlob := container.NewAppendBlobURL(generateName("appenddest"))
// Prepare source blob for copy.
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(cResp1.StatusCode(), chk.Equals, 201)
appendResp, err := srcBlob.AppendBlock(context.Background(), r, AppendBlobAccessConditions{}, nil)
appendResp, err := srcBlob.AppendBlock(context.Background(), r, AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(appendResp.Response().StatusCode, chk.Equals, 201)
c.Assert(appendResp.BlobAppendOffset(), chk.Equals, "0")
@ -195,10 +195,10 @@ func (s *aztestsSuite) TestAppendBlockFromURLWithMD5(c *chk.C) {
srcBlobURLWithSAS := srcBlobParts.URL()
// Append block from URL.
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(cResp2.StatusCode(), chk.Equals, 201)
appendFromURLResp, err := destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, md5Value[:])
appendFromURLResp, err := destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, md5Value[:], ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(appendFromURLResp.Response().StatusCode, chk.Equals, 201)
c.Assert(appendFromURLResp.BlobAppendOffset(), chk.Equals, "0")
@ -211,7 +211,7 @@ func (s *aztestsSuite) TestAppendBlockFromURLWithMD5(c *chk.C) {
c.Assert(appendFromURLResp.Date().IsZero(), chk.Equals, false)
// Check data integrity through downloading.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -219,7 +219,7 @@ func (s *aztestsSuite) TestAppendBlockFromURLWithMD5(c *chk.C) {
// Test append block from URL with bad MD5 value
_, badMD5 := getRandomDataAndReader(16)
_, err = destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, badMD5)
_, err = destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, badMD5, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeMd5Mismatch)
}
@ -229,10 +229,10 @@ func (s *aztestsSuite) TestBlobCreateAppendMetadataNonEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getAppendBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -243,10 +243,10 @@ func (s *aztestsSuite) TestBlobCreateAppendMetadataEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getAppendBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.HasLen, 0)
}
@ -257,7 +257,7 @@ func (s *aztestsSuite) TestBlobCreateAppendMetadataInvalid(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getAppendBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(strings.Contains(err.Error(), invalidHeaderErrorSubstring), chk.Equals, true)
}
@ -267,17 +267,17 @@ func (s *aztestsSuite) TestBlobCreateAppendHTTPHeaders(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getAppendBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, basicHeaders, nil, BlobAccessConditions{}, nil)
_, err := blobURL.Create(ctx, basicHeaders, nil, BlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
h := resp.NewHTTPHeaders()
c.Assert(h, chk.DeepEquals, basicHeaders)
}
func validateAppendBlobPut(c *chk.C, blobURL AppendBlobURL) {
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -290,7 +290,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfModifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateAppendBlobPut(c, blobURL)
@ -304,7 +304,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -316,7 +316,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateAppendBlobPut(c, blobURL)
@ -330,7 +330,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfUnmodifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -340,9 +340,9 @@ func (s *aztestsSuite) TestBlobCreateAppendIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateAppendBlobPut(c, blobURL)
@ -354,7 +354,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -364,7 +364,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateAppendBlobPut(c, blobURL)
@ -376,9 +376,9 @@ func (s *aztestsSuite) TestBlobCreateAppendIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, nil)
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -388,7 +388,7 @@ func (s *aztestsSuite) TestBlobAppendBlockNilBody(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, bytes.NewReader(nil), AppendBlobAccessConditions{}, nil)
_, err := blobURL.AppendBlock(ctx, bytes.NewReader(nil), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
validateStorageError(c, err, ServiceCodeInvalidHeaderValue)
}
@ -399,7 +399,7 @@ func (s *aztestsSuite) TestBlobAppendBlockEmptyBody(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(""), AppendBlobAccessConditions{}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(""), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidHeaderValue)
}
@ -409,12 +409,12 @@ func (s *aztestsSuite) TestBlobAppendBlockNonExistantBlob(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getAppendBlobURL(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeBlobNotFound)
}
func validateBlockAppended(c *chk.C, blobURL AppendBlobURL, expectedSize int) {
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ContentLength(), chk.Equals, int64(expectedSize))
}
@ -427,8 +427,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfModifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, len(blockBlobDefaultData))
@ -441,8 +440,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfModifiedSinceFalse(c *chk.C) {
blobURL, _ := createNewAppendBlob(c, containerURL)
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -453,8 +451,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfUnmodifiedSinceTrue(c *chk.C) {
blobURL, _ := createNewAppendBlob(c, containerURL)
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, len(blockBlobDefaultData))
@ -467,8 +464,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfUnmodifiedSinceFalse(c *chk.C) {
blobURL, _ := createNewAppendBlob(c, containerURL)
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -478,10 +474,9 @@ func (s *aztestsSuite) TestBlobAppendBlockIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, len(blockBlobDefaultData))
@ -493,8 +488,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -504,8 +498,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, len(blockBlobDefaultData))
@ -517,10 +510,9 @@ func (s *aztestsSuite) TestBlobAppendBlockIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -530,8 +522,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfAppendPositionMatchTrueNegOne(c *chk
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: -1}}, nil) // This will cause the library to set the value of the header to 0
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: -1}}, nil, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, len(blockBlobDefaultData))
@ -543,10 +534,9 @@ func (s *aztestsSuite) TestBlobAppendBlockIfAppendPositionMatchZero(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil) // The position will not match, but the condition should be ignored
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{}) // The position will not match, but the condition should be ignored
c.Assert(err, chk.IsNil)
_, err = blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: 0}}, nil)
_, err = blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: 0}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, 2*len(blockBlobDefaultData))
@ -558,10 +548,9 @@ func (s *aztestsSuite) TestBlobAppendBlockIfAppendPositionMatchTrueNonZero(c *ch
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: int64(len(blockBlobDefaultData))}}, nil)
_, err = blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: int64(len(blockBlobDefaultData))}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, len(blockBlobDefaultData)*2)
@ -573,10 +562,9 @@ func (s *aztestsSuite) TestBlobAppendBlockIfAppendPositionMatchFalseNegOne(c *ch
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: -1}}, nil) // This will cause the library to set the value of the header to 0
_, err = blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: -1}}, nil, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
validateStorageError(c, err, ServiceCodeAppendPositionConditionNotMet)
}
@ -586,8 +574,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfAppendPositionMatchFalseNonZero(c *c
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: 12}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfAppendPositionEqual: 12}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeAppendPositionConditionNotMet)
}
@ -597,8 +584,7 @@ func (s *aztestsSuite) TestBlobAppendBlockIfMaxSizeTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfMaxSizeLessThanOrEqual: int64(len(blockBlobDefaultData) + 1)}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfMaxSizeLessThanOrEqual: int64(len(blockBlobDefaultData) + 1)}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlockAppended(c, blobURL, len(blockBlobDefaultData))
@ -610,7 +596,6 @@ func (s *aztestsSuite) TestBlobAppendBlockIfMaxSizeFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewAppendBlob(c, containerURL)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData),
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfMaxSizeLessThanOrEqual: int64(len(blockBlobDefaultData) - 1)}}, nil)
_, err := blobURL.AppendBlock(ctx, strings.NewReader(blockBlobDefaultData), AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfMaxSizeLessThanOrEqual: int64(len(blockBlobDefaultData) - 1)}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeMaxBlobSizeConditionNotMet)
}

Просмотреть файл

@ -78,7 +78,7 @@ func waitForCopy(c *chk.C, copyBlobURL BlockBlobURL, blobCopyResponse *BlobStart
// Wait for the copy to finish. If the copy takes longer than a minute, we will fail
start := time.Now()
for status != CopyStatusSuccess {
props, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
props, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
status = props.CopyStatus()
currentTime := time.Now()
if currentTime.Sub(start) >= time.Minute {
@ -98,7 +98,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestEmpty(c *chk.C) {
c.Assert(err, chk.IsNil)
waitForCopy(c, copyBlobURL, blobCopyResponse)
resp, err := copyBlobURL.Download(ctx, 0, 20, BlobAccessConditions{}, false)
resp, err := copyBlobURL.Download(ctx, 0, 20, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
// Read the blob data to verify the copy
@ -119,7 +119,7 @@ func (s *aztestsSuite) TestBlobStartCopyMetadata(c *chk.C) {
c.Assert(err, chk.IsNil)
waitForCopy(c, copyBlobURL, resp)
resp2, err := copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -132,7 +132,7 @@ func (s *aztestsSuite) TestBlobStartCopyMetadataNil(c *chk.C) {
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
// Have the destination start with metadata so we ensure the nil metadata passed later takes effect
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
@ -140,7 +140,7 @@ func (s *aztestsSuite) TestBlobStartCopyMetadataNil(c *chk.C) {
waitForCopy(c, copyBlobURL, resp)
resp2, err := copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.HasLen, 0)
}
@ -153,7 +153,7 @@ func (s *aztestsSuite) TestBlobStartCopyMetadataEmpty(c *chk.C) {
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
// Have the destination start with metadata so we ensure the empty metadata passed later takes effect
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
@ -161,7 +161,7 @@ func (s *aztestsSuite) TestBlobStartCopyMetadataEmpty(c *chk.C) {
waitForCopy(c, copyBlobURL, resp)
resp2, err := copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.HasLen, 0)
}
@ -253,7 +253,7 @@ func (s *aztestsSuite) TestBlobStartCopyUsingSASSrc(c *chk.C) {
waitForCopy(c, copyBlobURL, resp)
resp2, err := copyBlobURL.Download(ctx, 0, int64(len(blockBlobDefaultData)), BlobAccessConditions{}, false)
resp2, err := copyBlobURL.Download(ctx, 0, int64(len(blockBlobDefaultData)), BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(resp2.Response().Body)
@ -325,7 +325,7 @@ func (s *aztestsSuite) TestBlobStartCopyUsingSASDest(c *chk.C) {
// Allow copy to happen
waitForCopy(c, anonBlobURL, resp)
resp2, err := copyBlobURL.Download(ctx, 0, int64(len(blockBlobDefaultData)), BlobAccessConditions{}, false)
resp2, err := copyBlobURL.Download(ctx, 0, int64(len(blockBlobDefaultData)), BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(resp2.Response().Body)
@ -347,7 +347,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfModifiedSinceTrue(c *chk.C) {
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfModifiedSince: currentTime}, BlobAccessConditions{}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -377,7 +377,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfUnmodifiedSinceTrue(c *chk.C) {
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfUnmodifiedSince: currentTime}, BlobAccessConditions{}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -401,7 +401,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
etag := resp.ETag()
@ -409,7 +409,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfMatchTrue(c *chk.C) {
_, err = destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfMatch: etag}, BlobAccessConditions{}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp2, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -435,7 +435,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfNoneMatchTrue(c *chk.C) {
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfNoneMatch: "a"}, BlobAccessConditions{}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp2, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -446,7 +446,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
etag := resp.ETag()
@ -466,7 +466,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfModifiedSinceTrue(c *chk.C) {
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -496,7 +496,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfUnmodifiedSinceTrue(c *chk.C) {
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -521,13 +521,13 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfMatchTrue(c *chk.C) {
blobURL, _ := createNewBlockBlob(c, containerURL)
destBlobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp, err = destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err = destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -539,10 +539,10 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfMatchFalse(c *chk.C) {
blobURL, _ := createNewBlockBlob(c, containerURL)
destBlobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
destBlobURL.SetMetadata(ctx, nil, BlobAccessConditions{}) // SetMetadata chances the blob's etag
destBlobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{}) // SetMetadata chances the blob's etag
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, DefaultAccessTier, nil)
validateStorageError(c, err, ServiceCodeTargetConditionNotMet)
@ -555,15 +555,15 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfNoneMatchTrue(c *chk.C) {
blobURL, _ := createNewBlockBlob(c, containerURL)
destBlobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
destBlobURL.SetMetadata(ctx, nil, BlobAccessConditions{}) // SetMetadata chances the blob's etag
destBlobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{}) // SetMetadata chances the blob's etag
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, DefaultAccessTier, nil)
c.Assert(err, chk.IsNil)
resp, err = destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err = destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -575,7 +575,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfNoneMatchFalse(c *chk.C) {
blobURL, _ := createNewBlockBlob(c, containerURL)
destBlobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, DefaultAccessTier, nil)
@ -594,7 +594,7 @@ func (s *aztestsSuite) TestBlobAbortCopyInProgress(c *chk.C) {
for i := range blobData {
blobData[i] = byte('a' + i%26)
}
_, err := blobURL.Upload(ctx, bytes.NewReader(blobData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(blobData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
containerURL.SetAccessPolicy(ctx, PublicAccessBlob, nil, ContainerAccessConditions{}) // So that we don't have to create a SAS
@ -622,7 +622,7 @@ func (s *aztestsSuite) TestBlobAbortCopyInProgress(c *chk.C) {
c.Error("The test failed because the copy completed because it was aborted")
}
resp2, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp2, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(resp2.CopyStatus(), chk.Equals, CopyStatusAborted)
}
@ -643,12 +643,12 @@ func (s *aztestsSuite) TestBlobSnapshotMetadata(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.CreateSnapshot(ctx, basicMetadata, BlobAccessConditions{})
resp, err := blobURL.CreateSnapshot(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
// Since metadata is specified on the snapshot, the snapshot should have its own metadata different from the (empty) metadata on the source
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -659,15 +659,15 @@ func (s *aztestsSuite) TestBlobSnapshotMetadataEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
resp, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
// In this case, because no metadata was specified, it should copy the basicMetadata from the source
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -678,14 +678,14 @@ func (s *aztestsSuite) TestBlobSnapshotMetadataNil(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{})
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -696,7 +696,7 @@ func (s *aztestsSuite) TestBlobSnapshotMetadataInvalid(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.CreateSnapshot(ctx, Metadata{"Invalid Field!": "value"}, BlobAccessConditions{})
_, err := blobURL.CreateSnapshot(ctx, Metadata{"Invalid Field!": "value"}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
c.Assert(strings.Contains(err.Error(), invalidHeaderErrorSubstring), chk.Equals, true)
}
@ -707,7 +707,7 @@ func (s *aztestsSuite) TestBlobSnapshotBlobNotExist(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeBlobNotFound)
}
@ -719,7 +719,7 @@ func (s *aztestsSuite) TestBlobSnapshotOfSnapshot(c *chk.C) {
snapshotURL := blobURL.WithSnapshot(time.Now().UTC().Format(SnapshotTimeFormat))
// The library allows the server to handle the snapshot of snapshot error
_, err := snapshotURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
_, err := snapshotURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidQueryParameterValue)
}
@ -731,8 +731,7 @@ func (s *aztestsSuite) TestBlobSnapshotIfModifiedSinceTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.Snapshot() != "", chk.Equals, true) // i.e. The snapshot time is not zero. If the service gives us back a snapshot time, it successfully created a snapshot
}
@ -745,8 +744,7 @@ func (s *aztestsSuite) TestBlobSnapshotIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -758,8 +756,7 @@ func (s *aztestsSuite) TestBlobSnapshotIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
resp, err := blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.Snapshot() == "", chk.Equals, false)
}
@ -772,8 +769,7 @@ func (s *aztestsSuite) TestBlobSnapshotIfUnmodifiedSinceFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -783,10 +779,9 @@ func (s *aztestsSuite) TestBlobSnapshotIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
resp2, err := blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
resp2, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.Snapshot() == "", chk.Equals, false)
}
@ -797,8 +792,7 @@ func (s *aztestsSuite) TestBlobSnapshotIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: "garbage"}})
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: "garbage"}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -808,8 +802,7 @@ func (s *aztestsSuite) TestBlobSnapshotIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: "garbage"}})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: "garbage"}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.Snapshot() == "", chk.Equals, false)
}
@ -820,10 +813,9 @@ func (s *aztestsSuite) TestBlobSnapshotIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err = blobURL.CreateSnapshot(ctx, nil,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
_, err = blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -833,7 +825,7 @@ func (s *aztestsSuite) TestBlobDownloadDataNonExistantBlob(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
_, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeBlobNotFound)
}
@ -843,7 +835,7 @@ func (s *aztestsSuite) TestBlobDownloadDataNegativeOffset(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.Download(ctx, -1, 0, BlobAccessConditions{}, false)
_, err := blobURL.Download(ctx, -1, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
}
@ -853,7 +845,7 @@ func (s *aztestsSuite) TestBlobDownloadDataOffsetOutOfRange(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.Download(ctx, int64(len(blockBlobDefaultData)), CountToEnd, BlobAccessConditions{}, false)
_, err := blobURL.Download(ctx, int64(len(blockBlobDefaultData)), CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidRange)
}
@ -863,7 +855,7 @@ func (s *aztestsSuite) TestBlobDownloadDataCountNegative(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.Download(ctx, 0, -2, BlobAccessConditions{}, false)
_, err := blobURL.Download(ctx, 0, -2, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
}
@ -873,7 +865,7 @@ func (s *aztestsSuite) TestBlobDownloadDataCountZero(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
// Specifying a count of 0 results in the value being ignored
@ -888,7 +880,7 @@ func (s *aztestsSuite) TestBlobDownloadDataCountExact(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.Download(ctx, 0, int64(len(blockBlobDefaultData)), BlobAccessConditions{}, false)
resp, err := blobURL.Download(ctx, 0, int64(len(blockBlobDefaultData)), BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(resp.Response().Body)
@ -902,7 +894,7 @@ func (s *aztestsSuite) TestBlobDownloadDataCountOutOfRange(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.Download(ctx, 0, int64(len(blockBlobDefaultData))*2, BlobAccessConditions{}, false)
resp, err := blobURL.Download(ctx, 0, int64(len(blockBlobDefaultData))*2, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(resp.Response().Body)
@ -916,7 +908,7 @@ func (s *aztestsSuite) TestBlobDownloadDataEmptyRangeStruct(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(resp.Response().Body)
@ -930,7 +922,7 @@ func (s *aztestsSuite) TestBlobDownloadDataContentMD5(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.Download(ctx, 10, 3, BlobAccessConditions{}, true)
resp, err := blobURL.Download(ctx, 10, 3, BlobAccessConditions{}, true, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
mdf := md5.Sum([]byte(blockBlobDefaultData)[10:13])
c.Assert(resp.ContentMD5(), chk.DeepEquals, mdf[:])
@ -944,8 +936,7 @@ func (s *aztestsSuite) TestBlobDownloadDataIfModifiedSinceTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, false)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ContentLength(), chk.Equals, int64(len(blockBlobDefaultData)))
}
@ -958,8 +949,7 @@ func (s *aztestsSuite) TestBlobDownloadDataIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, false)
_, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, false, ClientProvidedKeyOptions{})
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 304) // The server does not return the error in the body even though it is a GET
}
@ -972,8 +962,7 @@ func (s *aztestsSuite) TestBlobDownloadDataIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
resp, err := blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, false)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ContentLength(), chk.Equals, int64(len(blockBlobDefaultData)))
}
@ -986,8 +975,7 @@ func (s *aztestsSuite) TestBlobDownloadDataIfUnmodifiedSinceFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, false)
_, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, false, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -997,12 +985,11 @@ func (s *aztestsSuite) TestBlobDownloadDataIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
etag := resp.ETag()
resp2, err := blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, false)
resp2, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.ContentLength(), chk.Equals, int64(len(blockBlobDefaultData)))
}
@ -1013,14 +1000,13 @@ func (s *aztestsSuite) TestBlobDownloadDataIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
etag := resp.ETag()
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{})
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err = blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, false)
_, err = blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, false, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1030,14 +1016,13 @@ func (s *aztestsSuite) TestBlobDownloadDataIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
etag := resp.ETag()
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{})
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
resp2, err := blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, false)
resp2, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.ContentLength(), chk.Equals, int64(len(blockBlobDefaultData)))
}
@ -1048,12 +1033,11 @@ func (s *aztestsSuite) TestBlobDownloadDataIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
etag := resp.ETag()
_, err = blobURL.Download(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, false)
_, err = blobURL.Download(ctx, 0, 0, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, false, ClientProvidedKeyOptions{})
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 304) // The server does not return the error in the body even though it is a GET
}
@ -1074,7 +1058,7 @@ func (s *aztestsSuite) TestBlobDeleteSnapshot(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
@ -1090,7 +1074,7 @@ func (s *aztestsSuite) TestBlobDeleteSnapshotsInclude(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.Delete(ctx, DeleteSnapshotsOptionInclude, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
@ -1106,7 +1090,7 @@ func (s *aztestsSuite) TestBlobDeleteSnapshotsOnly(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.Delete(ctx, DeleteSnapshotsOptionOnly, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
@ -1123,14 +1107,14 @@ func (s *aztestsSuite) TestBlobDeleteSnapshotsNoneWithSnapshots(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
_, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.Delete(ctx, DeleteSnapshotsOptionNone, BlobAccessConditions{})
validateStorageError(c, err, ServiceCodeSnapshotsPresent)
}
func validateBlobDeleted(c *chk.C, blobURL BlockBlobURL) {
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
serr := err.(StorageError) // Delete blob is a HEAD request and does not return a ServiceCode in the body
c.Assert(serr.Response().StatusCode, chk.Equals, 404)
@ -1198,7 +1182,7 @@ func (s *aztestsSuite) TestBlobDeleteIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
_, err := blobURL.Delete(ctx, DeleteSnapshotsOptionNone,
@ -1214,9 +1198,9 @@ func (s *aztestsSuite) TestBlobDeleteIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{})
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Delete(ctx, DeleteSnapshotsOptionNone,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}})
@ -1230,9 +1214,9 @@ func (s *aztestsSuite) TestBlobDeleteIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{})
blobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Delete(ctx, DeleteSnapshotsOptionNone,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}})
@ -1247,7 +1231,7 @@ func (s *aztestsSuite) TestBlobDeleteIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
etag := resp.ETag()
_, err := blobURL.Delete(ctx, DeleteSnapshotsOptionNone,
@ -1263,11 +1247,10 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfModifiedSinceTrue(c *chk.C)
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -1278,13 +1261,12 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfModifiedSinceFalse(c *chk.C)
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
currentTime := getRelativeTimeGMT(10)
_, err = blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err = blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 304) // No service code returned for a HEAD
@ -1296,13 +1278,12 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfUnmodifiedSinceTrue(c *chk.C
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
currentTime := getRelativeTimeGMT(10)
resp, err := blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -1315,11 +1296,10 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfUnmodifiedSinceFalse(c *chk.
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err = blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 412)
@ -1331,11 +1311,10 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
resp, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp2, err := blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
resp2, err := blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -1346,7 +1325,7 @@ func (s *aztestsSuite) TestBlobGetPropsOnMissingBlob(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL := containerURL.NewBlobURL("MISSING")
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 404)
@ -1359,8 +1338,7 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}})
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 412)
@ -1372,11 +1350,10 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -1387,11 +1364,10 @@ func (s *aztestsSuite) TestBlobGetPropsAndMetadataIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.SetMetadata(ctx, nil, BlobAccessConditions{})
resp, err := blobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.GetProperties(ctx,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
_, err = blobURL.GetProperties(ctx, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 304)
@ -1406,7 +1382,7 @@ func (s *aztestsSuite) TestBlobSetPropertiesBasic(c *chk.C) {
_, err := blobURL.SetHTTPHeaders(ctx, basicHeaders, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
h := resp.NewHTTPHeaders()
c.Assert(h, chk.DeepEquals, basicHeaders)
}
@ -1423,13 +1399,13 @@ func (s *aztestsSuite) TestBlobSetPropertiesEmptyValue(c *chk.C) {
_, err = blobURL.SetHTTPHeaders(ctx, BlobHTTPHeaders{}, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ContentType(), chk.Equals, "")
}
func validatePropertiesSet(c *chk.C, blobURL BlockBlobURL, disposition string) {
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ContentDisposition(), chk.Equals, disposition)
}
@ -1496,7 +1472,7 @@ func (s *aztestsSuite) TestBlobSetPropertiesIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.SetHTTPHeaders(ctx, BlobHTTPHeaders{ContentDisposition: "my_disposition"},
@ -1536,7 +1512,7 @@ func (s *aztestsSuite) TestBlobSetPropertiesIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.SetHTTPHeaders(ctx, BlobHTTPHeaders{ContentDisposition: "my_disposition"},
@ -1550,13 +1526,13 @@ func (s *aztestsSuite) TestBlobSetMetadataNil(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, Metadata{"not": "nil"}, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, Metadata{"not": "nil"}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.SetMetadata(ctx, nil, BlobAccessConditions{})
_, err = blobURL.SetMetadata(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.HasLen, 0)
}
@ -1567,13 +1543,13 @@ func (s *aztestsSuite) TestBlobSetMetadataEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, Metadata{"not": "nil"}, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, Metadata{"not": "nil"}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.SetMetadata(ctx, Metadata{}, BlobAccessConditions{})
_, err = blobURL.SetMetadata(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.HasLen, 0)
}
@ -1584,13 +1560,13 @@ func (s *aztestsSuite) TestBlobSetMetadataInvalidField(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, Metadata{"Invalid field!": "value"}, BlobAccessConditions{})
_, err := blobURL.SetMetadata(ctx, Metadata{"Invalid field!": "value"}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
c.Assert(strings.Contains(err.Error(), invalidHeaderErrorSubstring), chk.Equals, true)
}
func validateMetadataSet(c *chk.C, blobURL BlockBlobURL) {
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -1603,8 +1579,7 @@ func (s *aztestsSuite) TestBlobSetMetadataIfModifiedSinceTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateMetadataSet(c, blobURL)
@ -1618,8 +1593,7 @@ func (s *aztestsSuite) TestBlobSetMetadataIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1631,8 +1605,7 @@ func (s *aztestsSuite) TestBlobSetMetadataIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateMetadataSet(c, blobURL)
@ -1646,8 +1619,7 @@ func (s *aztestsSuite) TestBlobSetMetadataIfUnmodifiedSinceFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1657,11 +1629,10 @@ func (s *aztestsSuite) TestBlobSetMetadataIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
_, err = blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateMetadataSet(c, blobURL)
@ -1673,8 +1644,7 @@ func (s *aztestsSuite) TestBlobSetMetadataIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1684,8 +1654,7 @@ func (s *aztestsSuite) TestBlobSetMetadataIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}})
_, err := blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateMetadataSet(c, blobURL)
@ -1697,11 +1666,10 @@ func (s *aztestsSuite) TestBlobSetMetadataIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.SetMetadata(ctx, basicMetadata,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
_, err = blobURL.SetMetadata(ctx, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1736,7 +1704,7 @@ func setAndCheckBlobTier(c *chk.C, containerURL ContainerURL, blobURL BlobURL, t
_, err := blobURL.SetTier(ctx, tier, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.AccessTier(), chk.Equals, string(tier))
@ -1786,7 +1754,7 @@ func (s *aztestsSuite) TestBlobTierInferred(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.AccessTierInferred(), chk.Equals, "true")
@ -1798,7 +1766,7 @@ func (s *aztestsSuite) TestBlobTierInferred(c *chk.C) {
_, err = blobURL.SetTier(ctx, AccessTierP4, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
resp, err = blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err = blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.AccessTierInferred(), chk.Equals, "")
@ -1822,7 +1790,7 @@ func (s *aztestsSuite) TestBlobArchiveStatus(c *chk.C) {
_, err = blobURL.SetTier(ctx, AccessTierCool, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ArchiveStatus(), chk.Equals, string(ArchiveStatusRehydratePendingToCool))
@ -1841,7 +1809,7 @@ func (s *aztestsSuite) TestBlobArchiveStatus(c *chk.C) {
_, err = blobURL.SetTier(ctx, AccessTierHot, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
resp, err = blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err = blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ArchiveStatus(), chk.Equals, string(ArchiveStatusRehydratePendingToHot))
@ -1922,7 +1890,7 @@ func (s *aztestsSuite) TestDownloadBlockBlobUnexpectedEOF(c *chk.C) {
cURL, _ := createNewContainer(c, bsu)
defer delContainer(c, cURL)
bURL, _ := createNewBlockBlob(c, cURL) // This uploads for us.
resp, err := bURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
resp, err := bURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
// Verify that we can inject errors first.

Просмотреть файл

@ -27,7 +27,7 @@ func (s *aztestsSuite) TestStageGetBlocks(c *chk.C) {
blockID := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 0)))
putResp, err := blob.StageBlock(context.Background(), blockID, getReaderToRandomBytes(1024), LeaseAccessConditions{}, nil)
putResp, err := blob.StageBlock(context.Background(), blockID, getReaderToRandomBytes(1024), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(putResp.Response().StatusCode, chk.Equals, 201)
c.Assert(putResp.ContentMD5(), chk.Not(chk.Equals), "")
@ -48,7 +48,7 @@ func (s *aztestsSuite) TestStageGetBlocks(c *chk.C) {
c.Assert(blockList.CommittedBlocks, chk.HasLen, 0)
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 1)
listResp, err := blob.CommitBlockList(context.Background(), []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
listResp, err := blob.CommitBlockList(context.Background(), []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
c.Assert(listResp.LastModified().IsZero(), chk.Equals, false)
@ -88,7 +88,7 @@ func (s *aztestsSuite) TestStageBlockFromURL(c *chk.C) {
destBlob := container.NewBlockBlobURL(generateBlobName())
// Prepare source blob for copy.
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
@ -110,7 +110,7 @@ func (s *aztestsSuite) TestStageBlockFromURL(c *chk.C) {
// Stage blocks from URL.
blockID1, blockID2 := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 0))), base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 1)))
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 4*1024*1024, LeaseAccessConditions{}, ModifiedAccessConditions{})
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 4*1024*1024, LeaseAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(stageResp1.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp1.ContentMD5(), chk.Not(chk.Equals), "")
@ -118,7 +118,7 @@ func (s *aztestsSuite) TestStageBlockFromURL(c *chk.C) {
c.Assert(stageResp1.Version(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.Date().IsZero(), chk.Equals, false)
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 4*1024*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{})
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 4*1024*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(stageResp2.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp2.ContentMD5(), chk.Not(chk.Equals), "")
@ -134,12 +134,12 @@ func (s *aztestsSuite) TestStageBlockFromURL(c *chk.C) {
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
// Commit block list.
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
// Check data integrity through downloading.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -163,7 +163,7 @@ func (s *aztestsSuite) TestCopyBlockBlobFromURL(c *chk.C) {
destBlob := container.NewBlockBlobURL(generateBlobName())
// Prepare source blob for copy.
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
@ -196,7 +196,7 @@ func (s *aztestsSuite) TestCopyBlockBlobFromURL(c *chk.C) {
c.Assert(string(resp.CopyStatus()), chk.DeepEquals, "success")
// Check data integrity through downloading.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -231,7 +231,7 @@ func (s *aztestsSuite) TestBlobSASQueryParamOverrideResponseHeaders(c *chk.C) {
ctx := context.Background() // Use default Background context
blob := container.NewBlockBlobURL(generateBlobName())
uploadResp, err := blob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
uploadResp, err := blob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
@ -262,7 +262,7 @@ func (s *aztestsSuite) TestBlobSASQueryParamOverrideResponseHeaders(c *chk.C) {
blobURL := NewBlobURL(blobParts.URL(), NewPipeline(NewAnonymousCredential(), PipelineOptions{}))
gResp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
gResp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(gResp.CacheControl(), chk.Equals, cacheControlVal)
c.Assert(gResp.ContentDisposition(), chk.Equals, contentDispositionVal)
@ -282,7 +282,7 @@ func (s *aztestsSuite) TestStageBlockWithMD5(c *chk.C) {
// test put block with valid MD5 value
readerToBody, body := getRandomDataAndReader(1024)
md5Value := md5.Sum(body)
putResp, err := blob.StageBlock(context.Background(), blockID, readerToBody, LeaseAccessConditions{}, md5Value[:])
putResp, err := blob.StageBlock(context.Background(), blockID, readerToBody, LeaseAccessConditions{}, md5Value[:], ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(putResp.Response().StatusCode, chk.Equals, 201)
c.Assert(putResp.ContentMD5(), chk.DeepEquals, md5Value[:])
@ -293,7 +293,7 @@ func (s *aztestsSuite) TestStageBlockWithMD5(c *chk.C) {
// test put block with bad MD5 value
readerToBody, body = getRandomDataAndReader(1024)
_, badMD5 := getRandomDataAndReader(16)
putResp, err = blob.StageBlock(context.Background(), blockID, readerToBody, LeaseAccessConditions{}, badMD5[:])
putResp, err = blob.StageBlock(context.Background(), blockID, readerToBody, LeaseAccessConditions{}, badMD5[:], ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeMd5Mismatch)
}
@ -303,10 +303,10 @@ func (s *aztestsSuite) TestBlobPutBlobNonEmptyBody(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, err := ioutil.ReadAll(resp.Response().Body)
c.Assert(string(data), chk.Equals, blockBlobDefaultData)
@ -318,10 +318,10 @@ func (s *aztestsSuite) TestBlobPutBlobHTTPHeaders(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
h := resp.NewHTTPHeaders()
h.ContentMD5 = nil // the service generates a MD5 value, omit before comparing
@ -334,10 +334,10 @@ func (s *aztestsSuite) TestBlobPutBlobMetadataNotEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -348,10 +348,10 @@ func (s *aztestsSuite) TestBlobPutBlobMetadataEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.HasLen, 0)
}
@ -362,7 +362,7 @@ func (s *aztestsSuite) TestBlobPutBlobMetadataInvalid(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.Upload(ctx, nil, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, nil, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(strings.Contains(err.Error(), validationErrorSubstring), chk.Equals, true)
}
@ -374,7 +374,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfModifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUpload(c, blobURL)
@ -388,7 +388,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -400,7 +400,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUpload(c, blobURL)
@ -414,7 +414,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfUnmodifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -424,10 +424,10 @@ func (s *aztestsSuite) TestBlobPutBlobIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUpload(c, blobURL)
@ -439,10 +439,10 @@ func (s *aztestsSuite) TestBlobPutBlobIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -452,10 +452,10 @@ func (s *aztestsSuite) TestBlobPutBlobIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUpload(c, blobURL)
@ -467,10 +467,10 @@ func (s *aztestsSuite) TestBlobPutBlobIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewBlockBlob(c, containerURL)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -488,7 +488,7 @@ func (s *aztestsSuite) TestBlobGetBlockListNone(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetBlockList(ctx, BlockListNone, LeaseAccessConditions{})
@ -503,7 +503,7 @@ func (s *aztestsSuite) TestBlobGetBlockListUncommitted(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetBlockList(ctx, BlockListUncommitted, LeaseAccessConditions{})
@ -518,10 +518,10 @@ func (s *aztestsSuite) TestBlobGetBlockListCommitted(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
resp, err := blobURL.GetBlockList(ctx, BlockListCommitted, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
@ -535,7 +535,7 @@ func (s *aztestsSuite) TestBlobGetBlockListCommittedEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetBlockList(ctx, BlockListCommitted, LeaseAccessConditions{})
@ -563,17 +563,17 @@ func (s *aztestsSuite) TestBlobGetBlockListBothNotEmpty(c *chk.C) {
id := newID()
// Put and commit two blocks
_, err := blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, id.issued(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, id.issued(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
// Put two uncommitted blocks
_, err = blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
@ -590,7 +590,7 @@ func (s *aztestsSuite) TestBlobGetBlockListInvalidType(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.GetBlockList(ctx, BlockListType("garbage"), LeaseAccessConditions{})
@ -603,12 +603,12 @@ func (s *aztestsSuite) TestBlobGetBlockListSnapshot(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
@ -623,7 +623,7 @@ func (s *aztestsSuite) TestBlobPutBlockIDInvalidCharacters(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, "!!", strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, "!!", strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidQueryParameterValue)
}
@ -633,9 +633,9 @@ func (s *aztestsSuite) TestBlobPutBlockIDInvalidLength(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.StageBlock(ctx, "00000000", strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, "00000000", strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidBlobOrBlock)
}
@ -645,7 +645,7 @@ func (s *aztestsSuite) TestBlobPutBlockEmptyBody(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(""), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(""), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidHeaderValue)
}
@ -654,7 +654,7 @@ func setupPutBlockListTest(c *chk.C) (containerURL ContainerURL, blobURL BlockBl
containerURL, _ = createNewContainer(c, bsu)
blobURL, _ = getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
return containerURL, blobURL, blockID
}
@ -663,7 +663,7 @@ func (s *aztestsSuite) TestBlobPutBlockListInvalidID(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id[:2]}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id[:2]}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidBlockID)
}
@ -671,7 +671,7 @@ func (s *aztestsSuite) TestBlobPutBlockListDuplicateBlocks(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id, id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id, id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
@ -683,7 +683,7 @@ func (s *aztestsSuite) TestBlobPutBlockListEmptyList(c *chk.C) {
containerURL, blobURL, _ := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
@ -695,10 +695,10 @@ func (s *aztestsSuite) TestBlobPutBlockListMetadataEmpty(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.HasLen, 0)
}
@ -707,10 +707,10 @@ func (s *aztestsSuite) TestBlobPutBlockListMetadataNonEmpty(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -719,10 +719,10 @@ func (s *aztestsSuite) TestBlobPutBlockListHTTPHeaders(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
h := resp.NewHTTPHeaders()
c.Assert(h, chk.DeepEquals, basicHeaders)
}
@ -731,13 +731,13 @@ func (s *aztestsSuite) TestBlobPutBlockListHTTPHeadersEmpty(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{ContentDisposition: "my_disposition"}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{ContentDisposition: "my_disposition"}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ContentDisposition(), chk.Equals, "")
}
@ -751,12 +751,12 @@ func validateBlobCommitted(c *chk.C, blobURL BlockBlobURL) {
func (s *aztestsSuite) TestBlobPutBlockListIfModifiedSinceTrue(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}) // The blob must actually exist to have a modifed time
c.Assert(err, chk.IsNil)
currentTime := getRelativeTimeGMT(-10)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlobCommitted(c, blobURL)
@ -768,19 +768,19 @@ func (s *aztestsSuite) TestBlobPutBlockListIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceTrue(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}) // The blob must actually exist to have a modifed time
c.Assert(err, chk.IsNil)
currentTime := getRelativeTimeGMT(10)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlobCommitted(c, blobURL)
@ -788,12 +788,12 @@ func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceTrue(c *chk.C) {
func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceFalse(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}) // The blob must actually exist to have a modifed time
defer deleteContainer(c, containerURL)
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -801,10 +801,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceFalse(c *chk.C) {
func (s *aztestsSuite) TestBlobPutBlockListIfMatchTrue(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}) // The blob must actually exist to have a modifed time
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlobCommitted(c, blobURL)
@ -813,10 +813,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfMatchTrue(c *chk.C) {
func (s *aztestsSuite) TestBlobPutBlockListIfMatchFalse(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}) // The blob must actually exist to have a modifed time
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -824,10 +824,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfMatchFalse(c *chk.C) {
func (s *aztestsSuite) TestBlobPutBlockListIfNoneMatchTrue(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}) // The blob must actually exist to have a modifed time
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateBlobCommitted(c, blobURL)
@ -836,10 +836,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfNoneMatchTrue(c *chk.C) {
func (s *aztestsSuite) TestBlobPutBlockListIfNoneMatchFalse(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{}) // The blob must actually exist to have a modifed time
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -848,9 +848,9 @@ func (s *aztestsSuite) TestBlobPutBlockListValidateData(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
data, _ := ioutil.ReadAll(resp.Response().Body)
c.Assert(string(data), chk.Equals, blockBlobDefaultData)
@ -860,19 +860,19 @@ func (s *aztestsSuite) TestBlobPutBlockListModifyBlob(c *chk.C) {
containerURL, blobURL, id := setupPutBlockListTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.StageBlock(ctx, "0001", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, "0001", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.StageBlock(ctx, "0010", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, "0010", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.StageBlock(ctx, "0011", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, "0011", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.StageBlock(ctx, "0100", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil)
_, err = blobURL.StageBlock(ctx, "0100", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{"0001", "0011"}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{"0001", "0011"}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
@ -890,10 +890,10 @@ func (s *aztestsSuite) TestSetTierOnBlobUpload(c *chk.C) {
for _, tier := range []AccessTierType{AccessTierArchive, AccessTierCool, AccessTierHot} {
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.Upload(ctx, strings.NewReader("Test Data"), basicHeaders, nil, BlobAccessConditions{}, tier, nil)
_, err := blobURL.Upload(ctx, strings.NewReader("Test Data"), basicHeaders, nil, BlobAccessConditions{}, tier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.AccessTier(), chk.Equals, string(tier))
}
@ -907,10 +907,10 @@ func (s *aztestsSuite) TestBlobSetTierOnCommit(c *chk.C) {
for _, tier := range []AccessTierType{AccessTierCool, AccessTierHot} {
blobURL, _ := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier, nil)
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier, nil, ClientProvidedKeyOptions{})
resp, err := blobURL.GetBlockList(ctx, BlockListCommitted, LeaseAccessConditions{})
c.Assert(err, chk.IsNil)
@ -932,7 +932,7 @@ func (s *aztestsSuite) TestSetTierOnCopyBlockBlobFromURL(c *chk.C) {
srcBlob := container.NewBlockBlobURL(generateBlobName())
// Setting blob tier as "cool"
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, AccessTierCool, nil)
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, AccessTierCool, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
@ -962,7 +962,7 @@ func (s *aztestsSuite) TestSetTierOnCopyBlockBlobFromURL(c *chk.C) {
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
c.Assert(string(resp.CopyStatus()), chk.DeepEquals, "success")
destBlobPropResp, err := destBlob.GetProperties(ctx, BlobAccessConditions{})
destBlobPropResp, err := destBlob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(destBlobPropResp.AccessTier(), chk.Equals, string(tier))
@ -986,7 +986,7 @@ func (s *aztestsSuite) TestSetTierOnStageBlockFromURL(c *chk.C) {
tier := AccessTierCool
// Prepare source blob for copy.
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, tier, nil)
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, tier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
@ -1008,7 +1008,7 @@ func (s *aztestsSuite) TestSetTierOnStageBlockFromURL(c *chk.C) {
// Stage blocks from URL.
blockID1, blockID2 := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 0))), base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 1)))
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 4*1024*1024, LeaseAccessConditions{}, ModifiedAccessConditions{})
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 4*1024*1024, LeaseAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(stageResp1.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp1.ContentMD5(), chk.Not(chk.Equals), "")
@ -1016,7 +1016,7 @@ func (s *aztestsSuite) TestSetTierOnStageBlockFromURL(c *chk.C) {
c.Assert(stageResp1.Version(), chk.Not(chk.Equals), "")
c.Assert(stageResp1.Date().IsZero(), chk.Equals, false)
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 4*1024*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{})
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 4*1024*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(stageResp2.Response().StatusCode, chk.Equals, 201)
c.Assert(stageResp2.ContentMD5(), chk.Not(chk.Equals), "")
@ -1032,19 +1032,19 @@ func (s *aztestsSuite) TestSetTierOnStageBlockFromURL(c *chk.C) {
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
// Commit block list.
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier, nil)
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
// Check data integrity through downloading.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
c.Assert(destData, chk.DeepEquals, sourceData)
// Get properties to validate the tier
destBlobPropResp, err := destBlob.GetProperties(ctx, BlobAccessConditions{})
destBlobPropResp, err := destBlob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(destBlobPropResp.AccessTier(), chk.Equals, string(tier))
}

Просмотреть файл

@ -124,7 +124,7 @@ func (s *aztestsSuite) TestContainerCreateAccessContainer(c *chk.C) {
c.Assert(err, chk.IsNil)
blobURL := containerURL.NewBlockBlobURL(blobPrefix)
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
// Anonymous enumeration should be valid with container access
containerURL2 := NewContainerURL(containerURL.URL(), NewPipeline(NewAnonymousCredential(), PipelineOptions{}))
@ -135,7 +135,7 @@ func (s *aztestsSuite) TestContainerCreateAccessContainer(c *chk.C) {
// Getting blob data anonymously should still be valid with container access
blobURL2 := containerURL2.NewBlockBlobURL(blobPrefix)
resp, err := blobURL2.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL2.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -149,7 +149,7 @@ func (s *aztestsSuite) TestContainerCreateAccessBlob(c *chk.C) {
c.Assert(err, chk.IsNil)
blobURL := containerURL.NewBlockBlobURL(blobPrefix)
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
// Reference the same container URL but with anonymous credentials
containerURL2 := NewContainerURL(containerURL.URL(), NewPipeline(NewAnonymousCredential(), PipelineOptions{}))
@ -158,7 +158,7 @@ func (s *aztestsSuite) TestContainerCreateAccessBlob(c *chk.C) {
// Accessing blob specific data should be public
blobURL2 := containerURL2.NewBlockBlobURL(blobPrefix)
resp, err := blobURL2.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL2.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -171,7 +171,7 @@ func (s *aztestsSuite) TestContainerCreateAccessNone(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL := containerURL.NewBlockBlobURL(blobPrefix)
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
// Reference the same container URL but with anonymous credentials
containerURL2 := NewContainerURL(containerURL.URL(), NewPipeline(NewAnonymousCredential(), PipelineOptions{}))
@ -181,7 +181,7 @@ func (s *aztestsSuite) TestContainerCreateAccessNone(c *chk.C) {
// Blob data is not public
blobURL2 := containerURL2.NewBlockBlobURL(blobPrefix)
_, err = blobURL2.GetProperties(ctx, BlobAccessConditions{})
_, err = blobURL2.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.NotNil)
serr := err.(StorageError)
c.Assert(serr.Response().StatusCode, chk.Equals, 401) // HEAD request does not return a status code
@ -346,7 +346,7 @@ func (s *aztestsSuite) TestContainerListBlobsIncludeTypeMetadata(c *chk.C) {
defer deleteContainer(c, container)
_, blobNameNoMetadata := createBlockBlobWithPrefix(c, container, "a")
blobMetadata, blobNameMetadata := createBlockBlobWithPrefix(c, container, "b")
_, err := blobMetadata.SetMetadata(ctx, Metadata{"field": "value"}, BlobAccessConditions{})
_, err := blobMetadata.SetMetadata(ctx, Metadata{"field": "value"}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := container.ListBlobsFlatSegment(ctx, Marker{}, ListBlobsSegmentOptions{Details: BlobListingDetails{Metadata: true}})
@ -363,7 +363,7 @@ func (s *aztestsSuite) TestContainerListBlobsIncludeTypeSnapshots(c *chk.C) {
containerURL, _ := createNewContainer(c, bsu)
defer deleteContainer(c, containerURL)
blob, blobName := createNewBlockBlob(c, containerURL)
_, err := blob.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
_, err := blob.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := containerURL.ListBlobsFlatSegment(ctx, Marker{},
@ -405,7 +405,7 @@ func (s *aztestsSuite) TestContainerListBlobsIncludeTypeUncommitted(c *chk.C) {
containerURL, _ := createNewContainer(c, bsu)
defer deleteContainer(c, containerURL)
blobURL, blobName := getBlockBlobURL(c, containerURL)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := containerURL.ListBlobsFlatSegment(ctx, Marker{},
@ -454,7 +454,7 @@ func testContainerListBlobsIncludeMultipleImpl(c *chk.C, bsu ServiceURL) error {
defer deleteContainer(c, containerURL)
blobURL, _ := createBlockBlobWithPrefix(c, containerURL, "z")
_, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
_, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
blobURL2, _ := createBlockBlobWithPrefix(c, containerURL, "copy")
resp2, err := blobURL2.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
@ -640,7 +640,7 @@ func (s *aztestsSuite) TestContainerSetPermissionsPublicAccessNone(c *chk.C) {
bsu2 := NewServiceURL(bsu.URL(), pipeline)
containerURL2 := bsu2.NewContainerURL(containerName)
blobURL2 := containerURL2.NewBlockBlobURL(blobName)
_, err = blobURL2.Download(ctx, 0, 0, BlobAccessConditions{}, false)
_, err = blobURL2.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
// Get permissions via the original container URL so the request succeeds
resp, _ := containerURL.GetAccessPolicy(ctx, LeaseAccessConditions{})

Просмотреть файл

@ -20,7 +20,7 @@ func (s *aztestsSuite) TestPutGetPages(c *chk.C) {
blob, _ := createNewPageBlob(c, container)
pageRange := PageRange{Start: 0, End: 1023}
putResp, err := blob.UploadPages(context.Background(), 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil)
putResp, err := blob.UploadPages(context.Background(), 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(putResp.Response().StatusCode, chk.Equals, 201)
c.Assert(putResp.LastModified().IsZero(), chk.Equals, false)
@ -60,7 +60,7 @@ func (s *aztestsSuite) TestUploadPagesFromURL(c *chk.C) {
destBlob, _ := createNewPageBlobWithSize(c, container, int64(testSize))
// Prepare source blob for copy.
uploadSrcResp1, err := srcBlob.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil)
uploadSrcResp1, err := srcBlob.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp1.Response().StatusCode, chk.Equals, 201)
@ -81,7 +81,7 @@ func (s *aztestsSuite) TestUploadPagesFromURL(c *chk.C) {
srcBlobURLWithSAS := srcBlobParts.URL()
// Upload page from URL.
pResp1, err := destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), nil, PageBlobAccessConditions{}, ModifiedAccessConditions{})
pResp1, err := destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), nil, PageBlobAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(pResp1.ETag(), chk.NotNil)
c.Assert(pResp1.LastModified(), chk.NotNil)
@ -92,7 +92,7 @@ func (s *aztestsSuite) TestUploadPagesFromURL(c *chk.C) {
c.Assert(pResp1.Date().IsZero(), chk.Equals, false)
// Check data integrity through downloading.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -116,7 +116,7 @@ func (s *aztestsSuite) TestUploadPagesFromURLWithMD5(c *chk.C) {
destBlob, _ := createNewPageBlobWithSize(c, container, int64(testSize))
// Prepare source blob for copy.
uploadSrcResp1, err := srcBlob.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil)
uploadSrcResp1, err := srcBlob.UploadPages(ctx, 0, r, PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(uploadSrcResp1.Response().StatusCode, chk.Equals, 201)
@ -137,7 +137,7 @@ func (s *aztestsSuite) TestUploadPagesFromURLWithMD5(c *chk.C) {
srcBlobURLWithSAS := srcBlobParts.URL()
// Upload page from URL with MD5.
pResp1, err := destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), md5Value[:], PageBlobAccessConditions{}, ModifiedAccessConditions{})
pResp1, err := destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), md5Value[:], PageBlobAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(pResp1.ETag(), chk.NotNil)
c.Assert(pResp1.LastModified(), chk.NotNil)
@ -149,7 +149,7 @@ func (s *aztestsSuite) TestUploadPagesFromURLWithMD5(c *chk.C) {
c.Assert(pResp1.BlobSequenceNumber(), chk.Equals, int64(0))
// Check data integrity through downloading.
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
c.Assert(err, chk.IsNil)
@ -157,7 +157,7 @@ func (s *aztestsSuite) TestUploadPagesFromURLWithMD5(c *chk.C) {
// Upload page from URL with bad MD5
_, badMD5 := getRandomDataAndReader(16)
_, err = destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), badMD5[:], PageBlobAccessConditions{}, ModifiedAccessConditions{})
_, err = destBlob.UploadPagesFromURL(ctx, srcBlobURLWithSAS, 0, 0, int64(testSize), badMD5[:], PageBlobAccessConditions{}, ModifiedAccessConditions{}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeMd5Mismatch)
}
@ -167,13 +167,13 @@ func (s *aztestsSuite) TestClearDiffPages(c *chk.C) {
defer delContainer(c, container)
blob, _ := createNewPageBlob(c, container)
_, err := blob.UploadPages(context.Background(), 0, getReaderToRandomBytes(2048), PageBlobAccessConditions{}, nil)
_, err := blob.UploadPages(context.Background(), 0, getReaderToRandomBytes(2048), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
snapshotResp, err := blob.CreateSnapshot(context.Background(), nil, BlobAccessConditions{})
snapshotResp, err := blob.CreateSnapshot(context.Background(), nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
_, err = blob.UploadPages(context.Background(), 2048, getReaderToRandomBytes(2048), PageBlobAccessConditions{}, nil)
_, err = blob.UploadPages(context.Background(), 2048, getReaderToRandomBytes(2048), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
pageList, err := blob.GetPageRangesDiff(context.Background(), 0, 4096, snapshotResp.Snapshot(), BlobAccessConditions{})
@ -182,7 +182,7 @@ func (s *aztestsSuite) TestClearDiffPages(c *chk.C) {
c.Assert(pageList.PageRange[0].Start, chk.Equals, int64(2048))
c.Assert(pageList.PageRange[0].End, chk.Equals, int64(4095))
clearResp, err := blob.ClearPages(context.Background(), 2048, 2048, PageBlobAccessConditions{})
clearResp, err := blob.ClearPages(context.Background(), 2048, 2048, PageBlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(clearResp.Response().StatusCode, chk.Equals, 201)
@ -199,9 +199,9 @@ func (s *aztestsSuite) TestIncrementalCopy(c *chk.C) {
c.Assert(err, chk.IsNil)
srcBlob, _ := createNewPageBlob(c, container)
_, err = srcBlob.UploadPages(context.Background(), 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil)
_, err = srcBlob.UploadPages(context.Background(), 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
snapshotResp, err := srcBlob.CreateSnapshot(context.Background(), nil, BlobAccessConditions{})
snapshotResp, err := srcBlob.CreateSnapshot(context.Background(), nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
dstBlob := container.NewPageBlobURL(generateBlobName())
@ -226,15 +226,15 @@ func (s *aztestsSuite) TestResizePageBlob(c *chk.C) {
defer delContainer(c, container)
blob, _ := createNewPageBlob(c, container)
resp, err := blob.Resize(context.Background(), 2048, BlobAccessConditions{})
resp, err := blob.Resize(context.Background(), 2048, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.Response().StatusCode, chk.Equals, 200)
resp, err = blob.Resize(context.Background(), 8192, BlobAccessConditions{})
resp, err = blob.Resize(context.Background(), 8192, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.Response().StatusCode, chk.Equals, 200)
resp2, err := blob.GetProperties(ctx, BlobAccessConditions{})
resp2, err := blob.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp2.ContentLength(), chk.Equals, int64(8192))
}
@ -269,7 +269,7 @@ func (s *aztestsSuite) TestPutPagesWithMD5(c *chk.C) {
// put page with valid MD5
readerToBody, body := getRandomDataAndReader(1024)
md5Value := md5.Sum(body)
putResp, err := blob.UploadPages(context.Background(), 0, readerToBody, PageBlobAccessConditions{}, md5Value[:])
putResp, err := blob.UploadPages(context.Background(), 0, readerToBody, PageBlobAccessConditions{}, md5Value[:], ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(putResp.Response().StatusCode, chk.Equals, 201)
c.Assert(putResp.LastModified().IsZero(), chk.Equals, false)
@ -283,7 +283,7 @@ func (s *aztestsSuite) TestPutPagesWithMD5(c *chk.C) {
// put page with bad MD5
readerToBody, body = getRandomDataAndReader(1024)
_, badMD5 := getRandomDataAndReader(16)
putResp, err = blob.UploadPages(context.Background(), 0, readerToBody, PageBlobAccessConditions{}, badMD5[:])
putResp, err = blob.UploadPages(context.Background(), 0, readerToBody, PageBlobAccessConditions{}, badMD5[:], ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeMd5Mismatch)
}
@ -293,7 +293,7 @@ func (s *aztestsSuite) TestBlobCreatePageSizeInvalid(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getPageBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, 1, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, 1, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeInvalidHeaderValue)
}
@ -303,7 +303,7 @@ func (s *aztestsSuite) TestBlobCreatePageSequenceInvalid(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getPageBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, PageBlobPageBytes, -1, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, -1, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.Not(chk.IsNil))
}
@ -313,9 +313,9 @@ func (s *aztestsSuite) TestBlobCreatePageMetadataNonEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getPageBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -326,9 +326,9 @@ func (s *aztestsSuite) TestBlobCreatePageMetadataEmpty(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getPageBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.HasLen, 0)
}
@ -339,7 +339,7 @@ func (s *aztestsSuite) TestBlobCreatePageMetadataInvalid(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getPageBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{"In valid1": "bar"}, BlobAccessConditions{}, PremiumPageBlobAccessTierNone, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{"In valid1": "bar"}, BlobAccessConditions{}, PremiumPageBlobAccessTierNone, nil, ClientProvidedKeyOptions{})
c.Assert(strings.Contains(err.Error(), invalidHeaderErrorSubstring), chk.Equals, true)
}
@ -350,17 +350,17 @@ func (s *aztestsSuite) TestBlobCreatePageHTTPHeaders(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getPageBlobURL(c, containerURL)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, basicHeaders, nil, BlobAccessConditions{}, PremiumPageBlobAccessTierNone, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, basicHeaders, nil, BlobAccessConditions{}, PremiumPageBlobAccessTierNone, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
h := resp.NewHTTPHeaders()
c.Assert(h, chk.DeepEquals, basicHeaders)
}
func validatePageBlobPut(c *chk.C, blobURL PageBlobURL) {
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.NewMetadata(), chk.DeepEquals, basicMetadata)
}
@ -373,7 +373,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfModifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validatePageBlobPut(c, blobURL)
@ -387,7 +387,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -399,7 +399,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validatePageBlobPut(c, blobURL)
@ -413,7 +413,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfUnmodifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -423,9 +423,9 @@ func (s *aztestsSuite) TestBlobCreatePageIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL) // Originally created without metadata
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, PremiumPageBlobAccessTierNone, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, PremiumPageBlobAccessTierNone, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validatePageBlobPut(c, blobURL)
@ -437,7 +437,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL) // Originally created without metadata
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -447,7 +447,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL) // Originally created without metadata
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validatePageBlobPut(c, blobURL)
@ -459,9 +459,9 @@ func (s *aztestsSuite) TestBlobCreatePageIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL) // Originally created without metadata
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultPremiumBlobAccessTier, nil)
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultPremiumBlobAccessTier, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -472,7 +472,7 @@ func (s *aztestsSuite) TestBlobPutPagesInvalidRange(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, strings.NewReader(blockBlobDefaultData), PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, 0, strings.NewReader(blockBlobDefaultData), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.Not(chk.IsNil))
}
@ -482,7 +482,7 @@ func (s *aztestsSuite) TestBlobPutPagesNilBody(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, nil, PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, 0, nil, PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.Not(chk.IsNil))
}
@ -492,7 +492,7 @@ func (s *aztestsSuite) TestBlobPutPagesEmptyBody(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, bytes.NewReader([]byte{}), PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, 0, bytes.NewReader([]byte{}), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.Not(chk.IsNil))
}
@ -502,7 +502,7 @@ func (s *aztestsSuite) TestBlobPutPagesNonExistantBlob(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := getPageBlobURL(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeBlobNotFound)
}
@ -521,8 +521,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfModifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -536,8 +535,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -549,8 +547,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -564,8 +561,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfUnmodifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -575,10 +571,9 @@ func (s *aztestsSuite) TestBlobPutPagesIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -590,8 +585,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -601,8 +595,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -614,10 +607,9 @@ func (s *aztestsSuite) TestBlobPutPagesIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -627,8 +619,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberLessThanTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 10}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 10}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -641,8 +632,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberLessThanFalse(c *chk.C) {
blobURL, _ := createNewPageBlob(c, containerURL)
blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 10, BlobAccessConditions{})
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 1}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 1}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -652,8 +642,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberLessThanNegOne(c *chk.C)
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: -1}}, nil) // This will cause the library to set the value of the header to 0
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: -1}}, nil, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -664,8 +653,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberLTETrue(c *chk.C) {
blobURL, _ := createNewPageBlob(c, containerURL)
blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 1, BlobAccessConditions{})
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 1}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 1}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -678,8 +666,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberLTEqualFalse(c *chk.C) {
blobURL, _ := createNewPageBlob(c, containerURL)
blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 10, BlobAccessConditions{})
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 1}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 1}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -689,8 +676,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberLTENegOne(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: -1}}, nil) // This will cause the library to set the value of the header to 0
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: -1}}, nil, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -703,8 +689,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberEqualTrue(c *chk.C) {
blobURL, _ := createNewPageBlob(c, containerURL)
blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 1, BlobAccessConditions{})
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 1}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 1}}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -716,8 +701,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberEqualFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 1}}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 1}}, nil, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -727,8 +711,7 @@ func (s *aztestsSuite) TestBlobPutPagesIfSequenceNumberEqualNegOne(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes),
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: -1}}, nil) // This will cause the library to set the value of the header to 0
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: -1}}, nil, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
c.Assert(err, chk.IsNil)
validateUploadPages(c, blobURL)
@ -739,7 +722,7 @@ func setupClearPagesTest(c *chk.C) (ContainerURL, PageBlobURL) {
containerURL, _ := createNewContainer(c, bsu)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
return containerURL, blobURL
@ -755,7 +738,7 @@ func (s *aztestsSuite) TestBlobClearPagesInvalidRange(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes+1, PageBlobAccessConditions{})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes+1, PageBlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.Not(chk.IsNil))
}
@ -765,8 +748,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfModifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -778,8 +760,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -789,8 +770,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -802,8 +782,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfUnmodifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -811,10 +790,9 @@ func (s *aztestsSuite) TestBlobClearPagesIfMatchTrue(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -824,8 +802,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfMatchFalse(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -833,8 +810,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfNoneMatchTrue(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -844,10 +820,9 @@ func (s *aztestsSuite) TestBlobClearPagesIfNoneMatchFalse(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -855,8 +830,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberLessThanTrue(c *chk.C)
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 10}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 10}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -868,8 +842,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberLessThanFalse(c *chk.C)
_, err := blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 10, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 1}})
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: 1}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -877,8 +850,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberLessThanNegOne(c *chk.C
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: -1}}) // This will cause the library to set the value of the header to 0
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThan: -1}}, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -886,8 +858,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberLTETrue(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 10}})
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 10}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -899,8 +870,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberLTEFalse(c *chk.C) {
_, err := blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 10, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 1}})
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: 1}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -908,8 +878,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberLTENegOne(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: -1}}) // This will cause the library to set the value of the header to 0
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberLessThanOrEqual: -1}}, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -921,8 +890,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberEqualTrue(c *chk.C) {
_, err := blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 10, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 10}})
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 10}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -934,8 +902,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberEqualFalse(c *chk.C) {
_, err := blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionUpdate, 10, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 1}})
_, err = blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: 1}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeSequenceNumberConditionNotMet)
}
@ -943,8 +910,7 @@ func (s *aztestsSuite) TestBlobClearPagesIfSequenceNumberEqualNegOne(c *chk.C) {
containerURL, blobURL := setupClearPagesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes,
PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: -1}}) // This will cause the library to set the value of the header to 0
_, err := blobURL.ClearPages(ctx, 0, PageBlobPageBytes, PageBlobAccessConditions{SequenceNumberAccessConditions: SequenceNumberAccessConditions{IfSequenceNumberEqual: -1}}, ClientProvidedKeyOptions{}) // This will cause the library to set the value of the header to 0
c.Assert(err, chk.IsNil)
validateClearPagesTest(c, blobURL)
@ -955,7 +921,7 @@ func setupGetPageRangesTest(c *chk.C) (containerURL ContainerURL, blobURL PageBl
containerURL, _ = createNewContainer(c, bsu)
blobURL, _ = createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
return
@ -998,7 +964,7 @@ func (s *aztestsSuite) TestBlobGetPageRangesNonContiguousRanges(c *chk.C) {
containerURL, blobURL := setupGetPageRangesTest(c)
defer deleteContainer(c, containerURL)
_, err := blobURL.UploadPages(ctx, PageBlobPageBytes*2, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, PageBlobPageBytes*2, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetPageRanges(ctx, 0, 0, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
@ -1019,7 +985,7 @@ func (s *aztestsSuite) TestBlobGetPageRangesSnapshot(c *chk.C) {
containerURL, blobURL := setupGetPageRangesTest(c)
defer deleteContainer(c, containerURL)
resp, _ := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
resp, _ := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
resp2, err := snapshotURL.GetPageRanges(ctx, 0, 0, BlobAccessConditions{})
c.Assert(err, chk.IsNil)
@ -1075,7 +1041,7 @@ func (s *aztestsSuite) TestBlobGetPageRangesIfMatchTrue(c *chk.C) {
containerURL, blobURL := setupGetPageRangesTest(c)
defer deleteContainer(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
resp2, err := blobURL.GetPageRanges(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
@ -1104,7 +1070,7 @@ func (s *aztestsSuite) TestBlobGetPageRangesIfNoneMatchFalse(c *chk.C) {
containerURL, blobURL := setupGetPageRangesTest(c)
defer deleteContainer(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.GetPageRanges(ctx, 0, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
@ -1117,14 +1083,14 @@ func setupDiffPageRangesTest(c *chk.C) (containerURL ContainerURL, blobURL PageB
containerURL, _ = createNewContainer(c, bsu)
blobURL, _ = createNewPageBlob(c, containerURL)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil)
_, err := blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
snapshot = resp.Snapshot()
_, err = blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil)
_, err = blobURL.UploadPages(ctx, 0, getReaderToRandomBytes(PageBlobPageBytes), PageBlobAccessConditions{}, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil) // This ensures there is a diff on the first page
return
}
@ -1202,7 +1168,7 @@ func (s *aztestsSuite) TestBlobDiffPageRangeIfMatchTrue(c *chk.C) {
containerURL, blobURL, snapshot := setupDiffPageRangesTest(c)
defer deleteContainer(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
resp2, err := blobURL.GetPageRangesDiff(ctx, 0, 0, snapshot,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
@ -1231,7 +1197,7 @@ func (s *aztestsSuite) TestBlobDiffPageRangeIfNoneMatchFalse(c *chk.C) {
containerURL, blobURL, snapshot := setupDiffPageRangesTest(c)
defer deleteContainer(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.GetPageRangesDiff(ctx, 0, 0, snapshot,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
@ -1246,10 +1212,10 @@ func (s *aztestsSuite) TestBlobResizeZero(c *chk.C) {
blobURL, _ := createNewPageBlob(c, containerURL)
// The default blob is created with size > 0, so this should actually update
_, err := blobURL.Resize(ctx, 0, BlobAccessConditions{})
_, err := blobURL.Resize(ctx, 0, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.ContentLength(), chk.Equals, int64(0))
}
@ -1260,7 +1226,7 @@ func (s *aztestsSuite) TestBlobResizeInvalidSizeNegative(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.Resize(ctx, -4, BlobAccessConditions{})
_, err := blobURL.Resize(ctx, -4, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.Not(chk.IsNil))
}
@ -1270,12 +1236,12 @@ func (s *aztestsSuite) TestBlobResizeInvalidSizeMisaligned(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.Resize(ctx, 12, BlobAccessConditions{})
_, err := blobURL.Resize(ctx, 12, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.Not(chk.IsNil))
}
func validateResize(c *chk.C, blobURL PageBlobURL) {
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(resp.ContentLength(), chk.Equals, int64(PageBlobPageBytes))
}
@ -1287,8 +1253,7 @@ func (s *aztestsSuite) TestBlobResizeIfModifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateResize(c, blobURL)
@ -1302,8 +1267,7 @@ func (s *aztestsSuite) TestBlobResizeIfModifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1315,8 +1279,7 @@ func (s *aztestsSuite) TestBlobResizeIfUnmodifiedSinceTrue(c *chk.C) {
currentTime := getRelativeTimeGMT(10)
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateResize(c, blobURL)
@ -1330,8 +1293,7 @@ func (s *aztestsSuite) TestBlobResizeIfUnmodifiedSinceFalse(c *chk.C) {
currentTime := getRelativeTimeGMT(-10)
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1341,10 +1303,9 @@ func (s *aztestsSuite) TestBlobResizeIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateResize(c, blobURL)
@ -1356,8 +1317,7 @@ func (s *aztestsSuite) TestBlobResizeIfMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1367,8 +1327,7 @@ func (s *aztestsSuite) TestBlobResizeIfNoneMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
validateResize(c, blobURL)
@ -1380,10 +1339,9 @@ func (s *aztestsSuite) TestBlobResizeIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.Resize(ctx, PageBlobPageBytes,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
_, err := blobURL.Resize(ctx, PageBlobPageBytes, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, ClientProvidedKeyOptions{})
validateStorageError(c, err, ServiceCodeConditionNotMet)
}
@ -1411,7 +1369,7 @@ func (s *aztestsSuite) TestBlobSetSequenceNumberSequenceNumberInvalid(c *chk.C)
}
func validateSequenceNumberSet(c *chk.C, blobURL PageBlobURL) {
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
c.Assert(resp.BlobSequenceNumber(), chk.Equals, int64(1))
}
@ -1478,7 +1436,7 @@ func (s *aztestsSuite) TestBlobSetSequenceNumberIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionIncrement, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
@ -1517,7 +1475,7 @@ func (s *aztestsSuite) TestBlobSetSequenceNumberIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
blobURL, _ := createNewPageBlob(c, containerURL)
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := blobURL.UpdateSequenceNumber(ctx, SequenceNumberActionIncrement, 0,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
@ -1530,7 +1488,7 @@ func waitForIncrementalCopy(c *chk.C, copyBlobURL PageBlobURL, blobCopyResponse
// Wait for the copy to finish
start := time.Now()
for status != CopyStatusSuccess {
getPropertiesAndMetadataResult, _ = copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
getPropertiesAndMetadataResult, _ = copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
status = getPropertiesAndMetadataResult.CopyStatus()
currentTime := time.Now()
if currentTime.Sub(start) >= time.Minute {
@ -1545,7 +1503,7 @@ func setupStartIncrementalCopyTest(c *chk.C) (containerURL ContainerURL, blobURL
containerURL, _ = createNewContainer(c, bsu)
containerURL.SetAccessPolicy(ctx, PublicAccessBlob, nil, ContainerAccessConditions{})
blobURL, _ = createNewPageBlob(c, containerURL)
resp, _ := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
resp, _ := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{})
copyBlobURL, _ = getPageBlobURL(c, containerURL)
// Must create the incremental copy blob so that the access conditions work on it
@ -1553,7 +1511,7 @@ func setupStartIncrementalCopyTest(c *chk.C) (containerURL ContainerURL, blobURL
c.Assert(err, chk.IsNil)
waitForIncrementalCopy(c, copyBlobURL, resp2)
resp, _ = blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}) // Take a new snapshot so the next copy will succeed
resp, _ = blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{}, ClientProvidedKeyOptions{}) // Take a new snapshot so the next copy will succeed
snapshot = resp.Snapshot()
return
}
@ -1563,7 +1521,7 @@ func validateIncrementalCopy(c *chk.C, copyBlobURL PageBlobURL, resp *PageBlobCo
// If we can access the snapshot without error, we are satisfied that it was created as a result of the copy
copySnapshotURL := copyBlobURL.WithSnapshot(t)
_, err := copySnapshotURL.GetProperties(ctx, BlobAccessConditions{})
_, err := copySnapshotURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
}
@ -1636,7 +1594,7 @@ func (s *aztestsSuite) TestBlobStartIncrementalCopyIfMatchTrue(c *chk.C) {
defer deleteContainer(c, containerURL)
resp, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
resp2, err := copyBlobURL.StartCopyIncremental(ctx, blobURL.URL(), snapshot,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
@ -1672,7 +1630,7 @@ func (s *aztestsSuite) TestBlobStartIncrementalCopyIfNoneMatchFalse(c *chk.C) {
defer deleteContainer(c, containerURL)
resp, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{})
resp, _ := copyBlobURL.GetProperties(ctx, BlobAccessConditions{}, ClientProvidedKeyOptions{})
_, err := copyBlobURL.StartCopyIncremental(ctx, blobURL.URL(), snapshot,
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})

Просмотреть файл

@ -27,7 +27,7 @@ func (s *aztestsSuite) TestGetAccountInfo(c *chk.C) {
// test on a block blob URL. They all call the same thing on the base URL, so only one test is needed for that.
bbURL := cURL.NewBlockBlobURL(generateBlobName())
_, err = bbURL.Upload(ctx, strings.NewReader("blah"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = bbURL.Upload(ctx, strings.NewReader("blah"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
c.Assert(err, chk.IsNil)
bAccInfo, err := bbURL.GetAccountInfo(ctx)
c.Assert(err, chk.IsNil)

Просмотреть файл

@ -56,12 +56,12 @@ func (s *aztestsSuite) TestUserDelegationSASContainer(c *chk.C) {
cSASURL := NewContainerURL(cURL, p)
bblob := cSASURL.NewBlockBlobURL("test")
_, err = bblob.Upload(ctx, strings.NewReader("hello world!"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = bblob.Upload(ctx, strings.NewReader("hello world!"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
c.Fatal(err)
}
resp, err := bblob.Download(ctx, 0, 0, BlobAccessConditions{}, false)
resp, err := bblob.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
data := &bytes.Buffer{}
body := resp.Body(RetryReaderOptions{})
if body == nil {
@ -134,13 +134,13 @@ func (s *aztestsSuite) TestUserDelegationSASBlob(c *chk.C) {
c.Fatal(err)
}
data := "Hello World!"
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil, ClientProvidedKeyOptions{})
if err != nil {
c.Fatal(err)
}
// Download data via User Delegation SAS URL; must succeed
downloadResponse, err := bSASURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
downloadResponse, err := bSASURL.Download(ctx, 0, 0, BlobAccessConditions{}, false, ClientProvidedKeyOptions{})
if err != nil {
c.Fatal(err)
}

Просмотреть файл

@ -63,11 +63,9 @@ func (r *DownloadResponse) Body(o RetryReaderOptions) io.ReadCloser {
}
return NewRetryReader(r.ctx, r.Response(), r.getInfo, o,
func(ctx context.Context, getInfo HTTPGetterInfo) (*http.Response, error) {
resp, err := r.b.Download(ctx, getInfo.Offset, getInfo.Count,
BlobAccessConditions{
ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: getInfo.ETag},
},
false)
resp, err := r.b.Download(ctx, getInfo.Offset, getInfo.Count, BlobAccessConditions{
ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: getInfo.ETag},
}, false, o.ClientProvidedKeyOptions)
if err != nil {
return nil, err
}