| 1 |
// Copyright 2019 Google LLC |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
syntax = "proto3"; |
| 16 |
|
| 17 |
package google.cloud.conformance.storage.v1; |
| 18 |
|
| 19 |
import "google/protobuf/timestamp.proto"; |
| 20 |
|
| 21 |
option csharp_namespace = "Google.Cloud.Storage.V1.Tests.Conformance"; |
| 22 |
option java_package = "com.google.cloud.conformance.storage.v1"; |
| 23 |
option java_multiple_files = true; |
| 24 |
option go_package = "google/cloud/conformance/storage/v1"; |
| 25 |
|
| 26 |
message TestFile { |
| 27 |
repeated SigningV4Test signing_v4_tests = 1; |
| 28 |
repeated PostPolicyV4Test post_policy_v4_tests = 2; |
| 29 |
repeated RetryTest retry_tests = 3; |
| 30 |
} |
| 31 |
|
| 32 |
enum UrlStyle { |
| 33 |
PATH_STYLE = 0; |
| 34 |
VIRTUAL_HOSTED_STYLE = 1; |
| 35 |
BUCKET_BOUND_HOSTNAME = 2; |
| 36 |
} |
| 37 |
|
| 38 |
message SigningV4Test { |
| 39 |
string fileName = 1; |
| 40 |
string description = 2; |
| 41 |
string bucket = 3; |
| 42 |
string object = 4; |
| 43 |
string method = 5; |
| 44 |
int64 expiration = 6; |
| 45 |
google.protobuf.Timestamp timestamp = 7; |
| 46 |
string expectedUrl = 8; |
| 47 |
map<string, string> headers = 9; |
| 48 |
map<string, string> query_parameters = 10; |
| 49 |
string scheme = 11; |
| 50 |
UrlStyle urlStyle = 12; |
| 51 |
string bucketBoundHostname = 13; |
| 52 |
string expectedCanonicalRequest = 14; |
| 53 |
string expectedStringToSign = 15; |
| 54 |
string hostname = 16; |
| 55 |
string clientEndpoint = 17; |
| 56 |
string emulatorHostname = 18; |
| 57 |
string universeDomain = 19; |
| 58 |
} |
| 59 |
|
| 60 |
message ConditionalMatches { |
| 61 |
repeated string expression = 1; |
| 62 |
} |
| 63 |
|
| 64 |
message PolicyConditions { |
| 65 |
repeated int32 contentLengthRange = 1; |
| 66 |
repeated string startsWith = 2; |
| 67 |
} |
| 68 |
|
| 69 |
// Specification documentation is located at: |
| 70 |
// https://cloud.google.com/storage/docs/authentication/signatures |
| 71 |
|
| 72 |
message PolicyInput { |
| 73 |
// http or https |
| 74 |
string scheme = 1; |
| 75 |
UrlStyle urlStyle = 2; |
| 76 |
string bucketBoundHostname = 3; |
| 77 |
string bucket = 4; |
| 78 |
string object = 5; |
| 79 |
int32 expiration = 6; |
| 80 |
google.protobuf.Timestamp timestamp = 7; |
| 81 |
/* |
| 82 |
fields with strict equivalence which are added into |
| 83 |
PolicyOutput.expectedDecodedPolicy to generate the |
| 84 |
signature. |
| 85 |
Expectations |
| 86 |
E.1: Order them in lexigraphical order so it's the |
| 87 |
signature can be verified across different language |
| 88 |
implementations. |
| 89 |
*/ |
| 90 |
map<string, string> fields = 8; |
| 91 |
PolicyConditions conditions = 9; |
| 92 |
} |
| 93 |
|
| 94 |
message PolicyOutput { |
| 95 |
string url = 1; |
| 96 |
map<string, string> fields = 2; |
| 97 |
/* |
| 98 |
Expectations |
| 99 |
E.1: PolicyInput.fields must be prepended to form expectedDecodedPolicy |
| 100 |
for consistent result across languages. Ordering doesn't matter to the |
| 101 |
service but the decision is made to make it easier to conform implementations |
| 102 |
in implementation. |
| 103 |
Example: |
| 104 |
# Step 1 |
| 105 |
PolicyInput.fields has: |
| 106 |
{ |
| 107 |
"content-disposition":"attachment; filename=\"~._-%=/é0Aa\"", |
| 108 |
"content-encoding":"gzip", |
| 109 |
"content-type":"text/plain", |
| 110 |
"success_action_redirect":"http://www.google.com/" |
| 111 |
} |
| 112 |
# Step 2 |
| 113 |
The expectedDecodedPolicy before prepending the PolicyInput.fields |
| 114 |
would look like this: |
| 115 |
{ |
| 116 |
"conditions":[ |
| 117 |
...prepend here in the same order provided in PolicyInput.fields... |
| 118 |
{"bucket":"bucket-name"}, |
| 119 |
{"key":"test-object"}, |
| 120 |
{"x-goog-date":"20200123T043530Z"}, |
| 121 |
{"x-goog-credential":"[email protected]/20200123/auto/storage/goog4_request"}, |
| 122 |
{"x-goog-algorithm":"GOOG4-RSA-SHA256"} |
| 123 |
], |
| 124 |
"expiration":"2020-01-23T04:35:40Z" |
| 125 |
} |
| 126 |
# Step 3 |
| 127 |
Then expectedDecodedPolicy should prepends PolicyInput.fields in |
| 128 |
the same order to PolicyOutput.expectedDecodedPolicy `conditions` key. |
| 129 |
{ |
| 130 |
"conditions":[ |
| 131 |
{"content-disposition":"attachment; filename=\"~._-%=/é0Aa\""}, |
| 132 |
{"content-encoding":"gzip"}, |
| 133 |
{"content-type":"text/plain"}, |
| 134 |
{"success_action_redirect":"http://www.google.com/"}, |
| 135 |
{"bucket":"bucket-name"}, |
| 136 |
{"key":"test-object"}, |
| 137 |
{"x-goog-date":"20200123T043530Z"}, |
| 138 |
{"x-goog-credential":"[email protected]/20200123/auto/storage/goog4_request"}, |
| 139 |
{"x-goog-algorithm":"GOOG4-RSA-SHA256"} |
| 140 |
], |
| 141 |
"expiration":"2020-01-23T04:35:40Z" |
| 142 |
} |
| 143 |
*/ |
| 144 |
|
| 145 |
string expectedDecodedPolicy = 3; |
| 146 |
} |
| 147 |
|
| 148 |
message PostPolicyV4Test { |
| 149 |
string description = 1; |
| 150 |
PolicyInput policyInput = 2; |
| 151 |
PolicyOutput policyOutput = 3; |
| 152 |
} |
| 153 |
|
| 154 |
/* |
| 155 |
------------------------------------------------------------------------------ |
| 156 |
Data types for retry conformance tests |
| 157 |
------------------------------------------------------------------------------ |
| 158 |
*/ |
| 159 |
|
| 160 |
message RetryTests { |
| 161 |
repeated RetryTest retryTests = 1; |
| 162 |
} |
| 163 |
|
| 164 |
// A list of instructions to send as headers to the GCS emulator. Each |
| 165 |
// instruction will force a specified failure for that request. |
| 166 |
message InstructionList { |
| 167 |
repeated string instructions = 1; |
| 168 |
} |
| 169 |
|
| 170 |
// Test resources that are necessary for a method call. For example, |
| 171 |
// storage.objects.get would require BUCKET and OBJECT. |
| 172 |
enum Resource { |
| 173 |
BUCKET = 0; |
| 174 |
OBJECT = 1; |
| 175 |
NOTIFICATION = 2; |
| 176 |
HMAC_KEY = 3; |
| 177 |
} |
| 178 |
|
| 179 |
// A particular storage API method and required resources in order to test it. |
| 180 |
// Methods must be implemented in tests for each language. |
| 181 |
message Method { |
| 182 |
string name = 1; // e.g. storage.objects.get |
| 183 |
repeated Resource resources = 2; |
| 184 |
string group = 3; // e.g. storage.resumable.upload |
| 185 |
} |
| 186 |
|
| 187 |
// Schema for a retry test, corresponding to a single scenario from the design |
| 188 |
// doc. |
| 189 |
message RetryTest { |
| 190 |
// Scenario number |
| 191 |
int32 id = 1; |
| 192 |
|
| 193 |
// Human-readable description of the test case. |
| 194 |
string description = 2; |
| 195 |
|
| 196 |
// list of emulator instruction sets. |
| 197 |
repeated InstructionList cases = 3; |
| 198 |
|
| 199 |
// List of API methods to be tested. |
| 200 |
repeated Method methods = 4; |
| 201 |
|
| 202 |
// Whether a precondition is provided (for conditionally-idempotent methods |
| 203 |
// only). |
| 204 |
bool preconditionProvided = 5; |
| 205 |
|
| 206 |
// Whether we expect the method calls to eventually succeed after the client |
| 207 |
// library retries. |
| 208 |
bool expectSuccess = 6; |
| 209 |
} |