This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jcookems/gb18030
Adding GB-18030 unit tests
- Loading branch information
Showing
5 changed files
with
970 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
#------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#-------------------------------------------------------------------------- | ||
require "integration/test_helper" | ||
require "azure/blob/blob_service" | ||
|
||
describe 'Blob GB-18030' do | ||
subject { Azure::Blob::BlobService.new } | ||
after { ContainerNameHelper.clean } | ||
|
||
let(:container_name) { ContainerNameHelper.name } | ||
let(:blob_name) { "blobname" } | ||
let(:length) { 1024 } | ||
|
||
before { | ||
subject.create_container container_name | ||
subject.create_page_blob container_name, blob_name, length | ||
} | ||
|
||
it 'Read/Write Blob Container Name UTF-8' do | ||
# Expected results: Failure, because the Blob | ||
# container name can only contain ASCII | ||
# characters, per the Blob Service spec. | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
subject.create_container container_name + v.encode("UTF-8") | ||
flunk "No exception" | ||
rescue | ||
# Add validation? | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Container Name GB-18030' do | ||
# Expected results: Failure, because the Blob | ||
# container name can only contain ASCII | ||
# characters, per the Blob Service spec. | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
subject.create_container container_name + v.encode("GB18030") | ||
flunk "No exception" | ||
rescue | ||
# Add validation? | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Name UTF-8' do | ||
container_name = ContainerNameHelper.name | ||
subject.create_container container_name | ||
GB18030TestStrings.get.each { |k,v| | ||
# The Blob service does not support characters from extended plains. | ||
if k != 'ChineseExtB' then | ||
test_name = container_name + v.encode("UTF-8") | ||
subject.create_block_blob container_name, test_name, "hi" | ||
blobs = subject.list_blobs container_name | ||
blobs.each { |v| | ||
v.name.must_equal test_name | ||
} | ||
subject.delete_blob container_name, test_name | ||
end | ||
} | ||
end | ||
|
||
# Fails because of https://github.com/appfog/azure-sdk-for-ruby/issues/293 | ||
it 'Read/Write Blob Name GB18030' do | ||
container_name = ContainerNameHelper.name | ||
subject.create_container container_name | ||
GB18030TestStrings.get.each { |k,v| | ||
# The Blob service does not support characters from extended plains. | ||
if k != 'ChineseExtB' then | ||
test_name = container_name + v.encode("GB18030") | ||
subject.create_block_blob container_name, test_name, "hi" | ||
blobs = subject.list_blobs container_name | ||
blobs.each { |v| | ||
v.name.encode("UTF-8").must_equal test_name.encode("UTF-8") | ||
} | ||
subject.delete_blob container_name, test_name | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Metadata UTF-8 key' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" + v.encode("UTF-8") => "CustomMetadataValue" } | ||
subject.set_blob_metadata container_name, blob_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
error.status_code.must_equal 400 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Metadata GB-18030 key' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" + v.encode("GB18030") => "CustomMetadataValue" } | ||
subject.set_blob_metadata container_name, blob_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
error.status_code.must_equal 400 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Metadata UTF-8 value' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" => "CustomMetadataValue" + v.encode("UTF-8")} | ||
subject.set_blob_metadata container_name, blob_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
# TODO: Error should really be 400 | ||
error.status_code.must_equal 403 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Metadata GB-18030 value' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" => "CustomMetadataValue" + v.encode("GB18030")} | ||
subject.set_blob_metadata container_name, blob_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
# TODO: Error should really be 400 | ||
error.status_code.must_equal 403 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Block Content UTF-8' do | ||
GB18030TestStrings.get.each { |k,v| | ||
blob_name = 'Read/Write Block Blob Content UTF-8 for ' + k | ||
content = v.encode("UTF-8") | ||
# The :content_encoding can be removed if feature in | ||
# https://github.com/appfog/azure-sdk-for-ruby/issues/294 | ||
# is added. | ||
options = { :content_encoding=>"UTF-8" } | ||
subject.create_block_blob container_name, blob_name, content, options | ||
blob, returned_content = subject.get_blob container_name, blob_name | ||
returned_content.force_encoding(blob.properties[:content_encoding]) | ||
returned_content.must_equal content | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Block Content GB18030' do | ||
GB18030TestStrings.get.each { |k,v| | ||
blob_name = 'Read/Write Block Blob Content GB18030 for ' + k | ||
content = v.encode("GB18030") | ||
options = { :content_encoding=>"GB18030" } | ||
subject.create_block_blob container_name, blob_name, content, options | ||
blob, returned_content = subject.get_blob container_name, blob_name | ||
returned_content.force_encoding(blob.properties[:content_encoding]) | ||
returned_content.must_equal content | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Page Content UTF-8' do | ||
GB18030TestStrings.get.each { |k,v| | ||
blob_name = 'Read/Write Page Blob Content UTF-8 for ' + k | ||
options = { :content_encoding=>"UTF-8" } | ||
content = v.encode("UTF-8") | ||
while content.bytesize < 512 do | ||
content << "X" | ||
end | ||
subject.create_page_blob container_name, blob_name, 512, options | ||
subject.create_blob_pages container_name, blob_name, 0, 511, content | ||
blob, returned_content = subject.get_blob container_name, blob_name | ||
returned_content.force_encoding(blob.properties[:content_encoding]) | ||
returned_content.must_equal content | ||
} | ||
end | ||
|
||
it 'Read/Write Blob Page Content GB18030' do | ||
GB18030TestStrings.get.each { |k,v| | ||
blob_name = 'Read/Write Page Blob Content GB18030 for ' + k | ||
options = { :content_encoding=>"GB18030" } | ||
content = v.encode("GB18030") | ||
while content.bytesize < 512 do | ||
content << "X" | ||
end | ||
subject.create_page_blob container_name, blob_name, 512, options | ||
subject.create_blob_pages container_name, blob_name, 0, 511, content | ||
blob, returned_content = subject.get_blob container_name, blob_name | ||
returned_content.force_encoding(blob.properties[:content_encoding]) | ||
returned_content.must_equal content | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#-------------------------------------------------------------------------- | ||
require "integration/test_helper" | ||
require "azure/blob/blob_service" | ||
|
||
describe 'Queue GB-18030' do | ||
subject { Azure::Queue::QueueService.new } | ||
|
||
let(:queue_name){ QueueNameHelper.name } | ||
|
||
before { | ||
subject.create_queue queue_name | ||
} | ||
|
||
it 'Read/Write Queue Name UTF-8' do | ||
# Expected results: Failure, because the Queue | ||
# name can only contain ASCII | ||
# characters, per the Queue Service spec. | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
subject.create_queue queue_name + v.encode("UTF-8") | ||
flunk "No exception" | ||
rescue | ||
# Add validation? | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Queue Name GB-18030' do | ||
# Expected results: Failure, because the Queue | ||
# name can only contain ASCII | ||
# characters, per the Queue Service spec. | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
subject.create_queue queue_name + v.encode("GB18030") | ||
flunk "No exception" | ||
rescue | ||
# Add validation? | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Queue Metadata UTF-8 key' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" + v.encode("UTF-8") => "CustomMetadataValue" } | ||
subject.set_queue_metadata queue_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
error.status_code.must_equal 400 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Queue Metadata GB-18030 key' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" + v.encode("GB18030") => "CustomMetadataValue" } | ||
subject.set_queue_metadata queue_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
error.status_code.must_equal 400 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Queue Metadata UTF-8 value' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" => "CustomMetadataValue" + v.encode("UTF-8")} | ||
subject.set_queue_metadata queue_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
# TODO: Error should really be 400 | ||
error.status_code.must_equal 403 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Queue Metadata GB-18030 value' do | ||
GB18030TestStrings.get.each { |k,v| | ||
begin | ||
metadata = {"custommetadata" => "CustomMetadataValue" + v.encode("GB18030")} | ||
subject.set_queue_metadata queue_name, metadata | ||
flunk "No exception" | ||
rescue Azure::Core::Http::HTTPError => error | ||
# TODO: Error should really be 400 | ||
error.status_code.must_equal 403 | ||
end | ||
} | ||
end | ||
|
||
it 'Read/Write Queue Content UTF-8' do | ||
GB18030TestStrings.get.each { |k,v| | ||
content = v.encode("UTF-8") | ||
subject.create_message queue_name, content | ||
messages = subject.list_messages queue_name, 500 | ||
message = messages.first | ||
returned_content = message.message_text | ||
returned_content.must_equal content | ||
subject.delete_message queue_name, message.id, message.pop_receipt | ||
} | ||
end | ||
|
||
# Fails because of | ||
# https://github.com/appfog/azure-sdk-for-ruby/issues/295 | ||
it 'Read/Write Queue Content GB18030' do | ||
GB18030TestStrings.get.each { |k,v| | ||
content = v.encode("GB18030") | ||
subject.create_message queue_name, content | ||
messages = subject.list_messages queue_name, 500 | ||
message = messages.first | ||
returned_content = message.message_text | ||
returned_content.encode("UTF-8").must_equal content.encode("UTF-8") | ||
subject.delete_message queue_name, message.id, message.pop_receipt | ||
} | ||
end | ||
|
||
end |
Oops, something went wrong.