|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative 'spec_helper' |
| 4 | + |
| 5 | +module Aws |
| 6 | + module Glacier |
| 7 | + describe Client do |
| 8 | + |
| 9 | + let(:client) { Client.new(stub_responses: true) } |
| 10 | + |
| 11 | + describe '#upload_archive' do |
| 12 | + # { |
| 13 | + # id: "GlacierVersionHeader", |
| 14 | + # documentation: "Glacier requires that a version header be set on all requests.", |
| 15 | + # protocol: restJson1, |
| 16 | + # method: "POST", |
| 17 | + # uri: "/foo/vaults/bar/archives", |
| 18 | + # headers: { |
| 19 | + # "X-Amz-Glacier-Version": "2012-06-01", |
| 20 | + # }, |
| 21 | + # body: "", |
| 22 | + # params: { |
| 23 | + # accountId: "foo", |
| 24 | + # vaultName: "bar", |
| 25 | + # }, |
| 26 | + # }, |
| 27 | + it 'GlacierVersionHeader' do |
| 28 | + resp = client.upload_archive( |
| 29 | + account_id: 'foo', |
| 30 | + vault_name: 'bar' |
| 31 | + ) |
| 32 | + request = resp.context.http_request |
| 33 | + expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01') |
| 34 | + end |
| 35 | + |
| 36 | + # { |
| 37 | + # id: "GlacierChecksums", |
| 38 | + # documentation: "Glacier requires checksum headers that are cumbersome to provide.", |
| 39 | + # protocol: restJson1, |
| 40 | + # method: "POST", |
| 41 | + # uri: "/foo/vaults/bar/archives", |
| 42 | + # headers: { |
| 43 | + # "X-Amz-Glacier-Version": "2012-06-01", |
| 44 | + # "X-Amz-Content-Sha256": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", |
| 45 | + # "X-Amz-Sha256-Tree-Hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", |
| 46 | + # }, |
| 47 | + # body: "hello world", |
| 48 | + # params: { |
| 49 | + # accountId: "foo", |
| 50 | + # vaultName: "bar", |
| 51 | + # body: "hello world" |
| 52 | + # }, |
| 53 | + # appliesTo: "client", |
| 54 | + # }, |
| 55 | + it 'GlacierChecksums' do |
| 56 | + resp = client.upload_archive( |
| 57 | + account_id: 'foo', |
| 58 | + vault_name: 'bar', |
| 59 | + body: 'hello world' |
| 60 | + ) |
| 61 | + request = resp.context.http_request |
| 62 | + expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01') |
| 63 | + expect(request.headers['x-amz-content-sha256']) |
| 64 | + .to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9') |
| 65 | + expect(request.headers['x-amz-sha256-tree-hash']) |
| 66 | + .to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9') |
| 67 | + end |
| 68 | + |
| 69 | + # { |
| 70 | + # id: "GlacierAccountId", |
| 71 | + # documentation: """ |
| 72 | + # Glacier requires that the account id be set, but you can just use a |
| 73 | + # hyphen (-) to indicate the current account. This should be default |
| 74 | + # behavior if the customer provides a null or empty string.""", |
| 75 | + # protocol: restJson1, |
| 76 | + # method: "POST", |
| 77 | + # uri: "/-/vaults/bar/archives", |
| 78 | + # headers: { |
| 79 | + # "X-Amz-Glacier-Version": "2012-06-01", |
| 80 | + # }, |
| 81 | + # body: "", |
| 82 | + # params: { |
| 83 | + # accountId: "", |
| 84 | + # vaultName: "bar", |
| 85 | + # }, |
| 86 | + # appliesTo: "client", |
| 87 | + # } |
| 88 | + it 'GlacierAccountId' do |
| 89 | + resp = client.upload_archive( |
| 90 | + account_id: '', |
| 91 | + vault_name: 'bar' |
| 92 | + ) |
| 93 | + request = resp.context.http_request |
| 94 | + expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01') |
| 95 | + expect(request.endpoint.path).to eq('/-/vaults/bar/archives') |
| 96 | + end |
| 97 | + end |
| 98 | + |
| 99 | + describe '#upload_multipart_part' do |
| 100 | + # { |
| 101 | + # id: "GlacierMultipartChecksums", |
| 102 | + # documentation: "Glacier requires checksum headers that are cumbersome to provide.", |
| 103 | + # protocol: restJson1, |
| 104 | + # method: "PUT", |
| 105 | + # uri: "/foo/vaults/bar/multipart-uploads/baz", |
| 106 | + # headers: { |
| 107 | + # "X-Amz-Glacier-Version": "2012-06-01", |
| 108 | + # "X-Amz-Content-Sha256": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", |
| 109 | + # "X-Amz-Sha256-Tree-Hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", |
| 110 | + # }, |
| 111 | + # body: "hello world", |
| 112 | + # params: { |
| 113 | + # accountId: "foo", |
| 114 | + # vaultName: "bar", |
| 115 | + # uploadId: "baz", |
| 116 | + # body: "hello world" |
| 117 | + # }, |
| 118 | + # appliesTo: "client", |
| 119 | + # } |
| 120 | + it 'GlacierMultipartChecksums' do |
| 121 | + resp = client.upload_multipart_part( |
| 122 | + account_id: 'foo', |
| 123 | + vault_name: 'bar', |
| 124 | + upload_id: 'baz', |
| 125 | + body: 'hello world' |
| 126 | + ) |
| 127 | + request = resp.context.http_request |
| 128 | + expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01') |
| 129 | + expect(request.headers['x-amz-content-sha256']) |
| 130 | + .to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9') |
| 131 | + expect(request.headers['x-amz-sha256-tree-hash']) |
| 132 | + .to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9') |
| 133 | + end |
| 134 | + end |
| 135 | + end |
| 136 | + end |
| 137 | +end |
0 commit comments